Skip to content

Commit 386b5bd

Browse files
committed
chore: tidy up for weekly release
- Fix formatting. - SGSL: Add caching by reference. - YimActions: Fix when actions are allowed to be added to history. - CI: Another attempt at fixing release workflow glob issue. STOP INCLUDING THE /dev FOLDER!
1 parent 3037eb2 commit 386b5bd

10 files changed

Lines changed: 205 additions & 190 deletions

File tree

.github/workflows/zip-release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ jobs:
172172
uses: thedoctor0/zip-release@0.7.6
173173
with:
174174
type: 'zip'
175-
filename: "Samurais_Scripts_${{ steps.increment_tag.outputs.version_number }}.zip"
176-
exclusions: /.git* /dev* /docs* **.json **.md **.editorconfig **.py **.txt *.ps1 .gitignore LICENSE
175+
path: './SSV2'
176+
filename: 'Samurais_Scripts_${{ steps.increment_tag.outputs.version_number }}.zip'
177+
exclusions: '**/*.json **/*.md **/*.editorconfig **/*.py **/*.txt **/*.ps1 **/*.gitignore'
177178

178179
- name: Upload Release
179180
if: steps.check_changes.outputs.should_proceed == 'true'

SSV2/includes/data/yrv3_data.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ local RawBusinessData <const> = {
130130
if (tunables.get_int("EXEC_SELL_COOLDOWN") > 0) then
131131
tunables.set_int("EXEC_SELL_COOLDOWN", 0)
132132
end
133-
if tunables.get_int("EXEC_SELL_FAIL_COOLDOWN") > 0 then
133+
if (tunables.get_int("EXEC_SELL_FAIL_COOLDOWN") > 0) then
134134
tunables.set_int("EXEC_SELL_FAIL_COOLDOWN", 0)
135135
end
136136
end

SSV2/includes/features/extra/yim_actions/YimActionsV3.lua

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,14 @@ function YimActions:InitInVehicleAnim(animData, targetPed)
202202
return true
203203
end
204204

205+
---@nodiscard
205206
---@param animData AnimData
206207
---@param targetPed? handle
208+
---@return boolean
207209
function YimActions:PlayAnim(animData, targetPed)
208210
targetPed = self:GetPed(targetPed)
209-
210211
if (animData.category == "In-Vehicle" and not self:InitInVehicleAnim(animData, targetPed)) then
211-
return
212+
return false
212213
end
213214

214215
TaskWait(Game.RequestAnimDict, animData.dict)
@@ -226,8 +227,6 @@ function YimActions:PlayAnim(animData, targetPed)
226227
false
227228
)
228229

229-
self:UpdatePlayHistory(targetPed)
230-
231230
if (not GVars.features.yim_actions.disable_props) then
232231
if (animData.props and #animData.props > 0) then
233232
self.m_prop_mgr:AttachProp(targetPed, animData.props)
@@ -244,29 +243,32 @@ function YimActions:PlayAnim(animData, targetPed)
244243

245244
local isLooped = Bit.IsBitSet(animData.flags, Enums.eAnimFlags.LOOPING)
246245
local isFrozen = Bit.IsBitSet(animData.flags, Enums.eAnimFlags.HOLD_LAST_FRAME)
247-
248246
if (not isLooped and not isFrozen) then
249-
repeat
250-
yield()
251-
until self:IsAnimDone(targetPed, animData)
252-
self.CurrentlyPlaying[targetPed] = nil
247+
ThreadManager:Run(function(s)
248+
while (not self:IsAnimDone(targetPed, animData)) do
249+
s:yield()
250+
end
251+
self.CurrentlyPlaying[targetPed] = nil
252+
end)
253253
end
254+
255+
return true
254256
end
255257

258+
---@nodiscard
256259
---@param scenarioData ScenarioData
257260
---@param targetPed? handle
258261
---@param playImmediately? boolean
262+
---@return boolean
259263
function YimActions:PlayScenario(scenarioData, targetPed, playImmediately)
260264
targetPed = self:GetPed(targetPed)
261-
262-
if scenarioData.label == "Cook On BBQ" then
265+
if (scenarioData.label == "Cook On BBQ") then
263266
local offsetCoords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(
264267
targetPed,
265268
0.0,
266269
1.0,
267270
0.0
268271
)
269-
270272
local bbq = self.m_prop_mgr:SpawnProp(
271273
targetPed,
272274
{ model = 286252949 },
@@ -276,13 +278,12 @@ function YimActions:PlayScenario(scenarioData, targetPed, playImmediately)
276278
true,
277279
true
278280
)
279-
280-
if bbq and bbq ~= 0 then
281+
if (bbq and bbq ~= 0) then
281282
ENTITY.SET_ENTITY_HEADING(bbq, Game.GetHeading(bbq) - 180)
282283
end
283284
end
284285

285-
if self:IsPedPlaying(targetPed) then
286+
if (self:IsPedPlaying(targetPed)) then
286287
TASK.CLEAR_PED_TASKS_IMMEDIATELY(targetPed) -- avoid scenario exit anims if we start a scenario while already playing one
287288
end
288289

@@ -292,11 +293,16 @@ function YimActions:PlayScenario(scenarioData, targetPed, playImmediately)
292293
-1,
293294
not playImmediately
294295
)
296+
297+
return true
295298
end
296299

