xTeRusX
Wiek: 26 Na forum: 2143 dni Posty: 5
Nick w MP: xTeRusX
--[[
--]]
-- 482
local strobo_interval = 10
local is_strobo_enabled = enable
local flash_interval = 1
local blink_interval = 20
local blink_duration = 2
local car_lights_table = {
[ 459 ] = {[ "mode" ]= "lamp" , -- Burrito
[ 7 ]={[ "pos" ]={- 0.6 , 0.9 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.15 , [ "phase" ]=- 30 },
[ 8 ]={[ "pos" ]={ 0.6 , 0.9 , 0.95 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 30 },
[ 9 ]={[ "pos" ]={- 0.4 , 0.9 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.15 , [ "phase" ]=- 30 },
[ 10 ]={[ "pos" ]={ 0.4 , 0.9 , 0.95 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 30 },
[ 11 ]={[ "pos" ]={ 0.65 , - 2.245 , 0.93 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]=- 15 },
[ 12 ]={[ "pos" ]={- 0.65 , - 2.245 , 0.93 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 15 },
},
[ 596 ] = {[ "mode" ]= "lamp" , -- policeLS
[ 1 ]={[ "pos" ]={ 0.5 , - 0.4 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 2 ]={[ "pos" ]={ 0.6 , - 0.4 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 3 ]={[ "pos" ]={ 0.7 , - 0.4 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 3 ]={[ "pos" ]={ 0.4 , - 0.4 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 4 ]={[ "pos" ]={ 0.3 , - 0.4 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 5 ]={[ "pos" ]={ 0.27 , - 0.4 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 6 ]={[ "pos" ]={- 0.5 , - 0.4 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]=- 25 },
[ 7 ]={[ "pos" ]={- 0.6 , - 0.4 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]=- 25 },
[ 8 ]={[ "pos" ]={- 0.7 , - 0.4 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]=- 25 },
[ 9 ]={[ "pos" ]={- 0.4 , - 0.4 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]=- 25 },
[ 10 ]={[ "pos" ]={- 0.3 , - 0.4 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]=- 25 },
[ 11 ]={[ "pos" ]={- 0.27 , - 0.4 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]=- 25 },
},
[ 516 ] = {[ "mode" ]= "lamp" , -- NEBULA ( DODGE )
[ 1 ]={[ "pos" ]={ 0.3 , 2.58 , - 0.07 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 10 },
[ 2 ]={[ "pos" ]={- 0.3 , 2.58 , - 0.07 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 7 ]={[ "pos" ]={ 0.1 , 2.58 , - 0.07 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.17 , [ "phase" ]= 10 },
[ 8 ]={[ "pos" ]={- 0.1 , 2.58 , - 0.07 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 3 ]={[ "pos" ]={ 0.5 , - 1.8 , 0.5 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.18 , [ "phase" ]= 10 },
[ 4 ]={[ "pos" ]={- 0.5 , - 1.8 , 0.5 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.18 , [ "phase" ]= 1 },
[ 5 ]={[ "pos" ]={ 0.5 , 0.35 , 0.7 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.25 , [ "phase" ]= 5 },
[ 6 ]={[ "pos" ]={- 0.5 , 0.35 , 0.7 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 50 },
},
[ 560 ] = {[ "mode" ]= "lamp" , -- SULTAN
[ 1 ]={[ "pos" ]={ 0.5 , 0.25 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
},
[ 415 ] = {[ "mode" ]= "lamp" , -- Cheetah
[ 1 ]={[ "pos" ]={ 0.55 , 0.15 , 0.3 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.18 , [ "phase" ]= 30 },
[ 2 ]={[ "pos" ]={- 0.55 , 0.15 , 0.3 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.18 , [ "phase" ]= 20 },
[ 3 ]={[ "pos" ]={ 0.79 , - 2.3 , 0.0 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.20 , [ "phase" ]= 50 },
[ 4 ]={[ "pos" ]={- 0.83 , - 2.3 , 0. }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.20 , [ "phase" ]= 40 },
[ 5 ]={[ "pos" ]={ 0.25 , 2.8 ,- 0.4 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.20 , [ "phase" ]= 80 },
[ 6 ]={[ "pos" ]={- 0.25 , 2.8 ,- 0.4 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.20 , [ "phase" ]= 50 },
[ 7 ]={[ "pos" ]={ 0.110 , 2.8 ,- 0.4 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.20 , [ "phase" ]= 50 },
[ 8 ]={[ "pos" ]={- 0.10 , 2.8 ,- 0.4 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.20 , [ "phase" ]= 80 },
},
[ 578 ] = {[ "mode" ]= "lamp" ,
[ 1 ]={[ "pos" ]={- 1.2 , 4.4 , - 0.2 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 2 ]={[ "pos" ]={ 1.2 , 4.4 , - 0.2 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 3 ]={[ "pos" ]={- 1.2 , 4.4 , - 0.2 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 4 ]={[ "pos" ]={ 1.2 , 4.4 , - 0.2 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 5 ]={[ "pos" ]={ 1.2 , - 5.4 , - 0.5 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 6 ]={[ "pos" ]={- 1.2 , - 5.4 , - 0.5 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 7 ]={[ "pos" ]={ 1.2 , - 5.4 , - 0.5 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 8 ]={[ "pos" ]={- 1.2 , - 5.4 , - 0.5 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 15 },
[ 9 ]={[ "pos" ]={- 1.4 , 0.5 , - 0.8 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 25 },
[ 10 ]={[ "pos" ]={- 1.4 , - 0.8 , - 0.8 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.35 , [ "phase" ]= 25 },
[ 11 ]={[ "pos" ]={- 1.4 , - 2.2 , - 0.8 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.35 , [ "phase" ]= 25 },
[ 12 ]={[ "pos" ]={ 1.4 , 0.5 , - 0.8 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.35 , [ "phase" ]= 25 },
[ 13 ]={[ "pos" ]={ 1.4 , - 0.8 , - 0.8 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.35 , [ "phase" ]= 25 },
[ 14 ]={[ "pos" ]={ 1.4 , - 2.2 , - 0.8 }, [ "color" ]={ 255 , 90 , 0 }, [ "size" ]= 0.35 , [ "phase" ]= 25 },
},
[ 470 ] = {[ "mode" ]= "lamp" , -- PATRIOT
[ 1 ]={[ "pos" ]={ 0.5 , 2.2 , 0.2 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 50 },
[ 2 ]={[ "pos" ]={- 0.5 , 2.2 , 0.2 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 80 },
[ 3 ]={[ "pos" ]={- 0.3 , 2.2 , 0.2 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.15 , [ "phase" ]= 80 },
[ 4 ]={[ "pos" ]={ 0.3 , 2.2 , 0.2 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.15 , [ "phase" ]= 50 },
[ 5 ]={[ "pos" ]={- 0.1 , 2.2 , 0.2 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 50 },
[ 6 ]={[ "pos" ]={ 0.1 , 2.2 , 0.2 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 80 },
[ 7 ]={[ "pos" ]={- 0.8 , 0.6 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.15 , [ "phase" ]= 75 },
[ 8 ]={[ "pos" ]={ 0.8 , 0.6 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 25 },
[ 9 ]={[ "pos" ]={- 0.5 , 0.6 , 0.9 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.15 , [ "phase" ]= 75 },
[ 10 ]={[ "pos" ]={ 0.5 , 0.6 , 0.9 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.15 , [ "phase" ]= 25 },
[ 11 ]={[ "pos" ]={ 0.8 , - 1.7 , 0.85 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 25 },
[ 12 ]={[ "pos" ]={- 0.8 , - 1.7 , 0.85 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.25 , [ "phase" ]= 75 },
[ 13 ]={[ "pos" ]={ 0.7 , - 2.7 , - 0.2 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 95 },
[ 14 ]={[ "pos" ]={- 0.7 , - 2.7 , - 0.2 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 100 },
},
[ 490 ] = {[ "mode" ]= "lamp" , -- FBI Rancher
[ 1 ]={[ "pos" ]={ 0.4 , 0.4 , 1.1 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH lewo
[ 2 ]={[ "pos" ]={- 0.4 , 0.4 , 1.1 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH Prawo
[ 1 ]={[ "pos" ]={ 0.5 , 0.4 , 1.1 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH lewo
[ 2 ]={[ "pos" ]={- 0.5 , 0.4 , 1.1 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH Prawo
[ 3 ]={[ "pos" ]={ 0.6 , 0.4 , 1.1 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH lewo
[ 4 ]={[ "pos" ]={- 0.6 , 0.4 , 1.1 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH Prawo
[ 5 ]={[ "pos" ]={ 0.7 , 0.4 , 1.1 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH lewo
[ 6 ]={[ "pos" ]={- 0.7 , 0.4 , 1.1 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 27 }, -- DACH Prawo
},
[ 427 ] = {[ "mode" ]= "lamp" , -- ENFORCER
[ 1 ]={[ "pos" ]={- 0.90 , 2.70 , 0.2 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 10 },
[ 2 ]={[ "pos" ]={ 0.90 , 2.70 , 0.2 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.25 , [ "phase" ]= 1 },
[ 3 ]={[ "pos" ]={- 0.5 , 1.1 , 1.4 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 45 },
[ 4 ]={[ "pos" ]={ 0.5 , 1.1 , 1.4 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 45 },
[ 5 ]={[ "pos" ]={ 0.0 , 1.1 , 1.4 }, [ "color" ]={ 200 , 100 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 45 },
[ 6 ]={[ "pos" ]={- 0.3 , 1.1 , 1.4 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 45 },
[ 7 ]={[ "pos" ]={ 0.3 , 1.1 , 1.4 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 45 },
[ 8 ]={[ "pos" ]={ 1 ,- 3.87 , 0.35 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.30 , [ "phase" ]= 25 },
[ 9 ]={[ "pos" ]={- 1 ,- 3.87 , 0.35 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.30 , [ "phase" ]= 25 },
[ 10 ]={[ "pos" ]={- 1.15 ,- 3.80 ,- 0.30 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 15 },
[ 11 ]={[ "pos" ]={ 1.15 ,- 3.80 ,- 0.30 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 15 },
[ 12 ]={[ "pos" ]={ 0.95 , - 3.80 , 1.30 }, [ "color" ]={ 255 , 255 , 255 }, [ "size" ]= 0.30 , [ "phase" ]= 25 },
[ 13 ]={[ "pos" ]={- 0.95 , - 3.80 , 1.30 }, [ "color" ]={ 255 , 255 , 255 }, [ "size" ]= 0.30 , [ "phase" ]= 10 },
[ 14 ]={[ "pos" ]={ 1.10 , - 3.40 , 1.25 }, [ "color" ]={ 200 , 100 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 60 },
[ 15 ]={[ "pos" ]={- 1.10 , - 3.40 , 1.25 }, [ "color" ]={ 200 , 100 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 30 },
[ 16 ]={[ "pos" ]={ 1.10 , - 3.40 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 30 },
[ 17 ]={[ "pos" ]={- 1.10 , - 3.40 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 60 },
[ 18 ]={[ "pos" ]={ 1.10 , - 1.65 , 1.25 }, [ "color" ]={ 200 , 100 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 60 },
[ 19 ]={[ "pos" ]={- 1.10 , - 1.65 , 1.25 }, [ "color" ]={ 200 , 100 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 30 },
[ 20 ]={[ "pos" ]={ 1.10 , - 1.65 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 30 },
[ 21 ]={[ "pos" ]={- 1.10 , - 1.65 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 60 },
[ 22 ]={[ "pos" ]={ 1.10 , 0.1 , 1.25 }, [ "color" ]={ 200 , 100 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 60 },
[ 23 ]={[ "pos" ]={- 1.10 , 0.1 , 1.25 }, [ "color" ]={ 200 , 100 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 30 },
[ 24 ]={[ "pos" ]={ 1.10 , 0.1 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 30 },
[ 25 ]={[ "pos" ]={- 1.10 , 0.1 , 0.95 }, [ "color" ]={ 255 , 0 , 0 }, [ "size" ]= 0.30 , [ "phase" ]= 60 },
},
[ 541 ] = {[ "mode" ]= "lamp" , -- Infek
[ 1 ]={[ "pos" ]={ 0.45 , 0.1 , 0.7 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
[ 2 ]={[ "pos" ]={ 0.45 , 0.1 , 0.6 }, [ "color" ]={ 0 , 0 , 255 }, [ "size" ]= 0.17 , [ "phase" ]= 25 },
},
}
-- do not modify --------------------------------------------
local vehicles = {}
local timers = {}
local base_freq = 50 -- freq of timer for light change
-------------------------------------------------------------
function release_vehicle ( vehicle )
if ( isElement ( vehicle )) then
if ( is_strobo_enabled ) then
setVehicleOverrideLights ( vehicle , 1 )
setVehicleLightState ( vehicle , 3 , 1 )
setVehicleLightState ( vehicle , 1 , 1 )
setVehicleLightState ( vehicle , 2 , 1 )
setVehicleLightState ( vehicle , 3 , 1 )
end
end
if ( vehicles [ vehicle ]~= nil ) then
-- release the markers
for key , value in pairs ( vehicles [ vehicle ][ "flist" ]) do
destroyElement ( value [ "m" ])
end
vehicles [ vehicle ] = nil
end
if ( timers [ vehicle ]~= nil ) then
-- kill the strobo timer
killTimer ( timers [ vehicle ])
timers [ vehicle ] = nil
if ( isElement ( vehicle )) then
if ( getElementData ( vehicle , "emerlights_source" )== getPlayerName ( getLocalPlayer ())) then
triggerEvent ( "onPlayerEmergencyLightStateChange" , getRootElement (), 0 )
end
end
end
end
function checkForAbility ( vehicle )
local veh_model = getElementModel ( vehicle )
if ( car_lights_table [ veh_model ]== nil )or( getElementData ( vehicle , "emerlights_enabled" )== "false" ) then
return false
end
return true
end
function strobo_state_update ( vehicle )
-- check for valid vehicle
if ( isElement ( vehicle )) then
if ( vehicles [ vehicle ]== nil ) then
-- check for disallowing to use lights
-- its enabled by default
if ( checkForAbility ( vehicle )== false ) then
release_vehicle ( vehicle )
return
end
local veh_model = getElementModel ( vehicle )
--if ( car_lights_table [ veh_model ]== nil ) then
-- veh_model = "default"
-- end
local occupant = getVehicleOccupant ( vehicle , 0 )
if ( getElementType ( occupant )== "player" ) then -- peds also can use emerlights
local src = getPlayerName ( occupant )
setElementData ( vehicle , "emerlights_source" , src , false )
if ( src == getPlayerName ( getLocalPlayer ())) then
triggerEvent ( "onPlayerEmergencyLightStateChange" , getRootElement (), 1 )
end
end
-- init state variable
vehicles [ vehicle ] = {}
vehicles [ vehicle ][ "lstate" ] = 0 -- strobo lights state
vehicles [ vehicle ][ "fstate" ] = 0 -- flash light state
vehicles [ vehicle ][ "flist" ] = {} -- flash lights list ( marker ids )
-- create flash lights
local mode = car_lights_table [ veh_model ][ "mode" ]
if ( mode == nil ) then
mode = "lamp"
end
local coeff = 0
if ( mode == "lamp" ) then
coeff = 3.141592654 / 10.0
else
coeff = blink_interval / 20.0
end
vehicles [ vehicle ][ "fmode" ] = mode
if getElementData ( vehicle , "vehicle:PSP" ) or getElementData ( vehicle , "vehicle:police" ) or getElementData ( vehicle , "vehicle:oswietlenie" ) or getElementData ( vehicle , "data:job" ) or getElementData ( vehicle , "vehicle:" ) or getElementData ( vehicle , "vehicle:id" ) == 128 then
for light_id , light_desc in pairs ( car_lights_table [ veh_model ]) do
if ( light_id ~= "mode" ) then
vehicles [ vehicle ][ "flist" ][ light_id ] = {}
vehicles [ vehicle ][ "flist" ][ light_id ][ "m" ] = createMarker ( 0.0001 , 0.0001 , 0.0001 , "corona" , light_desc [ "size" ], light_desc [ "color" ][ 1 ], light_desc [ "color" ][ 2 ], light_desc [ "color" ][ 3 ], 100 )
vehicles [ vehicle ][ "flist" ][ light_id ][ "p" ] = light_desc [ "phase" ]* coeff
attachElements ( vehicles [ vehicle ][ "flist" ][ light_id ][ "m" ], vehicle , light_desc [ "pos" ][ 1 ], light_desc [ "pos" ][ 2 ], light_desc [ "pos" ][ 3 ] )
end
end
end
end
-- strobo light
if ( is_strobo_enabled ) then
setVehicleOverrideLights ( vehicle , 2 )
if ( vehicles [ vehicle ][ "lstate" ]< strobo_interval ) then
setVehicleLightState ( vehicle , 0 , 1 )
setVehicleLightState ( vehicle , 1 , 0 )
setVehicleLightState ( vehicle , 2 , 0 )
setVehicleLightState ( vehicle , 3 , 1 )
else
setVehicleLightState ( vehicle , 0 , 0 )
setVehicleLightState ( vehicle , 1 , 1 )
setVehicleLightState ( vehicle , 2 , 1 )
setVehicleLightState ( vehicle , 3 , 0 )
end
if ( vehicles [ vehicle ][ "lstate" ]>= strobo_interval * 2 ) then
vehicles [ vehicle ][ "lstate" ] = 0
else
vehicles [ vehicle ][ "lstate" ] = vehicles [ vehicle ][ "lstate" ] + 1
end
end
-- flash light -- createMarker
if ( vehicles [ vehicle ][ "fmode" ]== "lamp" ) then
-- lamp mode
local tmp_fstate = vehicles [ vehicle ][ "fstate" ]
for key , value in pairs ( vehicles [ vehicle ][ "flist" ]) do
local R , G , B , A = getMarkerColor ( value [ "m" ] )
setMarkerColor ( value [ "m" ], R , G , B , ( math . sin ( tmp_fstate + value [ "p" ])+ 1.0 )* 128.0 )
end
vehicles [ vehicle ][ "fstate" ] = vehicles [ vehicle ][ "fstate" ] + flash_interval
else
-- led mode 3
local tmp_fstate = vehicles [ vehicle ][ "fstate" ]
for key , value in pairs ( vehicles [ vehicle ][ "flist" ]) do
local R , G , B , A = getMarkerColor ( value [ "m" ])
-- blinking mode
local tmp_val = tmp_fstate + value [ "p" ]
if ( tmp_val > blink_interval ) then
tmp_val = tmp_val - blink_interval
end
if (( tmp_val >= 0 )and( tmp_val < blink_duration ))or(( tmp_val >= blink_duration * 6 )and( tmp_val < blink_duration * 5 )) then
setMarkerColor ( value [ "m" ], R , G , B , 255 )
else
setMarkerColor ( value [ "m" ], R , G , B , 0 )
end
end
vehicles [ vehicle ][ "fstate" ] = vehicles [ vehicle ][ "fstate" ] + 1
if ( vehicles [ vehicle ][ "fstate" ]> blink_interval ) then
vehicles [ vehicle ][ "fstate" ] = vehicles [ vehicle ][ "fstate" ] - blink_interval
end
end
else
-- if vehicle is no more exists
release_vehicle ( vehicle )
end
end
-- not used anymore
function stroboLightOn ()
playerVehicle = getPedOccupiedVehicle ( getLocalPlayer () ) -- get the player 's vehicle
--setElementData( playerVehicle, "emerlights_enabled", "true" ) -- debug
if ( playerVehicle ) then
-- if player is not a driver
if (getLocalPlayer()~=getVehicleOccupant( playerVehicle )) then
--outputChatBox("you' re not a driver ! ")
return
end
setStroboLightsOn(playerVehicle, nil)
end
end
function isStroboLightsOn (vehicle_id)
if (timers[vehicle_id]) then
return 1
else
return 0
end
end
function setStroboLightsOn(vehicle_id, value)
if ( vehicle_id ) then
if (value==nil) then
if (isStroboLightsOn(vehicle_id)==1) then
value = 0
else
value = 1
end;
end;
if (value==0) then
if (timers[vehicle_id]) then
release_vehicle(vehicle_id)
end
end
if (value==1) then
if (timers[vehicle_id]) then
release_vehicle(vehicle_id)
end
-- create strobo timer
timers[vehicle_id] = setTimer ( strobo_state_update, base_freq, 0, vehicle_id )
end
end
end
--vehicle:psp
-- only local effect
function enableStroboLightsMode(source, value)
if (value==" 0 ")or(value==" false ") then
is_strobo_enabled = false
outputConsole(" Stroboscopic mode disabled ")
else
if (value==" 1 ")or(value==" true ") then
is_strobo_enabled = true
outputChatBox(" Stroboscopic mode enabled ")
else
outputChatBox(" Usage : strobo 0 or strobo 1 for disable / enable stroboscopic lights mode ")
end
end
end
addCommandHandler(" psrpgtozajebistyserwer ", enableStroboLightsMode)
-- triggered by server
function setEmerlightsState(value, state)
local player = getPlayerFromName ( value )
local vehicle = getPedOccupiedVehicle(player)
if (vehicle) then
setStroboLightsOn(vehicle, state)
end
end
addEvent(" setEmerlights ", true)
addEventHandler(" setEmerlights ", getRootElement(), setEmerlightsState)
function requestEmerlights()
-- check for driver
playerVehicle = getPedOccupiedVehicle (getLocalPlayer()) -- get the player's vehicle
if (playerVehicle) then
-- if player is not a driver
if (getLocalPlayer()~=getVehicleOccupant( playerVehicle )) then
--outputChatBox(" you 're not a driver!")
return
end
if (checkForAbility(playerVehicle)) then
-- sync
triggerServerEvent("requestEmerlightChangeState", getLocalPlayer(), 1-isStroboLightsOn(getPedOccupiedVehicle(getLocalPlayer())))
else
-- not able to use lights for this vehicle
--outputChatBox("unknown car!")
end
end
end
addCommandHandler("sygnaly_swietlne", requestEmerlights)--stroboLightOn)
bindKey("n", "down", "sygnaly_swietlne")
addEvent("onPlayerEmergencyLightStateChange")
--582
Dodano: 2020-11-07, 12:44
Wys?a?em plik ze ?wiate?kami. Nie potrafie da? tego jako code
Kod dodawaj za pomoc? znacznik?w code/lua -> [ lua] Tw?j kod [/lua] [bez spacji w tagu] //Emm
Ostatnio zmieniony przez Emm 2020-11-07, 16:58, w całości zmieniany 1 raz