Jump to content

setTimer problem :D


golanu21

Recommended Posts

--EDIT 
function spawn () 
toggleAllControls(source, false) 
setTimer(togleAllControls, 10000, 1, source, true) 
setControlState(source, "forwards", true) 
setTimer(setControlState,10000, 1, source, "forwards", false) 
end 
addEventHandler("onPlayerSpawn", getRootElement(), spawn) 
setTimer(spawn, 10000, 1) 

how i make after 10 sec to stop forcing "forwards" ?and the toggleControls to come back to true ?

Link to comment
  
function spawn () 
       toggleAllControls (source, false); 
       toggleControl (source, "forwards", true);  
       setControlState (source, "forwards", true)  
       setTimer ( 
             function (thePlayer)  
                   setControlState (thePlayer, "forwards", false); 
                   toggleAllControls (thePlayer, true);  
             end, 10000, 1,  source);  
end;  
  

Link to comment
  • Moderators

Note: the player can leave while the timer is running.

= warning/error

setTimer (function () 
    if isElement(source) then 
        setControlState (source, "forwards", false) 
        toggleAllControls (source, true) 
    end 
end, 10000, 1) 

The source can be used with in the timer-function, the data stays within the block.

It will be erased after everything has ended within the block.

Block

function spawn ()

end;

Btw: make sure there is an event else probably there won't be a source.

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