mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 00:16:27 +02:00
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:
20
cl_sync.lua
20
cl_sync.lua
@@ -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 )
|
||||
Reference in New Issue
Block a user