Jump to content

Restrict this


tim260

Recommended Posts

how do i restrict it on team instead of Vehicle

-- Simple Police-Lights by MuLTi! 
  
p_lights = {} 
p_timer = {} 
p_lvar = {} 
  
function toggleLights(thePlayer, cmd) 
    local veh = getPedOccupiedVehicle(thePlayer)  
    local id = getElementModel(veh) 
    if (id == 470) then 
        if(p_lights[veh] == 0) or (not p_lights[veh]) then 
            p_lights[veh] = 1 
            setVehicleOverrideLights ( veh, 2 ) 
            triggerClientEvent ( "startSirene", getRootElement(), veh ) 
            p_timer[veh] = setTimer( 
            function() 
                if(p_lvar[veh] == 0) or (p_lvar[veh] == nil) then 
                    p_lvar[veh] = 1 
                    -- 0 = vorne links 1 = vorne rechts 2 = hinten links 3 = hinten rechts 
  
                    setVehicleLightState ( veh, 1, 0) 
                    setVehicleLightState ( veh, 2, 0) 
                    setVehicleLightState ( veh, 0, 1) 
                    setVehicleLightState ( veh, 3, 1) 
                    setVehicleHeadLightColor(veh, 0, 0, 255) 
                else 
                    setVehicleLightState ( veh, 3, 0) 
                    setVehicleLightState ( veh, 0, 0) 
                    setVehicleLightState ( veh, 1, 1) 
                    setVehicleLightState ( veh, 2, 1)    
                    setVehicleHeadLightColor(veh, 255, 0, 0) 
                    p_lvar[veh] = 0 
                end 
            end, 500, 0) 
        else 
            p_lights[veh] = 0 
            killTimer(p_timer[veh]) 
            setVehicleLightState ( veh, 0, 0) 
            setVehicleLightState ( veh, 1, 0) 
            setVehicleLightState ( veh, 2, 0) 
            setVehicleLightState ( veh, 3, 0)    
            setVehicleHeadLightColor(veh, 255, 255, 255) 
            setVehicleOverrideLights ( veh, 1 ) 
            triggerClientEvent ( "stopSirene", getRootElement(), veh ) 
        end 
    else 
        outputChatBox("You can't use this command!", thePlayer, 255, 0, 0, false) 
    end 
end 
addCommandHandler("lights", toggleLights) 
  
addEventHandler ( "onVehicleExplode", getRootElement(),  
    function() 
        if(p_lights[source] == 1) then 
            killTimer(p_timer[source])   
        end 
    end  
) 
  
addEventHandler ( "onVehicleRespawn", getRootElement(),  
    function() 
        if(p_lights[source] == 1) then 
            killTimer(p_timer[source])   
        end 
    end  
) 
  
addEventHandler("onElementDestroy", getRootElement(),  
    function () 
        if getElementType(source) == "vehicle" then 
            if(p_lights[source] == 1) then 
                killTimer(p_timer[source]) 
            end 
        end 
    end 
) 

Link to comment
-- Simple Police-Lights by MuLTi! 
  
p_lights = {} 
p_timer = {} 
p_lvar = {} 
allowedTeams = {["Admin"] = true} 
  
function toggleLights(thePlayer, cmd) 
    local veh = getPedOccupiedVehicle(thePlayer) 
    if (getPlayerTeam(thePlayer) and allowedTeams[getTeamName(getPlayerTeam(thePlayer))]) then 
        if(p_lights[veh] == 0) or (not p_lights[veh]) then 
            p_lights[veh] = 1 
            setVehicleOverrideLights ( veh, 2 ) 
            triggerClientEvent ( "startSirene", getRootElement(), veh ) 
            p_timer[veh] = setTimer( 
            function() 
                if(p_lvar[veh] == 0) or (p_lvar[veh] == nil) then 
                    p_lvar[veh] = 1 
                    -- 0 = vorne links 1 = vorne rechts 2 = hinten links 3 = hinten rechts 
  
                    setVehicleLightState ( veh, 1, 0) 
                    setVehicleLightState ( veh, 2, 0) 
                    setVehicleLightState ( veh, 0, 1) 
                    setVehicleLightState ( veh, 3, 1) 
                    setVehicleHeadLightColor(veh, 0, 0, 255) 
                else 
                    setVehicleLightState ( veh, 3, 0) 
                    setVehicleLightState ( veh, 0, 0) 
                    setVehicleLightState ( veh, 1, 1) 
                    setVehicleLightState ( veh, 2, 1)    
                    setVehicleHeadLightColor(veh, 255, 0, 0) 
                    p_lvar[veh] = 0 
                end 
            end, 500, 0) 
        else 
            p_lights[veh] = 0 
            killTimer(p_timer[veh]) 
            setVehicleLightState ( veh, 0, 0) 
            setVehicleLightState ( veh, 1, 0) 
            setVehicleLightState ( veh, 2, 0) 
            setVehicleLightState ( veh, 3, 0)    
            setVehicleHeadLightColor(veh, 255, 255, 255) 
            setVehicleOverrideLights ( veh, 1 ) 
            triggerClientEvent ( "stopSirene", getRootElement(), veh ) 
        end 
    else 
        outputChatBox("You can't use this command!", thePlayer, 255, 0, 0, false) 
    end 
