Jump to content

Hydra timer


-Doc-

Recommended Posts

Hey, i made this script which toggles vehicle_fire when a projectile created and then restores it using timer but doesn't work.

timer = {} 
addEventHandler("onClientProjectileCreation", localPlayer, 
function() 
    if  getElementModel(getPedOccupiedVehicle(getLocalPlayer())) == 520  then 
        setElementData(localPlayer, "anti repeater", true); 
        if ( getElementData(localPlayer, "anti repeater") == true ) then 
            toggleControl("vehicle_fire", false); 
            timer[source] = setTimer( function() 
            toggleControl("vehicle_fire", true); 
            setElementData(localPlayer, "anti repeater", false); 
            end, 5000, 1 ) 
        end 
    end 
end) 

Link to comment

Client:

The source of this event is the projectile that was created.
timer = {} 
addEventHandler("onClientProjectileCreation", root, function(creator) 
    local vehicle = getPedOccupiedVehicle(creator) 
    if vehicle and getElementModel(vehicle) == 520 then 
        if setElementData(creator, "anti repeater", true) then 
            triggerServerEvent("toggle_control", creator, false) 
            timer[creator] = setTimer( function() 
                triggerServerEvent("toggle_control", creator, true) 
                setElementData(creator, "anti repeater", false) 
            end, 5000, 1 ) 
        end 
    end 
end) 

Server

addEvent("toggle_control", true) 
addEventHandler("toggle_control", root, function(enabled) 
    toggleControl(source, "vehicle_fire", enabled) 
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...