Hello, i try to do my own ELS and i have a problem. I create this code (client site):
local zmienna = 0
local elm = 0
local timer = nil
local lp = nil
local ll = nil
local czas = 500
--[[function czest(player,CommandName,wartosc)
tonumber(wartosc)
czas = wartosc
end
addCommandHandler("hz", czest)--]]
function swiatla(source)
for i,player in ipairs(getElementsByType("player")) do
local vehicle = getPedOccupiedVehicle ( player )
if zmienna == 0 then
zmienna = 1
destroyElement ( ll )
lp = createMarker ( 0, 0, 0, "corona", 0.5, 255, 0, 0, 170 )
attachElements (lp, vehicle, -0.8, 2.2, 0)
setVehicleLightState ( vehicle, 0, 0 )
setVehicleLightState ( vehicle, 1, 1 )
setVehicleHeadLightColor(vehicle,255,0,0)
else
destroyElement ( lp )
ll = createMarker ( 0, 0, 0, "corona", 0.5, 0, 0, 255, 170 )
attachElements (ll, vehicle, 0.8, 2.2, 0)
setVehicleLightState ( vehicle, 0, 1 )
setVehicleLightState ( vehicle, 1, 0 )
setVehicleHeadLightColor(vehicle,0,0,255)
zmienna = 0
end
end
end
addCommandHandler("els", function ()
if elm == 0 then
elm = 1
timer = setTimer ( swiatla, czas, 0)
elseif elm == 1 then
elm = 0
killTimer (timer)
for i,player in ipairs(getElementsByType("player")) do
local vehicle = getPedOccupiedVehicle(player)
setVehicleLightState ( vehicle, 0, 0 )
setVehicleLightState ( vehicle, 1, 0 )
setVehicleLightState ( vehicle, 2, 0 )
setVehicleLightState ( vehicle, 3, 0 )
setVehicleHeadLightColor(vehicle,255,255,255)
destroyElement ( lp )
destroyElement ( ll )
end
end
end)
In this script its work if I was alone in a server, if someone join in debugscript 3 i have a error like: setVehicleLightState argument 1 is empty or got boolean.
So i do a another code
setVehicleLightState
local zmienna = 0
local elm = 0
local timer = nil
local lp = nil
local ll = nil
local czas = 500
--[[function czest(player,CommandName,wartosc)
tonumber(wartosc)
czas = wartosc
end
addCommandHandler("hz", czest)--]]
function swiatla(source)
local vehicle = getPedOccupiedVehicle ( source )
if zmienna == 0 then
zmienna = 1
destroyElement ( ll )
lp = createMarker ( 0, 0, 0, "corona", 0.5, 255, 0, 0, 170 )
attachElements (lp, vehicle, -0.8, 2.2, 0)
setVehicleLightState ( vehicle, 0, 0 )
setVehicleLightState ( vehicle, 1, 1 )
setVehicleHeadLightColor(vehicle,255,0,0)
else
destroyElement ( lp )
ll = createMarker ( 0, 0, 0, "corona", 0.5, 0, 0, 255, 170 )
attachElements (ll, vehicle, 0.8, 2.2, 0)
setVehicleLightState ( vehicle, 0, 1 )
setVehicleLightState ( vehicle, 1, 0 )
setVehicleHeadLightColor(vehicle,0,0,255)
zmienna = 0
end
end
addCommandHandler("els", function ()
if elm == 0 then
elm = 1
timer = setTimer ( swiatla, czas, 0)
elseif elm == 1 then
elm = 0
killTimer (timer)
for i,player in ipairs(getElementsByType("player")) do
local vehicle = getPedOccupiedVehicle(player)
setVehicleLightState ( vehicle, 0, 0 )
setVehicleLightState ( vehicle, 1, 0 )
setVehicleLightState ( vehicle, 2, 0 )
setVehicleLightState ( vehicle, 3, 0 )
setVehicleHeadLightColor(vehicle,255,255,255)
destroyElement ( lp )
destroyElement ( ll )
end
end
end)
And this don't work. erorr like this:setVehicleLightState [expected element at argument 1, got boolean.
So what i should do to repair this? I want a flashing light work in car when i on car and when i leave from car. And 1 have a 2st question, what should i do if i want a change a freq of flash light? its my try to do this:
function czest(player,CommandName,wartosc)
tonumber(wartosc)
czas = wartosc
end
addCommandHandler("hz", czest)
("wartosc" its a whats layer type in chat for example: /hz 100, the "czas" is a stock value (500, its on 6 line of code). I wanna change a "czas" value to a "wartosc" vaule but if i do this i have error: setTimer [expected number at argument 2, got nil]
Sorry for my english
Thanks