end 
addCommandHandler("lights", toggleLights) 
  
addEventHandler ( "onVehicleExplode", getRootElement(), 
    function() 
        if(p_lights[source] == 1) then 
            killTimer(p_timer[source])  
        end 
    end 
) 
  
addEventHandler ( "onVehicleRespawn", getRootElement(), 
    function() 
        if(p_lights[source] == 1) then 
            killTimer(p_timer[source])  
        end 
    end 
) 
  
addEventHandler("onElementDestroy", getRootElement(), 
    function () 
        if getElementType(source) == "vehicle" then 
            if(p_lights[source] == 1) then 
                killTimer(p_timer[source]) 
            end 
        end 
    end 
) 

Do you mean that?

Link to comment
-- Simple Police-Lights by MuLTi! 
  
p_lights = {} 
p_timer = {} 
p_lvar = {} 
allowedTeams = {["Admin"] = true} 
  
function toggleLights(thePlayer, cmd) 
    local veh = getPedOccupiedVehicle(thePlayer) 
    if (getPlayerTeam(thePlayer) and allowedTeams[getTeamName(getPlayerTeam(thePlayer))]) then 
        if(p_lights[veh] == 0) or (not p_lights[veh]) then 
            p_lights[veh] = 1 
            setVehicleOverrideLights ( veh, 2 ) 
            triggerClientEvent ( "startSirene", getRootElement(), veh ) 
            p_timer[veh] = setTimer( 
            function() 
                if(p_lvar[veh] == 0) or (p_lvar[veh] == nil) then 
                    p_lvar[veh] = 1 
                    -- 0 = vorne links 1 = vorne rechts 2 = hinten links 3 = hinten rechts 
  
                    setVehicleLightState ( veh, 1, 0) 
                    setVehicleLightState ( veh, 2, 0) 
                    setVehicleLightState ( veh, 0, 1) 
                    setVehicleLightState ( veh, 3, 1) 
                    setVehicleHeadLightColor(veh, 0, 0, 255) 
                else 
                    setVehicleLightState ( veh, 3, 0) 
                    setVehicleLightState ( veh, 0, 0) 
                    setVehicleLightState ( veh, 1, 1) 
                    setVehicleLightState ( veh, 2, 1)    
                    setVehicleHeadLightColor(veh, 255, 0, 0) 
                    p_lvar[veh] = 0 
                end 
            end, 500, 0) 
        else 
            p_lights[veh] = 0 
            killTimer(p_timer[veh]) 
            setVehicleLightState ( veh, 0, 0) 
            setVehicleLightState ( veh, 1, 0) 
            setVehicleLightState ( veh, 2, 0) 
            setVehicleLightState ( veh, 3, 0)    
            setVehicleHeadLightColor(veh, 255, 255, 255) 
            setVehicleOverrideLights ( veh, 1 ) 
            triggerClientEvent ( "stopSirene", getRootElement(), veh ) 
        end 
    else 
        outputChatBox("You can't use this command!", thePlayer, 255, 0, 0, false) 
    end 
end 
addCommandHandler("lights", toggleLights) 
  
addEventHandler ( "onVehicleExplode", getRootElement(), 
    function() 
        if(p_lights[source] == 1) then 
            killTimer(p_timer[source])  
        end 
    end 
) 
  
addEventHandler ( "onVehicleRespawn", getRootElement(), 
    function() 
        if(p_lights[source] == 1) then 
            killTimer(p_timer[source])  
        end 
    end 
) 
  
addEventHandler("onElementDestroy", getRootElement(), 
    function () 
        if getElementType(source) == "vehicle" then 
            if(p_lights[source] == 1) then 
                killTimer(p_timer[source]) 
            end 
        end 
    end 
) 

Do you mean that?

yes ty

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...