Skip to content

Commit

Permalink
fix(menu/playermode): fixes ptfx on all players (closes #559)
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Feb 18, 2022
1 parent 6b6a888 commit a1516a3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions scripts/menu/client/cl_player_mode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ local PTFX_DURATION = 1000
-- Applies the particle effect to a ped
local function createPlayerModePtfxLoop(tgtPedId)
CreateThread(function()
if tgtPedId <= 0 or tgtPedId == nil then return end
RequestNamedPtfxAsset(PTFX_DICT)
local playerPed = tgtPedId or PlayerPedId()

-- Wait until it's done loading.
while not HasNamedPtfxAssetLoaded(PTFX_DICT) do
Expand All @@ -103,7 +103,7 @@ local function createPlayerModePtfxLoop(tgtPedId)

for i=0, LOOP_AMOUNT do
UseParticleFxAssetNextCall(PTFX_DICT)
local partiResult = StartParticleFxLoopedOnEntity(PTFX_ASSET, playerPed, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, false, false, false)
local partiResult = StartParticleFxLoopedOnEntity(PTFX_ASSET, tgtPedId, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, false, false, false)
particleTbl[#particleTbl + 1] = partiResult
Wait(0)
end
Expand All @@ -118,9 +118,8 @@ end
RegisterNetEvent('txcl:syncPtfxEffect', function(tgtSrc)
debugPrint('Syncing particle effect for target netId')
local tgtPlayer = GetPlayerFromServerId(tgtSrc)
local tgtPlayerPed = GetPlayerPed(tgtPlayer)
if tgtSrc == 0 then return end
createPlayerModePtfxLoop(tgtPlayerPed)
if tgtPlayer == -1 then return end
createPlayerModePtfxLoop(GetPlayerPed(tgtPlayer))
end)

-- Ask server for playermode change and sends nearby playerlist
Expand Down Expand Up @@ -155,7 +154,7 @@ end)
-- [[ Player mode changed cb event ]]
RegisterNetEvent('txAdmin:menu:playerModeChanged', function(mode, ptfx)
if ptfx then
createPlayerModePtfxLoop()
createPlayerModePtfxLoop(PlayerPedId())
end

if mode == 'godmode' then
Expand Down

0 comments on commit a1516a3

Please sign in to comment.