Paplo Posted August 19, 2013 Share Posted August 19, 2013 how use getTickCount to half hour and one hour i try this but it work in one min and litle time Link to comment
bandi94 Posted August 19, 2013 Share Posted August 19, 2013 function time() startTick = getTickCount() if not endTick then endTick = startTick + 1000*60*30 -- 1000 = 1s*60 = 1m*30 = 30 min end if startTick >= endTick then outputChatBox("30 mins") endTick = startTick + 1000*60*30 -- reset it again for 30 min end setTimer(time,50,0) -- or addEventHandler("onClientRender",root,time) Link to comment
Paplo Posted August 19, 2013 Author Share Posted August 19, 2013 local lastTick = 0 local toWait = 60000*60 function buycar() local playerMoney = getPlayerMoney(localPlayer) if ( getTickCount ( ) - lastTick >= toWait ) then if ( playerMoney >= tonumber(9500) ) then triggerServerEvent("onBuycar",localPlayer) lastTick = getTickCount ( ) guiSetVisible( w, false ) showCursor( false ) outputChatBox ( "you bought the car", 0, 255, 0 ) else outputChatBox("you dont have 9500",255,0,0) end else outputChatBox("you must wait some time",255,0,0) end end if i will buy the car say you must wait some time if i change the toWait = 5000 or little time then it work Link to comment
bandi94 Posted August 19, 2013 Share Posted August 19, 2013 and if is bigger ?? , you can but / you can't ? Normaly it should work 5000 is only 5s it's a small time , it should work with bigger values to . Link to comment
Paplo Posted August 19, 2013 Author Share Posted August 19, 2013 and if is bigger ?? , you can but / you can't ? Normaly it should work 5000 is only 5s it's a small time , it should work with bigger values to . but i test it if i change to little time it work but if i change to big time its not work i don't know Link to comment
Paplo Posted August 19, 2013 Author Share Posted August 19, 2013 local lastTick = 0 local toWait = 60000*60 function buycar() local playerMoney = getPlayerMoney(localPlayer) if ( getTickCount ( ) - lastTick >= toWait ) then if ( playerMoney >= tonumber(9500) ) then triggerServerEvent("onBuycar",localPlayer) lastTick = getTickCount ( ) guiSetVisible( w, false ) showCursor( false ) outputChatBox ( "you bought the car", 0, 255, 0 ) else outputChatBox("you dont have 9500",255,0,0) end else outputChatBox("you must wait some time",255,0,0) end end if i will buy the car say you must wait some time if i change the toWait = 5000 or little time then it work hmmm okey how i can do this function work first time and if try to use it again you will wait one hour ?? Link to comment
Paplo Posted August 19, 2013 Author Share Posted August 19, 2013 lol nobody know how ??? Link to comment
bandi94 Posted August 19, 2013 Share Posted August 19, 2013 well you can use : setTimer getRealTime Link to comment
Paplo Posted August 19, 2013 Author Share Posted August 19, 2013 well you can use : setTimer getRealTime can you give me example ? Link to comment
bandi94 Posted August 19, 2013 Share Posted August 19, 2013 local toWait = false function buycar() local playerMoney = getPlayerMoney(localPlayer) if not toWait then if ( playerMoney >= tonumber(9500) ) then triggerServerEvent("onBuycar",localPlayer) toWait = true setTimer(switch,1000*60*60,1) guiSetVisible( w, false ) showCursor( false ) outputChatBox ( "you bought the car", 0, 255, 0 ) else outputChatBox("you dont have 9500",255,0,0) end else outputChatBox("you must wait some time",255,0,0) end end function switch() toWait = false end Link to comment
Paplo Posted August 19, 2013 Author Share Posted August 19, 2013 local toWait = false function buycar() local playerMoney = getPlayerMoney(localPlayer) if not toWait then if ( playerMoney >= tonumber(9500) ) then triggerServerEvent("onBuycar",localPlayer) toWait = true setTimer(switch,1000*60*60,1) guiSetVisible( w, false ) showCursor( false ) outputChatBox ( "you bought the car", 0, 255, 0 ) else outputChatBox("you dont have 9500",255,0,0) end else outputChatBox("you must wait some time",255,0,0) end end function switch() toWait = false end thank you it work ^^ Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now