300+
---@nodiscard
297301
---@param data SyncedSceneData
302+
---@return boolean
298303
function YimActions:PlaySyncedScene(data)
299304
self.m_scene_mgr:Play(data)
305+
return true
300306
end
301307

302308
---@param action? Action
@@ -320,22 +326,23 @@ function YimActions:Play(action, ped)
320326
TaskWait(function() return self.CurrentlyPlaying[ped] == nil end)
321327

322328
self.CurrentlyPlaying[ped] = action
329+
local success = false
323330

331+
---@diagnostic disable: param-type-mismatch
324332
if (action.action_type == Enums.eActionType.SCENARIO) then
325-
---@diagnostic disable-next-line
326-
self:PlayScenario(action.data, ped)
333+
success = self:PlayScenario(action.data, ped)
327334
elseif action.action_type == Enums.eActionType.ANIM then
328-
---@diagnostic disable-next-line
329-
self:PlayAnim(action.data, ped)
335+
success = self:PlayAnim(action.data, ped)
330336
elseif action.action_type == Enums.eActionType.SCENE then
331-
---@diagnostic disable-next-line
332-
self:PlaySyncedScene(action.data)
337+
success = self:PlaySyncedScene(action.data)
333338
end
339+
---@diagnostic enable: param-type-mismatch
334340

335-
self:UpdatePlayHistory(ped)
336-
337-
if (Backend.debug_mode) then
338-
self.Debugger:Update(ped)
341+
if (success) then
342+
self:UpdatePlayHistory(ped)
343+
if (Backend.debug_mode) then
344+
self.Debugger:Update(ped)
345+
end
339346
end
340347
end
341348

