Jump to content

Funçao setTimer


Recommended Posts

Eu ultilizei a funçao setTimer

so que na hr de ultilizar o comando no servidor ele continua sem o tempo ainda queria por com 40 minutos ;x

PegarArma = { } 
tempo = 4000000

function consoleGive ( thePlayer, commandName, weaponID, ammo )

  local money = getPlayerMoney ( thePlayer )
	if money >= 250 then

        if (PegarArma[thePlayerSource]) then 
            return outputChatBox ( "Aguarde 40 minutos para pegar essa belezura", thePlayerSource, 225, 0, 0 ) 
        end 
	
	local status = giveWeapon ( thePlayer, 16, 1, true )
  outputChatBox('#FFFF00Você acaba de pegar uma belezura bombinha', source, 0, 255, 0, true)
  takePlayerMoney ( thePlayer, 200 )
        PegarArma[thePlayerSource] = true 
        setTimer( function(consoleGive) 
                PegarArma[thePlayerSource] = false 
            end, tempo, 1)
	else
		outputChatBox("Você tem que gastar 200 real apenas hoje pra pegar essa belezura(",thePlayer, 255, 0, 0)
	end
end
addCommandHandler ( "pegarbomba", consoleGive )

 

Link to comment

Alguns erros que deve ser de usar control+C e control+V.

Deixei assinalado os seus erros...

timer = { } --/> Adicionado
PegarArma = { } 
tempo = 2400000 --/ 60.000 (= 1 Minuto) x 40 (= 40 Minutos) = 2.400.000 milissegundos

function consoleGive ( thePlayer --[[ Removido : commandName, weaponID, ammo ]] )
   local money = getPlayerMoney ( thePlayer )
   if money >= 200 then

   if (PegarArma[thePlayer] --[[Alteração Para thePlayer]] ) then 
      return outputChatBox ( "Aguarde 40 minutos para pegar essa belezura", thePlayer --[[Alteração Para thePlayer]], 225, 0, 0 ) 
   end 
	
   giveWeapon ( thePlayer, 16, 1, true )
   outputChatBox("#FFFF00Você acaba de pegar uma belezura bombinha", thePlayer --[[Alteração Para thePlayer]], 255, 255, 255, true)
   takePlayerMoney ( thePlayer, 200 )
   PegarArma[thePlayer --[[Alteração Para thePlayer]]] = true 
   
      timer[thePlayer] = setTimer( function( thePlayer --[[Alteração Para thePlayer]])
         PegarArma[thePlayer --[[Alteração Para thePlayer]]] = false 
      end, tempo, 1, thePlayer--[[Adicionado thePlayer]])
   else
      outputChatBox("Você tem que gastar 200 real apenas hoje pra pegar essa belezura(",thePlayer, 255, 0, 0)
   end
end
addCommandHandler ( "pegarbomba", consoleGive )

addEventHandler("onPlayerQuit", root, function()
   if isTimer(timer[source]) then killTimer(timer[source]) timer[source] = nil end
   if PegarArma[source] then PegarArma[source] = nil end
end)

 

 

Edited by Lord Henry
Ctrl
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...