Jump to content

killTimer


Sasu

Recommended Posts

local tiempo = setTimer(setElementPosition, theTimeBan, 1, thePlayer, 1543.29, -1675.92, 13.55) 

I use to killTimer...

if isTimer(tiempo) then killTimer(tiempo) end 

But it dont kill Timer. And no error on debug 3. I am doing a panel jail system.

Link to comment

I'd suggest you to use tiempo = nil inside the if isTimer(tiempo) statement in addition to killTimer cause it happens to me generally and I gotta use that to make it work.

edit:

Use this example

if isTimer(tiempo) then killTimer(tiempo) tiempo = nil end 

Edited by Guest
Link to comment

Your timer is a local variable. This will not be available outside the block it was defined in.

function name( ) 
    local a = "hello world"; 
end 
print( a ); -- this will print "nil" because 'a' is not a global variable 
  

If you want to make timers for each player then you need to use table and store timers in a table, otherwise you will have 1 global timer variable which you will kill for all players. There was a discussion about the same problem you're having yesterday: viewtopic.php?f=91&t=55691

Also, please search the forum before you post.

Link to comment

For each players not. Only see...

function banear(text, adminJail, timeJail, editText) 
local thePlayer = getPlayerFromName(text) 
if not thePlayer then 
        outputChatBox("Selecciona a un jugador de la lista", source,255,0,0,true) return end 
if (getElementData(thePlayer, "jail") == "si") then 
    setElementPosition(thePlayer, 1543.29, -1675.92, 13.55) 
        outputChatBox(text.." ha sido liberado por "..adminJail..".", getRootElement(), 255, 0, 0, false) 
        if isTimer(tiempo) then 
            killTimer(tiempo) 
            end 
                setElementData(thePlayer, "jail", "no") 
    else 
if (timeJail) then 
    theTimeBan = math.floor ( tonumber ( timeJail )*60*1000 ) 
        setElementPosition(thePlayer, 5562.25, -2121.5, 19.9) 
            tiempo = setTimer(setElementPosition, theTimeBan, 1, thePlayer, 1543.29, -1675.92, 13.55) 
                setElementData(thePlayer, "jail", "si") 
                    outputChatBox(text.." ha sido encarcelado por "..adminJail..". Razon: "..editText.." ( "..timeJail.." Min )", getRootElement(), 255, 0, 0, false) 
                end 
        end 
        end 
addEvent("jailHim", true) 
addEventHandler("jailHim", getRootElement(), banear) 

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