Skip to content

Commit

Permalink
performance tweak for last commit
Browse files Browse the repository at this point in the history
performance tweak for last commit
  • Loading branch information
ddraigcymraeg committed Jan 20, 2023
1 parent a64b023 commit 146b146
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions mrp-missions-v3/client.lua
Expand Up @@ -8522,6 +8522,41 @@ AddEventHandler('SpawnPed', function(input)
aliveCheck()
end)


function FoundIamSpawner()

local pid = 0

--For one sync legacy find if I am the greatest playerid, is so, I am the spawner
--experimental.
if Config.UsingOneSync then
for _, i in ipairs(GetActivePlayers()) do
if NetworkIsPlayerActive(i) then
pid = i
end
end
if PlayerId() == pid then
--print("PlayerId found:"..PlayerId())
return true
else
return false
--print("PlayerId not found:"..PlayerId())
end

else
--onesync legacy turned off, default beahvior.
if NetworkIsHost() then
return true

else
return false
end

end


end

--FOR: Config.Missions[MissionName].IndoorsMission=true
--spawn NPCs nearby (30m) as players progress, to stop invisible peds showing up
--used with SpawnAPed, which is derived from the default SpawnPed event
Expand All @@ -8532,34 +8567,6 @@ Citizen.CreateThread(function()
--print("PlayerId:"..PlayerId())



local pid = 0
local foundIamspawner = false

--For one sync legacy find if I am the greatest playerid, is so, I am the spawner
--experimental.
if Config.UsingOneSync then
for _, i in ipairs(GetActivePlayers()) do
if NetworkIsPlayerActive(i) then
pid = i
end
end

if PlayerId() == pid then
--print("PlayerId found:"..PlayerId())
foundIamspawner = true
else
--print("PlayerId not found:"..PlayerId())
end

else
--onesync legacy turned off, default beahvior.
if NetworkIsHost() then
foundIamspawner = true
end

end

--[[
local players = GetPlayers()
local pid2 = 0;
Expand All @@ -8583,7 +8590,7 @@ Citizen.CreateThread(function()
else
--allow for 'outside' peds to spawn right away, but let host do that

if(Config.Missions[MissionName].Peds[i].outside and foundIamspawner) then
if(Config.Missions[MissionName].Peds[i].outside and FoundIamSpawner()) then
--print("spawn outside ped"..i)

SpawnAPed(MissionName,i,false)
Expand Down Expand Up @@ -8630,7 +8637,7 @@ Citizen.CreateThread(function()
else

--allow for 'outside' vehicles to spawn right away, but let host do that
if(Config.Missions[MissionName].Vehicles[i].outside and foundIamspawner) then
if(Config.Missions[MissionName].Vehicles[i].outside and FoundIamSpawner()) then
--print("spawn outside vehicle"..i)

SpawnAPed(MissionName,i,true)
Expand Down

0 comments on commit 146b146

Please sign in to comment.