Jump to content

Area on map


Recommended Posts

Thank you mate.

I would ask another thing here too. What's problem with this one?

This is an emergency light script, it doesn't quit emergency lights if I do the /l command again.

In debugscript it says:

.lua:9: Bad argument @ 'killTimer'

.lua:10: Bad argument @ 'killTimer'

function EmergencyLights ( source )      
    theVehicle = getPlayerOccupiedVehicle ( source )      
    if ( theVehicle ) then                                           
        if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then  
            setVehicleOverrideLights ( theVehicle, 2 ) 
            setTimer ( setLight, 400, 1 )             
        else 
            setVehicleOverrideLights ( theVehicle, 0 )    
            killTimer ( setLight ) 
            killTimer ( setLight2 )         
        end 
    end 
end 
  
function setLight ( ) 
            setTimer ( setLight2, 400, 1 )         
            setVehicleHeadLightColor (theVehicle, 000, 000, 255)         
end 
  
function setLight2 (  ) 
            setVehicleHeadLightColor (theVehicle, 255, 000, 000)           
            setTimer ( setLight, 400, 1 )     
end 
  
addCommandHandler ( "l", EmergencyLights ) 

Link to comment

Try this:

setLights = {} 
  
function EmergencyLights ( thePlayer ) 
    theVehicle = getPedOccupiedVehicle ( thePlayer ) 
    if ( theVehicle ) then                                           
        if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then  
            setVehicleOverrideLights ( theVehicle, 2 ) 
            setLights[theVehicle] = setTimer ( setLight, 400, 1, 1, theVehicle ) 
        else 
            setVehicleOverrideLights ( theVehicle, 0 )    
            setVehicleHeadLightColor(theVehicle, 255, 255, 255) 
            if isTimer(setLights[theVehicle]) then killTimer ( setLights[theVehicle] ) end 
        end 
    end 
end 
addCommandHandler ( "l", EmergencyLights ) 
  
function setLight ( state, theVehicle ) 
if state == 1 then 
    setLights[theVehicle] = setTimer ( setLight, 400, 1, 2, theVehicle ) 
    setVehicleHeadLightColor (theVehicle, 000, 000, 255)         
elseif state == 2 then 
    setVehicleHeadLightColor (theVehicle, 255, 000, 000)           
    setLights[theVehicle] = setTimer ( setLight, 400, 1, 1, theVehicle ) 
    end 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...