feat: power button sync and passenger control

The power state is now synced between the driver and passenger. The passenger can also toggle the radar's power if the config line allows for it.
This commit is contained in:
Dan
2021-02-26 15:42:17 +00:00
parent 92d3ae8132
commit 3fd458ac63
3 changed files with 28 additions and 4 deletions

View File

@@ -32,3 +32,23 @@
SYNC = {}
function SYNC:SendPowerState( state )
local otherPed = PLY:GetOtherPed()
local otherPly = GetPlayerServerId( NetworkGetPlayerIndexFromPed( otherPed ) )
TriggerServerEvent( "wk_wars2x_sync:sendPowerState", otherPly, state )
end
RegisterNetEvent( "wk_wars2x_sync:receivePowerState" )
AddEventHandler( "wk_wars2x_sync:receivePowerState", function( state )
local power = RADAR:IsPowerOn()
if ( power ~= state ) then
Citizen.SetTimeout( 100, function()
RADAR:TogglePower()
end )
end
end )