Jump to content

(Ayuda) Timer No funciona


lucascba

Recommended Posts

Hola, Tengo una duda, estoy haciendo un evento y quiero hacer que cuando el jugador pase por un Col le cuente un timer y cuando pase por otro se detenga hice esto pero no funciona:

function incrementartiempo(player) 
    local segundos = 0 
    segundos = segundos + 1 
    setElementData(player, "CLEvento.Tiempo", ""..segundos.."") 
end 
  
function parteinicio1 (hitelemnt) 
eltiempoplayer[hitelemnt] = setTimer(incrementartiempo, 1000, 1, hitelemnt) 
end 
addEventHandler ( "onColShapeHit", N1, parteinicio1 ) 

Que puedo hacer?

Link to comment

prueva con esto

function incrementartiempo(player) 
    local segundos = 0 
    segundos = segundos + 1 
    setElementData(player, "CLEvento.Tiempo", ""..segundos.."") 
end 
  
function parteinicio1 (hitelemnt) 
eltiempoplayer[hitelemnt] = setTimer(incrementartiempo, 1000, 0, hitelemnt) 
end 
addEventHandler ( "onColShapeHit", N1, parteinicio1 ) 

Link to comment

Recuerda que estás usando server side, no uses variables sin definir el jugador, además cada 1 segundo estás llamando a una función que hace poner la variable en 0.

  
segundos = {} 
    function incrementartiempo(player) 
if not segundos[player] then 
        segundos[player] = 0 
end 
        segundos[player] = segundos[player] + 1 
        setElementData(player, "CLEvento.Tiempo",segundos[player]) 
    end 
      
    function parteinicio1 (hitelemnt) 
    eltiempoplayer = setTimer(incrementartiempo, 1000, 1, hitelemnt) 
    end 
    addEventHandler ( "onColShapeHit", N1, parteinicio1 ) 

Link to comment

Con respecto a lo que me preguntaste en Facebook, era un error mio

  
    timer = {} 
    segundos = {} 
        function incrementartiempo(player) 
    if not segundos[player] then 
            segundos[player] = 0 
    end 
            segundos[player] = segundos[player] + 1 
            setElementData(player, "CLEvento.Tiempo",segundos[player]) 
        end 
          
        function parteinicio1 (hitelemnt) 
        timer[hitElement] = setTimer(incrementartiempo, 1000, 1, hitelemnt) 
        end 
        addEventHandler ( "onColShapeHit", N1, parteinicio1 ) 
  

Link to comment
  
    function gano (hitelemnt) 
    local yaesta1 = getElementData(hitelemnt, "EventoP") 
    if yaesta1 == "Si" then 
    if isTimer ( timer[hitelement] ) then killTimer ( timer[hitelement] ) end 
    end 
    end 
    addEventHandler ( "onColShapeHit", EV, gano ) 

Link to comment
  • Recently Browsing   0 members

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