Jump to content

timer help


orcun99

Recommended Posts

Posted (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 by orcun99

560x95_FFFFFF_FF9900_000000_000000.png

Posted

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.

Lua Scripter

?ucet=miki_cz

Owner of mshost.cz MTA portal.

Posted
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?

560x95_FFFFFF_FF9900_000000_000000.png

Posted

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.

  • Sad 1

Lua Scripter

?ucet=miki_cz

Owner of mshost.cz MTA portal.

Posted
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)

 

560x95_FFFFFF_FF9900_000000_000000.png

Posted

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	

 

  • Thanks 1
Posted
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

560x95_FFFFFF_FF9900_000000_000000.png

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