Skip to content

Commit 95f598d

Browse files
authored
Merge pull request #121 from acidlabsdev/main
fix(misc): miscellaneous fixes and improvements
2 parents 47cb5ee + 4e7f0ff commit 95f598d

55 files changed

Lines changed: 1259 additions & 846 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SSV2/includes/backend.lua

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ local Backend = {
7474

7575
---@type table<eEntityType, integer>
7676
MaxAllowedEntities = {
77-
[Enums.eEntityType.Ped] = 50,
78-
[Enums.eEntityType.Vehicle] = 25,
79-
[Enums.eEntityType.Object] = 75,
77+
[Enums.eEntityType.Ped] = 25,
78+
[Enums.eEntityType.Vehicle] = 15,
79+
[Enums.eEntityType.Object] = 35,
8080
},
8181
}
8282
Backend.__index = Backend
@@ -456,7 +456,6 @@ function Backend:OnPlayerSwitch()
456456
end
457457

458458
self.is_in_player_transition = true
459-
460459
ThreadManager:Run(function()
461460
self:TriggerEventCallbacks(Enums.eBackendEvent.PLAYER_SWITCH)
462461

@@ -469,36 +468,39 @@ function Backend:OnPlayerSwitch()
469468
end
470469

471470
function Backend:RegisterHandlers()
472-
self.debug_mode = self:IsMockEnv() or GVars.backend.debug_mode or false
471+
local mockEnv = self:IsMockEnv()
472+
self.debug_mode = mockEnv or GVars.backend.debug_mode or false
473473

474-
if (self:IsMockEnv()) then
475-
return
476-
end
474+
if (mockEnv) then return end
477475

478476
ThreadManager:RegisterLooped("SS_CTRLS", function()
479477
if (self.disable_input) then
480478
PAD.DISABLE_ALL_CONTROL_ACTIONS(0)
481-
end
482-
483-
if ((gui.is_open() or GUI:IsOpen()) and not self.disable_input) then
484-
self:DisableAttackInput()
485-
end
479+
else
480+
if ((gui.is_open() or GUI:IsOpen())) then
481+
self:DisableAttackInput()
482+
end
486483

487-
for _, control in pairs(self.ControlsToDisable) do
488-
PAD.DISABLE_CONTROL_ACTION(0, control, true)
484+
for _, control in pairs(self.ControlsToDisable) do
485+
PAD.DISABLE_CONTROL_ACTION(0, control, true)
486+
end
489487
end
490488
end)
491489

492490
ThreadManager:RegisterLooped("SS_BACKEND", function()
493491
self:OnPlayerSwitch()
494492
self:OnSessionSwitch()
493+
495494
PreviewService:Update()
496495
Decorator:CollectGarbage()
496+
Translator:OnTick()
497+
497498
yield()
498499
end)
499500

500501
ThreadManager:RegisterLooped("SS_POOLMGR", function()
501502
self:PoolMgr()
503+
yield()
502504
end)
503505

504506
event.register_handler(menu_event.MenuUnloaded, function() self:Cleanup() end)

SSV2/includes/classes/Mutex.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
--------------------------------------
1111
-- Class: Mutex
1212
--------------------------------------
13-
-- Simple mutual exclusion.
13+
-- Simple mutual exclusivity.
1414
---@class Mutex
1515
---@field protected m_locked boolean
1616
---@overload fun(): Mutex
@@ -42,9 +42,10 @@ function Mutex:Release()
4242
end
4343

4444
-- Scoped lock.
45-
---@param func function
45+
---@generic R1, R2, R3, R4, R5
46+
---@param func fun(...?: any): R1?, R2?, R3?, R4?, R5?, ...?
4647
---@param ... any
47-
---@return ...
48+
---@return boolean success, R1?, R2?, R3?, R4?, R5?, ...?
4849
function Mutex:WithLock(func, ...)
4950
self:Acquire()
5051
local ret = { xpcall(func, function(msg)

SSV2/includes/classes/gta/CPed.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ local CPlayerInfo = require("includes.classes.gta.CPlayerInfo")
2727
---@field m_ped_weapon_mgr pointer_ref<CPedWeaponManager>
2828
---@field m_player_info CPlayerInfo
2929
---@field m_velocity pointer<vec3>
30-
---@field m_ped_type pointer<uint8_t>
30+
---@field m_ped_type pointer<uint32_t>
3131
---@field m_ped_task_flag pointer<uint8_t>
3232
---@field m_seatbelt pointer<uint8_t>
3333
---@field m_armor pointer<float>
@@ -64,14 +64,14 @@ end
6464
---@return boolean
6565
function CPed:CanRagdoll()
6666
return self:__safecall(false, function()
67-
return (self.m_ped_type & 0x20) ~= 0
67+
return (self.m_ped_type:get_dword() & 0x20) ~= 0
6868
end)
6969
end
7070

7171
---@return boolean
7272
function CPed:HasSeatbelt()
7373
return self:__safecall(false, function()
74-
return (self.m_seatbelt & 0x3) ~= 0
74+
return (self.m_seatbelt:get_byte() & 0x3) ~= 0
7575
end)
7676
end
7777

@@ -85,7 +85,7 @@ end
8585
---@return ePedType
8686
function CPed:GetPedType()
8787
return self:__safecall(-1, function()
88-
return (self.m_ped_type:get_word() << 11 >> 25)
88+
return (self.m_ped_type:get_dword() << 11 >> 25)
8989
end)
9090
end
9191

SSV2/includes/data/config.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ local Config <const> = {
1414
auto_cleanup_entities = false,
1515
language_index = 1,
1616
language_code = "en-US",
17-
language_name = "English"
17+
language_name = "English",
18+
use_game_language = false
1819
},
1920
ui = {
2021
disable_tooltips = false,

SSV2/includes/data/enums/__init__.lua

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@
88

99

1010
local Enums <const> = {
11+
eActionType = require("includes.data.enums.action_type"),
12+
eAnimFlags = require("includes.data.enums.anim_flags"),
13+
eDrivingFlags = require("includes.data.enums.driving_flags"),
1114
eGameState = require("includes.data.enums.game_state"),
12-
eModelType = require("includes.data.enums.model_type"),
13-
eRagdollBlockingFlags = require("includes.data.enums.ragdoll_blocking_flags"),
14-
eVehicleClasses = require("includes.data.enums.vehicle_classes"),
15+
eGameLanguage = require("includes.data.enums.game_language"),
1516
eHandlingType = require("includes.data.enums.handling_type"),
16-
eDrivingFlags = require("includes.data.enums.driving_flags"),
17-
eVehicleHandlingFlags = require("includes.data.enums.handling_flags"),
18-
eVehicleModelFlags = require("includes.data.enums.vehicle_model_flags"),
19-
eVehicleModelInfoFlags = require("includes.data.enums.vehicle_model_info_flags"),
20-
eVehicleAdvancedFlags = require("includes.data.enums.vehicle_advanced_flags"),
21-
ePedType = require("includes.data.enums.ped_type"),
22-
ePedGender = require("includes.data.enums.ped_gender"),
17+
eLandingGearState = require("includes.data.enums.landing_gear_state"),
18+
eModelType = require("includes.data.enums.model_type"),
19+
ePedCombatAttributes = require("includes.data.enums.ped_combat_attributes"),
2320
ePedComponents = require("includes.data.enums.ped_components"),
2421
ePedConfigFlags = require("includes.data.enums.ped_config_flags"),
22+
ePedGender = require("includes.data.enums.ped_gender"),
2523
ePedResetFlags = require("includes.data.enums.ped_reset_flags"),
26-
ePedCombatAttributes = require("includes.data.enums.ped_combat_attributes"),
2724
ePedTaskIndex = require("includes.data.enums.ped_task_index"),
28-
eAnimFlags = require("includes.data.enums.anim_flags"),
29-
eActionType = require("includes.data.enums.action_type"),
25+
ePedType = require("includes.data.enums.ped_type"),
26+
eRagdollBlockingFlags = require("includes.data.enums.ragdoll_blocking_flags"),
27+
eVehicleAdvancedFlags = require("includes.data.enums.vehicle_advanced_flags"),
28+
eVehicleClasses = require("includes.data.enums.vehicle_classes"),
29+
eVehicleHandlingFlags = require("includes.data.enums.vehicle_handling_flags"),
30+
eVehicleModelFlags = require("includes.data.enums.vehicle_model_flags"),
31+
eVehicleModelInfoFlags = require("includes.data.enums.vehicle_model_info_flags"),
3032
eVehicleTask = require("includes.data.enums.vehicle_task"),
31-
eLandingGearState = require("includes.data.enums.landing_gear_state"),
3233
}
3334

3435
return Enums
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- Copyright (C) 2026 SAMURAI (xesdoog) & Contributors.
2+
-- This file is part of Samurai's Scripts.
3+
--
4+
-- Permission is hereby granted to copy, modify, and redistribute
5+
-- this code as long as you respect these conditions:
6+
-- * Credit the owner and contributors.
7+
-- * Provide a copy of or a link to the original license (GPL-3.0 or later); see LICENSE.md or <https://www.gnu.org/licenses/>.
8+
9+
10+
---@enum eGameLanguage
11+
local eGameLanguage <const> = {
12+
ENGLISH = 0,
13+
FRENCH = 1,
14+
GERMAN = 2,
15+
ITALIAN = 3,
16+
SPANISH = 4,
17+
PORTUGUESE_BRASIL = 5,
18+
POLISH = 6,
19+
RUSSIAN = 7,
20+
KOREAN = 8,
21+
CHINESE_TRADITIONAL = 9,
22+
JAPANESE = 10,
23+
SPANISH_MEXICAN = 11,
24+
CHINESE_SIMPLIFIED = 12,
25+
}
26+
27+
return eGameLanguage
File renamed without changes.

SSV2/includes/data/pointers.lua

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PatternScanner = require("includes.services.PatternScanner")
2121
--
2222
-- **NOTE:** Please make sure no modules/files try to use a pointer before the scan is complete.
2323
--
24-
-- You can call `PatternScanner:IsDone()` to double check.
24+
-- You can call `PatternScanner:IsDone()` to double check.-
2525
---@class GPointers
2626
---@field ScriptGlobals pointer
2727
---@field GameState pointer<byte>
@@ -66,12 +66,10 @@ local mem_batches <const> = {
6666
GPointers.ScriptGlobals = ptr:add(0x3):rip()
6767
end),
6868
MemoryBatch.new("GameVersion", "8B C3 33 D2 C6 44 24 20", function(ptr)
69-
local pGameBuild = ptr:add(0x24):rip()
70-
local pOnlineVersion = pGameBuild:add(0x20)
71-
GPointers.GameVersion = {
72-
build = pGameBuild:get_string(),
73-
online = pOnlineVersion:get_string()
74-
}
69+
local pGameBuild = ptr:add(0x24):rip()
70+
local pOnlineVersion = pGameBuild:add(0x20)
71+
GPointers.GameVersion.build = pGameBuild:get_string()
72+
GPointers.GameVersion.online = pOnlineVersion:get_string()
7573
end),
7674
MemoryBatch.new("GameState", "81 39 5D 6D FF AF 75 20", function(ptr)
7775
GPointers.GameState = ptr:add(0xA):rip():add(0x1)
@@ -80,10 +78,8 @@ local mem_batches <const> = {
8078
GPointers.GameTime = ptr:add(0x2):rip()
8179
end),
8280
MemoryBatch.new("ScreenResolution", "66 0F 6E 0D ? ? ? ? 0F B7 3D", function(ptr)
83-
GPointers.ScreenResolution = vec2:new(
84-
ptr:sub(0x4):rip():get_word(),
85-
ptr:add(0x4):rip():get_word()
86-
)
81+
GPointers.ScreenResolution.x = ptr:sub(0x4):rip():get_word()
82+
GPointers.ScreenResolution.y = ptr:add(0x4):rip():get_word()
8783
end),
8884

8985
-- TODO: enable once dynamic calls become stable. For now either the JIT compiler is broken or I'm just outright stupid.
@@ -103,19 +99,15 @@ local mem_batches <const> = {
10399
GPointers.ScriptGlobals = ptr:add(0x7):add(0x3):rip()
104100
end),
105101
MemoryBatch.new("GameVersion", "4C 8D 0D ? ? ? ? 48 8D 5C 24 ? 48 89 D9 48 89 FA", function(ptr)
106-
GPointers.GameVersion = {
107-
build = ptr:add(0x3):rip():get_string(),
108-
online = ptr:add(0x47):add(0x3):rip():get_string()
109-
}
102+
GPointers.GameVersion.build = ptr:add(0x3):rip():get_string()
103+
GPointers.GameVersion.online = ptr:add(0x47):add(0x3):rip():get_string()
110104
end),
111105
MemoryBatch.new("GameState", "83 3D ? ? ? ? ? 0F 85 ? ? ? ? BA ? 00", function(ptr)
112106
GPointers.GameState = ptr:add(0x2):rip():add(0x1)
113107
end),
114108
MemoryBatch.new("ScreenResolution", "75 39 0F 57 C0 F3 0F 2A 05", function(ptr)
115-
GPointers.ScreenResolution = vec2:new(
116-
ptr:add(0x5):add(0x4):rip():get_word(),
117-
ptr:add(0x1E):add(0x4):rip():get_word()
118-
)
109+
GPointers.ScreenResolution.x = ptr:add(0x5):add(0x4):rip():get_word()
110+
GPointers.ScreenResolution.y = ptr:add(0x1E):add(0x4):rip():get_word()
119111
end),
120112
},
121113
[Enums.eAPIVersion.L54] = { --[[dummy]] },

SSV2/includes/data/refs.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,19 @@ return {
252252
},
253253

254254
locales = {
255-
{ name = "English", id = 0, iso = "en-US" },
256-
{ name = "French", id = 1, iso = "fr-FR" },
257-
{ name = "German", id = 2, iso = "de-DE" },
258-
{ name = "Italian", id = 3, iso = "it-IT" },
259-
{ name = "Spanish, Spain", id = 4, iso = "es-ES" },
260-
{ name = "Portugese", id = 5, iso = "pt-BR" },
261-
{ name = "Polish", id = 6, iso = "pl-PL" },
262-
{ name = "Russian", id = 7, iso = "ru-RU" },
263-
{ name = "Korean", id = 8, iso = "ko-KR" },
264-
{ name = "Chinese Traditional", id = 9, iso = "zh-TW" },
265-
{ name = "Japanese", id = 10, iso = "ja-JP" },
266-
{ name = "Spanish, Mexico", id = 11, iso = "es-MX" },
267-
{ name = "Chinese Simplified", id = 12, iso = "zh-CN" },
255+
[0] = { name = "English", iso = "en-US" },
256+
[1] = { name = "French", iso = "fr-FR" },
257+
[2] = { name = "German", iso = "de-DE" },
258+
[3] = { name = "Italian", iso = "it-IT" },
259+
[4] = { name = "Spanish, Spain", iso = "es-ES" },
260+
[5] = { name = "Portugese", iso = "pt-BR" },
261+
[6] = { name = "Polish", iso = "pl-PL" },
262+
[7] = { name = "Russian", iso = "ru-RU" },
263+
[8] = { name = "Korean", iso = "ko-KR" },
264+
[9] = { name = "Chinese Traditional", iso = "zh-TW" },
265+
[10] = { name = "Japanese", iso = "ja-JP" },
266+
[11] = { name = "Spanish, Mexico", iso = "es-MX" },
267+
[12] = { name = "Chinese Simplified", iso = "zh-CN" },
268268
},
269269

270270
engineSwaps = {

SSV2/includes/features/EntityForge.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function EntityForge:init()
6262

6363
ThreadManager:RegisterLooped("SS_ENTITY_FORGE", function()
6464
if (not instance.EntityGunEnabled or not WEAPON.IS_PED_ARMED(LocalPlayer:GetHandle(), 4)) then
65+
yield()
6566
return
6667
end
6768

0 commit comments

Comments
 (0)