• Help me with CurTime()
    6 replies, posted
Can someone Explain how to use CurTime() as a Timer
[lua]if CurTime() < Timer then Timer = CurTime() + extra end[/lua]
[QUOTE=gonzalolog;47110978][lua]if CurTime() < Timer then Timer = CurTime() + extra end[/lua][/QUOTE] ok now put a function with it like give() or something so i understand better cause i basically already have that but it doesn't register
[lua]local nextAllowance = 0 local delay = 5 local function giveAllowance() if CurTime() < nextAllowance then return end -- The current time is less than the time when it will next be allowed, so return -- Do whatever nextAllowance = CurTime() + delay -- Set the next allowed time to delay seconds after now end [/lua]
[QUOTE=zerf;47111032][lua]local nextAllowance = 0 local delay = 5 local function giveAllowance() if CurTime() < nextAllowance then return end -- The current time is less than the time when it will next be allowed, so return -- Do whatever nextAllowance = CurTime() + delay -- Set the next allowed time to delay seconds after now end [/lua][/QUOTE] Oh ok ty i get it now :P [editline]10th February 2015[/editline] well i thought it worked its still just sitting there [code]local nextrun = 0 local delay = 5 function swag( ply ) if CurTime() < nextrun then return end-- The current time is less than the time when it will next be allowed, so return print("swag") print("sawag") nextrun = CurTime() + delay -- Set the next allowed time to delay seconds after now end [/code]
Here's a simple tut on time: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/time/understanding_time%20and_basic_time_calculations.lua.html[/url] CurTime( ) starts at 0 when the server starts and it starts counting when the first player joins ( because timers, etc... get triggered by the first player / bot ). There's also RealTime( ), os.time( ), FrameTime( ) and a few others. FrameTime( ) gets the &#9650;T from the last frame to current time so it's useful when binding something to time rather than fps.
[QUOTE=log404;47111207]Oh ok ty i get it now :P [editline]10th February 2015[/editline] well i thought it worked its still just sitting there [code]local nextrun = 0 local delay = 5 function swag( ply ) if CurTime() < nextrun then return end-- The current time is less than the time when it will next be allowed, so return print("swag") print("sawag") nextrun = CurTime() + delay -- Set the next allowed time to delay seconds after now end [/code][/QUOTE] Do you have swag running on think or something? It's not gonna run itself
Sorry, you need to Log In to post a reply to this thread.