orcun99 Posted February 21, 2018 Share Posted February 21, 2018 (edited) I tried this command but don't works timer works auto I wanna just """" If (kumar) then""" function mainFunction() outputChatBox ("you need wait 10min") setTimer ( function() setAccountData ( uyelik, "aq", false ) outputChatBox ( "10min expried you can use command again" ) end, 60000*10, 1 ) end full code function paraVer(para) local uyelik = getPlayerAccount(source) local kumar = getAccountData(uyelik, "aq", true) if (kumar) then outputChatBox("you are already used command you need wait 10min") mainFunction() -- WRONG HERE TIMER STARTS AUTO setAccountData ( uyelik, "aq", false ) outputChatBox("10min expried now you can command again") return end for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #0589f9"..para.."$ #e4e4e4kazandi..!",player, 255,255,255,true ) end givePlayerMoney(source, para ) setAccountData ( uyelik, "aq", true ) end addEvent("moneyVer", true) addEventHandler("moneyVer", getRootElement(), paraVer) Edited February 21, 2018 by orcun99 Link to comment
MIKI785 Posted February 21, 2018 Share Posted February 21, 2018 Kind of difficult to understand what you want.. are you trying to limit a command use to once every 10mins? If so, using a timer is never a good way. Use getTickCount instead. Link to comment
orcun99 Posted February 21, 2018 Author Share Posted February 21, 2018 1 minute ago, MIKI785 said: Kind of difficult to understand what you want.. are you trying to limit a command use to once every 10mins? If so, using a timer is never a good way. Use getTickCount instead. yes I trying to limit a command use to once every 10mins I don't know how to use getTickCount pls don't send me wiki links can u edit my code pls? Link to comment
MIKI785 Posted February 21, 2018 Share Posted February 21, 2018 You will never learn by simply copy-pasting. If you keep going on like that you will keep posting here every little issue you may have. It's really simple, player uses a command, you get the current tick using getTickCount, compare this with the tick that was saved in the user's account previously, if it's bigger, let the function execute and save the current tick + whatever the limit into the player's account. 1 Link to comment
orcun99 Posted February 21, 2018 Author Share Posted February 21, 2018 1 hour ago, MIKI785 said: You will never learn by simply copy-pasting. If you keep going on like that you will keep posting here every little issue you may have. It's really simple, player uses a command, you get the current tick using getTickCount, compare this with the tick that was saved in the user's account previously, if it's bigger, let the function execute and save the current tick + whatever the limit into the player's account. so where is wrong? function paraVer(para) local uyelik = getPlayerAccount(source) local kumar = getAccountData(uyelik, "aq", true) local time = false if (kumar) then outputChatBox("you are already used command you need wait 10min") if getTickCount()-time>=10000 then -- trying 10sec time = getTickCount() setAccountData ( uyelik, "aq", false ) outputChatBox("10min expried now you can command again") return end for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #0589f9"..para.."$ #e4e4e4kazandi..!",player, 255,255,255,true ) end givePlayerMoney(source, para ) setAccountData ( uyelik, "aq", true ) end end addEvent("moneyVer", true) addEventHandler("moneyVer", getRootElement(), paraVer) Link to comment
Mahlukat Posted February 21, 2018 Share Posted February 21, 2018 can you try this ? tablo = {} function paraVer(para) local uyelik = getPlayerAccount(source) local uyelikname = getAccountName(uyelik) if tablo[uyelikname] == "Used" then outputChatBox("you are already used command you need wait 10min", source, 255,0,0) return end for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #0589f9"..para.."$ #e4e4e4kazandi..!",player, 255,255,255,true ) end givePlayerMoney(source, para ) tablo[uyelikname] = "Used" setTimer(timer, 60000*10,1, uyelikname) end addEvent("moneyVer", true) addEventHandler("moneyVer", getRootElement(), paraVer) function timer(accname) local acc = getAccount(accname) local accPlayer = getAccountPlayer(acc) tablo[accname] = nil if accPlayer then outputChatBox ( "10min expried you can use command again", accPlayer, 0,255,0) end end 1 Link to comment
orcun99 Posted February 21, 2018 Author Share Posted February 21, 2018 6 minutes ago, Mahlukat said: can you try this ? tablo = {} function paraVer(para) local uyelik = getPlayerAccount(source) local uyelikname = getAccountName(uyelik) if tablo[uyelikname] == "Used" then outputChatBox("you are already used command you need wait 10min", source, 255,0,0) return end for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #0589f9"..para.."$ #e4e4e4kazandi..!",player, 255,255,255,true ) end givePlayerMoney(source, para ) tablo[uyelikname] = "Used" setTimer(timer, 60000*10,1, uyelikname) end addEvent("moneyVer", true) addEventHandler("moneyVer", getRootElement(), paraVer) function timer(accname) local acc = getAccount(accname) local accPlayer = getAccountPlayer(acc) tablo[accname] = nil if accPlayer then outputChatBox ( "10min expried you can use command again", accPlayer, 0,255,0) end end WORKS <3 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