SSV2/includes/features/online/CasinoPacino.lua

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,29 +190,24 @@ function CasinoPacino:SetPokerCards(player_id, players_current_table, card_one,
190190
local three_card_poker_deck_size = SGSL:Get(SGSL.data.three_card_poker_deck_size):GetValue()
191191
local three_card_poker_anti_cheat = tcp_ac_obj:GetValue()
192192
local three_card_poker_anti_cheat_deck = tcp_ac_obj:GetOffset(1)
193-
194-
195-
local TCPCards = ScriptLocal(three_card_poker_cards, "three_card_poker")
193+
local TCPCards = ScriptLocal(three_card_poker_cards, "three_card_poker")
196194
:At(three_card_poker_current_deck)
197195
:At(1)
198196
:At(players_current_table * three_card_poker_deck_size)
199197
:At(2)
200198

201-
local TCPAC = ScriptLocal(three_card_poker_anti_cheat, "three_card_poker")
199+
local TCPAC = ScriptLocal(three_card_poker_anti_cheat, "three_card_poker")
202200
:At(three_card_poker_anti_cheat_deck)
203201
:At(1)
204202
:At(1)
205203
:At(players_current_table * three_card_poker_deck_size)
206204

207205

208-
TCPCards:At(1):At(player_id * 3):WriteInt(card_one)
209-
TCPAC:At(1):At(player_id * 3):WriteInt(card_one)
210-
211-
TCPCards:At(2):At(player_id * 3):WriteInt(card_two)
212-
TCPAC:At(2):At(player_id * 3):WriteInt(card_two)
213-
214-
TCPCards:At(3):At(player_id * 3):WriteInt(card_three)
215-
TCPAC:At(3):At(player_id * 3):WriteInt(card_three)
206+
local base = player_id * 3
207+
for i, card in ipairs({ card_one, card_two, card_three }) do
208+
TCPCards:At(i):At(base):WriteInt(card)
209+
TCPAC:At(i):At(base):WriteInt(card)
210+
end
216211
end
217212

218213
function CasinoPacino:ForcePokerCards()
@@ -283,7 +278,6 @@ function CasinoPacino:ForceRouletteWheel()
283278
local roulette_master_table = rmt_obj:GetValue()
284279
local roulette_outcomes_table = rmt_obj:GetOffset(1)
285280
local roulette_ball_table = SGSL:Get(SGSL.data.roulette_ball_table_offset):GetValue()
286-
287281
for table_iter = 0, 6, 1 do
288282
locals.set_int(
289283
"casinoroulette",

SSV2/includes/features/online/yim_resupplier/YimResupplierV3.lua

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -885,25 +885,25 @@ function YRV3:CooldownHandler()
885885
end
886886
end
887887

888-
local fadedOutTimer = Timer.new(1e4)
889-
fadedOutTimer:Pause()
888+
---@return boolean isRunning, string? scriptName, string displayName
889+
function YRV3:FindRunningSaleScript()
890+
for sn in pairs(self.m_raw_data.SellScripts) do
891+
if (script.is_active(sn)) then
892+
return true, sn, ScriptDisplayNames[sn] or "None"
893+
end
894+
end
895+
896+
return false, nil, "None"
897+
end
898+
890899
function YRV3:SetupAutosell()
891900
if (Time.Millis() - self.m_last_autosell_check_time < 1200) then
892901
return
893902
end
894903

895-
for sn in pairs(self.m_raw_data.SellScripts) do
896-
if script.is_active(sn) then
897-
self.m_sell_script_name = sn
898-
self.m_sell_script_running = true
899-
self.m_sell_script_disp_name = self:GetRunningSellScriptDisplayName()
900-
break
901-
else
902-
self.m_sell_script_name = "None"
903-
self.m_sell_script_disp_name = "None"
904-
self.m_sell_script_running = false
905-
end
906-
end
904+
self.m_sell_script_running,
905+
self.m_sell_script_name,
906+
self.m_sell_script_disp_name = self:FindRunningSaleScript()
907907

908908
if (self.m_sell_script_running and self.m_bhub_script_handle ~= 0) then -- was triggered from the mct
909909
for _, scr in pairs(ScriptsToTerminate) do
@@ -916,9 +916,8 @@ function YRV3:SetupAutosell()
916916
end
917917

918918
sleep(1000)
919-
920919
if (CAM.IS_SCREEN_FADING_OUT() or CAM.IS_SCREEN_FADED_OUT()) then
921-
fadedOutTimer:Resume()
920+
local fadedOutTimer = Timer.new(1e4)
922921
while (not fadedOutTimer:IsDone()) do
923922
if (not CAM.IS_SCREEN_FADED_OUT() or CAM.IS_SCREEN_FADING_IN()) then
924923
break
@@ -932,9 +931,6 @@ function YRV3:SetupAutosell()
932931
CAM.DO_SCREEN_FADE_IN(100)
933932
end
934933
end
935-
936-
fadedOutTimer:Reset()
937-
fadedOutTimer:Pause()
938934
end
939935

940936
self.m_last_autosell_check_time = Time.Millis()

0 commit comments

Comments
 (0)