Jump to content

About setTimer


SkatCh

Recommended Posts

guys please i need some help i create a vip system and i want to keep the time working even if the player logout is that possible .

just a part from my script:

local timers = { }

function startTime ( thePlayer ) 
    if not ( timers [ thePlayer ] ) then 
        timers [ thePlayer ] = setTimer ( function () 
                if ( isElement ( thePlayer ) ) then 
                    local timeLeft = getElementData ( thePlayer, "time" ); 
                    if ( timeLeft ) then 
                        if ( timeLeft > 0 ) then 
                            if ( ( timeLeft - 1 ) > 0 ) then 
                                setElementData ( thePlayer, "time", timeLeft - 1 ); 
                            else 
                                remove ( thePlayer ); 
                            end 
                        else 
                            remove ( thePlayer ); 
                        end 
                    end 
                else 
                    return; 
                end 
            end, 1000, -1 
        );       
    end 
end 

Edited by Guest
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...