Jump to content

Ayuda con getTickCount.


Araa

Recommended Posts

Posted

Bueno, asi como dice el titulo, les queria preguntar como podria hacer que el jugador solo pueda ejecutar el comando una vez cada diez minutos, y usar getTickCount para esto.

function fianza (jugador, comando) 
    if getPlayerWantedLevel(jugador) == 1 then 
    setPlayerWantedLevel (jugador, 0) 
    else  
    outputChatBox ("Solo puedes pagar fianza si tienes una estrella", jugador) 
    end 
end 
addCommandHandler ("fianza", fianza) 

Gracias (:

Hi, this is a signature.

Posted

Con tick count no sabria hacerlo pero creo que esto te pueda servir :

  
  
addEventHandler("onPlayerLogin",root, 
  
function() 
  
setElementData(source,"pago.Fianza",false) 
  
end 
) 
  
function fianza (jugador, comando) 
 local pagoFianza = getElementData(jugador,"tiene.Fianza") 
 if pagoFianza == false then    
 if getPlayerWantedLevel(jugador) == 1 then 
    setPlayerWantedLevel (jugador, 0) 
    setElementData(jugador,"pago.Fianza",true) 
    setTimer(function() setElementData(jugador,"pago.Fianza",false) end,600000,1) 
    else 
    outputChatBox ("Solo puedes pagar fianza si tienes una estrella", jugador) 
    end 
else 
outputChatBox("Hay 10 minutos de atraso para pagar la fianza",jugador) 
end 
end 
addCommandHandler ("fianza", fianza) 
  
  

WRS( World Racing Server) [server] = 8%

Posted
local ticks = { } 
local tiempo = ( 10 * 60000 ) 
  
function convertTime ( ms ) 
    local min = math.floor ( ms / 60000 ) 
    local sec = math.floor ( ( ms / 1000 ) % 60 ) 
    return min, sec 
end 
  
function fianza ( jugador ) 
    if ( ticks [ jugador ] ) then 
        local endTick = getTickCount ( ) 
        if ( endTick - ticks [ jugador ] < tiempo ) then 
            local mins, secs = convertTime ( tiempo - endTick + ticks [ jugador ] ) 
            outputChatBox ( "En ".. mins .." minutos y ".. secs .." segundos puedes volver a usar este comando.", jugador, 255, 0, 0 ) 
            return 
        end 
    end 
  
    if ( getPlayerWantedLevel ( jugador ) == 1 ) then 
        ticks [ jugador ] = getTickCount ( ) 
  
        setPlayerWantedLevel ( jugador, 0 ) 
    else 
        outputChatBox ( "Solo puedes pagar fianza si tienes una estrella", jugador, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "fianza", fianza ) 

Ahi tienes, deberia funcionar perfectamente ;).

Espero que lo leas y aprendas de como lo hice.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Ah, perfecto muchas gracias. Cuando ejecutas el comando comienza el tick count y se termina cuando lo ejecutas de nuevo, verdad?

Hi, this is a signature.

Posted

Es que no es como un timer, no se ejecuta y luego se borra.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...