Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions SSV2/includes/backend.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ local Backend = {

---@type table<eEntityType, integer>
MaxAllowedEntities = {
[Enums.eEntityType.Ped] = 50,
[Enums.eEntityType.Vehicle] = 25,
[Enums.eEntityType.Object] = 75,
[Enums.eEntityType.Ped] = 25,
[Enums.eEntityType.Vehicle] = 15,
[Enums.eEntityType.Object] = 35,
},
}
Backend.__index = Backend
Expand Down Expand Up @@ -456,7 +456,6 @@ function Backend:OnPlayerSwitch()
end

self.is_in_player_transition = true

ThreadManager:Run(function()
self:TriggerEventCallbacks(Enums.eBackendEvent.PLAYER_SWITCH)

Expand All @@ -469,36 +468,39 @@ function Backend:OnPlayerSwitch()
end

function Backend:RegisterHandlers()
self.debug_mode = self:IsMockEnv() or GVars.backend.debug_mode or false
local mockEnv = self:IsMockEnv()
self.debug_mode = mockEnv or GVars.backend.debug_mode or false

if (self:IsMockEnv()) then
return
end
if (mockEnv) then return end

ThreadManager:RegisterLooped("SS_CTRLS", function()
if (self.disable_input) then
PAD.DISABLE_ALL_CONTROL_ACTIONS(0)
end

if ((gui.is_open() or GUI:IsOpen()) and not self.disable_input) then
self:DisableAttackInput()
end
else
if ((gui.is_open() or GUI:IsOpen())) then
self:DisableAttackInput()
end

for _, control in pairs(self.ControlsToDisable) do
PAD.DISABLE_CONTROL_ACTION(0, control, true)
for _, control in pairs(self.ControlsToDisable) do
PAD.DISABLE_CONTROL_ACTION(0, control, true)
end
end
end)

ThreadManager:RegisterLooped("SS_BACKEND", function()
self:OnPlayerSwitch()
self:OnSessionSwitch()

PreviewService:Update()
Decorator:CollectGarbage()
Translator:OnTick()

yield()
end)

ThreadManager:RegisterLooped("SS_POOLMGR", function()
self:PoolMgr()
yield()
end)

event.register_handler(menu_event.MenuUnloaded, function() self:Cleanup() end)
Expand Down
7 changes: 4 additions & 3 deletions SSV2/includes/classes/Mutex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
--------------------------------------
-- Class: Mutex
--------------------------------------
-- Simple mutual exclusion.
-- Simple mutual exclusivity.
---@class Mutex
---@field protected m_locked boolean
---@overload fun(): Mutex
Expand Down Expand Up @@ -42,9 +42,10 @@ function Mutex:Release()
end

-- Scoped lock.
---@param func function
---@generic R1, R2, R3, R4, R5
---@param func fun(...?: any): R1?, R2?, R3?, R4?, R5?, ...?
---@param ... any
---@return ...
---@return boolean success, R1?, R2?, R3?, R4?, R5?, ...?
function Mutex:WithLock(func, ...)
self:Acquire()
local ret = { xpcall(func, function(msg)
Expand Down
8 changes: 4 additions & 4 deletions SSV2/includes/classes/gta/CPed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local CPlayerInfo = require("includes.classes.gta.CPlayerInfo")
---@field m_ped_weapon_mgr pointer_ref<CPedWeaponManager>
---@field m_player_info CPlayerInfo
---@field m_velocity pointer<vec3>
---@field m_ped_type pointer<uint8_t>
---@field m_ped_type pointer<uint32_t>
---@field m_ped_task_flag pointer<uint8_t>
---@field m_seatbelt pointer<uint8_t>
---@field m_armor pointer<float>
Expand Down Expand Up @@ -64,14 +64,14 @@ end
---@return boolean
function CPed:CanRagdoll()
return self:__safecall(false, function()
return (self.m_ped_type & 0x20) ~= 0
return (self.m_ped_type:get_dword() & 0x20) ~= 0
end)
end

---@return boolean
function CPed:HasSeatbelt()
return self:__safecall(false, function()
return (self.m_seatbelt & 0x3) ~= 0
return (self.m_seatbelt:get_byte() & 0x3) ~= 0
end)
end

Expand All @@ -85,7 +85,7 @@ end
---@return ePedType
function CPed:GetPedType()
return self:__safecall(-1, function()
return (self.m_ped_type:get_word() << 11 >> 25)
return (self.m_ped_type:get_dword() << 11 >> 25)
end)
end

Expand Down
3 changes: 2 additions & 1 deletion SSV2/includes/data/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ local Config <const> = {
auto_cleanup_entities = false,
language_index = 1,
language_code = "en-US",
language_name = "English"
language_name = "English",
use_game_language = false
},
ui = {
disable_tooltips = false,
Expand Down
29 changes: 15 additions & 14 deletions SSV2/includes/data/enums/__init__.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@


local Enums <const> = {
eActionType = require("includes.data.enums.action_type"),
eAnimFlags = require("includes.data.enums.anim_flags"),
eDrivingFlags = require("includes.data.enums.driving_flags"),
eGameState = require("includes.data.enums.game_state"),
eModelType = require("includes.data.enums.model_type"),
eRagdollBlockingFlags = require("includes.data.enums.ragdoll_blocking_flags"),
eVehicleClasses = require("includes.data.enums.vehicle_classes"),
eGameLanguage = require("includes.data.enums.game_language"),
eHandlingType = require("includes.data.enums.handling_type"),
eDrivingFlags = require("includes.data.enums.driving_flags"),
eVehicleHandlingFlags = require("includes.data.enums.handling_flags"),
eVehicleModelFlags = require("includes.data.enums.vehicle_model_flags"),
eVehicleModelInfoFlags = require("includes.data.enums.vehicle_model_info_flags"),
eVehicleAdvancedFlags = require("includes.data.enums.vehicle_advanced_flags"),
ePedType = require("includes.data.enums.ped_type"),
ePedGender = require("includes.data.enums.ped_gender"),
eLandingGearState = require("includes.data.enums.landing_gear_state"),
eModelType = require("includes.data.enums.model_type"),
ePedCombatAttributes = require("includes.data.enums.ped_combat_attributes"),
ePedComponents = require("includes.data.enums.ped_components"),
ePedConfigFlags = require("includes.data.enums.ped_config_flags"),
ePedGender = require("includes.data.enums.ped_gender"),
ePedResetFlags = require("includes.data.enums.ped_reset_flags"),
ePedCombatAttributes = require("includes.data.enums.ped_combat_attributes"),
ePedTaskIndex = require("includes.data.enums.ped_task_index"),
eAnimFlags = require("includes.data.enums.anim_flags"),
eActionType = require("includes.data.enums.action_type"),
ePedType = require("includes.data.enums.ped_type"),
eRagdollBlockingFlags = require("includes.data.enums.ragdoll_blocking_flags"),
eVehicleAdvancedFlags = require("includes.data.enums.vehicle_advanced_flags"),
eVehicleClasses = require("includes.data.enums.vehicle_classes"),
eVehicleHandlingFlags = require("includes.data.enums.vehicle_handling_flags"),
eVehicleModelFlags = require("includes.data.enums.vehicle_model_flags"),
eVehicleModelInfoFlags = require("includes.data.enums.vehicle_model_info_flags"),
eVehicleTask = require("includes.data.enums.vehicle_task"),
eLandingGearState = require("includes.data.enums.landing_gear_state"),
}

return Enums
27 changes: 27 additions & 0 deletions SSV2/includes/data/enums/game_language.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- Copyright (C) 2026 SAMURAI (xesdoog) & Contributors.
-- This file is part of Samurai's Scripts.
--
-- Permission is hereby granted to copy, modify, and redistribute
-- this code as long as you respect these conditions:
-- * Credit the owner and contributors.
-- * 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/>.


---@enum eGameLanguage
local eGameLanguage <const> = {
ENGLISH = 0,
FRENCH = 1,
GERMAN = 2,
ITALIAN = 3,
SPANISH = 4,
PORTUGUESE_BRASIL = 5,
POLISH = 6,
RUSSIAN = 7,
KOREAN = 8,
CHINESE_TRADITIONAL = 9,
JAPANESE = 10,
SPANISH_MEXICAN = 11,
CHINESE_SIMPLIFIED = 12,
}

return eGameLanguage
30 changes: 11 additions & 19 deletions SSV2/includes/data/pointers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PatternScanner = require("includes.services.PatternScanner")
--
-- **NOTE:** Please make sure no modules/files try to use a pointer before the scan is complete.
--
-- You can call `PatternScanner:IsDone()` to double check.
-- You can call `PatternScanner:IsDone()` to double check.-
---@class GPointers
---@field ScriptGlobals pointer
---@field GameState pointer<byte>
Expand Down Expand Up @@ -66,12 +66,10 @@ local mem_batches <const> = {
GPointers.ScriptGlobals = ptr:add(0x3):rip()
end),
MemoryBatch.new("GameVersion", "8B C3 33 D2 C6 44 24 20", function(ptr)
local pGameBuild = ptr:add(0x24):rip()
local pOnlineVersion = pGameBuild:add(0x20)
GPointers.GameVersion = {
build = pGameBuild:get_string(),
online = pOnlineVersion:get_string()
}
local pGameBuild = ptr:add(0x24):rip()
local pOnlineVersion = pGameBuild:add(0x20)
GPointers.GameVersion.build = pGameBuild:get_string()
GPointers.GameVersion.online = pOnlineVersion:get_string()
end),
MemoryBatch.new("GameState", "81 39 5D 6D FF AF 75 20", function(ptr)
GPointers.GameState = ptr:add(0xA):rip():add(0x1)
Expand All @@ -80,10 +78,8 @@ local mem_batches <const> = {
GPointers.GameTime = ptr:add(0x2):rip()
end),
MemoryBatch.new("ScreenResolution", "66 0F 6E 0D ? ? ? ? 0F B7 3D", function(ptr)
GPointers.ScreenResolution = vec2:new(
ptr:sub(0x4):rip():get_word(),
ptr:add(0x4):rip():get_word()
)
GPointers.ScreenResolution.x = ptr:sub(0x4):rip():get_word()
GPointers.ScreenResolution.y = ptr:add(0x4):rip():get_word()
end),

-- TODO: enable once dynamic calls become stable. For now either the JIT compiler is broken or I'm just outright stupid.
Expand All @@ -103,19 +99,15 @@ local mem_batches <const> = {
GPointers.ScriptGlobals = ptr:add(0x7):add(0x3):rip()
end),
MemoryBatch.new("GameVersion", "4C 8D 0D ? ? ? ? 48 8D 5C 24 ? 48 89 D9 48 89 FA", function(ptr)
GPointers.GameVersion = {
build = ptr:add(0x3):rip():get_string(),
online = ptr:add(0x47):add(0x3):rip():get_string()
}
GPointers.GameVersion.build = ptr:add(0x3):rip():get_string()
GPointers.GameVersion.online = ptr:add(0x47):add(0x3):rip():get_string()
end),
MemoryBatch.new("GameState", "83 3D ? ? ? ? ? 0F 85 ? ? ? ? BA ? 00", function(ptr)
GPointers.GameState = ptr:add(0x2):rip():add(0x1)
end),
MemoryBatch.new("ScreenResolution", "75 39 0F 57 C0 F3 0F 2A 05", function(ptr)
GPointers.ScreenResolution = vec2:new(
ptr:add(0x5):add(0x4):rip():get_word(),
ptr:add(0x1E):add(0x4):rip():get_word()
)
GPointers.ScreenResolution.x = ptr:add(0x5):add(0x4):rip():get_word()
GPointers.ScreenResolution.y = ptr:add(0x1E):add(0x4):rip():get_word()
end),
},
[Enums.eAPIVersion.L54] = { --[[dummy]] },
Expand Down
26 changes: 13 additions & 13 deletions SSV2/includes/data/refs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,19 @@ return {
},

locales = {
{ name = "English", id = 0, iso = "en-US" },
{ name = "French", id = 1, iso = "fr-FR" },
{ name = "German", id = 2, iso = "de-DE" },
{ name = "Italian", id = 3, iso = "it-IT" },
{ name = "Spanish, Spain", id = 4, iso = "es-ES" },
{ name = "Portugese", id = 5, iso = "pt-BR" },
{ name = "Polish", id = 6, iso = "pl-PL" },
{ name = "Russian", id = 7, iso = "ru-RU" },
{ name = "Korean", id = 8, iso = "ko-KR" },
{ name = "Chinese Traditional", id = 9, iso = "zh-TW" },
{ name = "Japanese", id = 10, iso = "ja-JP" },
{ name = "Spanish, Mexico", id = 11, iso = "es-MX" },
{ name = "Chinese Simplified", id = 12, iso = "zh-CN" },
[0] = { name = "English", iso = "en-US" },
[1] = { name = "French", iso = "fr-FR" },
[2] = { name = "German", iso = "de-DE" },
[3] = { name = "Italian", iso = "it-IT" },
[4] = { name = "Spanish, Spain", iso = "es-ES" },
[5] = { name = "Portugese", iso = "pt-BR" },
[6] = { name = "Polish", iso = "pl-PL" },
[7] = { name = "Russian", iso = "ru-RU" },
[8] = { name = "Korean", iso = "ko-KR" },
[9] = { name = "Chinese Traditional", iso = "zh-TW" },
[10] = { name = "Japanese", iso = "ja-JP" },
[11] = { name = "Spanish, Mexico", iso = "es-MX" },
[12] = { name = "Chinese Simplified", iso = "zh-CN" },
},

engineSwaps = {
Expand Down
1 change: 1 addition & 0 deletions SSV2/includes/features/EntityForge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function EntityForge:init()

ThreadManager:RegisterLooped("SS_ENTITY_FORGE", function()
if (not instance.EntityGunEnabled or not WEAPON.IS_PED_ARMED(LocalPlayer:GetHandle(), 4)) then
yield()
return
end

Expand Down
5 changes: 4 additions & 1 deletion SSV2/includes/features/YimActionsV3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ function YimActions:IsPlayerBusy()
or LocalPlayer:IsRagdoll()
or Game.IsInNetworkTransition()
or Backend:IsPlayerSwitchInProgress()
or Backend:AreControlsDisabled()
end

---@param ped? integer
Expand Down Expand Up @@ -631,6 +630,10 @@ function YimActions:GoofyUnaliveAnim()
end

function YimActions:OnKeyDown()
if (Backend:AreControlsDisabled()) then
return
end

if (KeyManager:IsKeybindJustPressed("stop_anim")) then
ThreadManager:Run(function()
local timer = Timer.new(1000)
Expand Down
5 changes: 3 additions & 2 deletions SSV2/includes/features/vehicle/flappy_doors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
-- * 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/>.


local FeatureBase = require("includes.modules.FeatureBase")
local FeatureBase = require("includes.modules.FeatureBase")
local StateMachine = require("includes.structs.StateMachine")


---@class FlappyDoors : FeatureBase
---@field private m_entity PlayerVehicle
---@field private m_is_active boolean
---@field private m_state_machine StateMachine
local FlappyDoors = setmetatable({}, FeatureBase)
local FlappyDoors = setmetatable({}, FeatureBase)
FlappyDoors.__index = FlappyDoors

---@param pv PlayerVehicle
Expand Down
2 changes: 1 addition & 1 deletion SSV2/includes/features/vehicle/misc_vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function MiscVehicle:UpdateMachineGuns()
return
end

if (not LocalPlayer:IsUsingAirctaftMG()) then
if (not LocalPlayer:IsUsingAircraftMG()) then
return
end

Expand Down
7 changes: 2 additions & 5 deletions SSV2/includes/frontend/self/self_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ local playerAbilitiesWindow = {

local function CheckIfRagdollBlocked()
ThreadManager:Run(function()
if (LocalPlayer:IsOnFoot() and not PED.CAN_PED_RAGDOLL(LocalPlayer:GetHandle())) then
Notifier:ShowWarning(
"Samurais Scripts",
_T("SELF_RAGDOLL_BLOCK_INFO")
)
if (LocalPlayer:IsOnFoot() and not LocalPlayer:IsRagdoll() and not LocalPlayer:CanRagdoll()) then
Notifier:ShowWarning("Samurais Scripts", _T("SELF_RAGDOLL_BLOCK_INFO"))
end
end)
end
Expand Down
Loading