Jump to content

Problema con Timer


Destroyer.-

Recommended Posts

Hola tengo un problema con el timer en este script de Pizzero, lo que pasa es que cuando salgo del vehiculo quiero que si en 10 segundos no entra acabe , pero no acaba :S

Client:

  
local markersPosition = { 
    {1715.3720703125, -2138.09375, 12.546875}, 
    {1684.328125, -2086.080078125, 12.546875}, 
    {2454.8046875, -1708.7099609375, 12.61628818512}, 
    {1938.380859375, -1066.4912109375, 23.417552947998}, 
    {1321.353515625, -1075.5107421875, 28.1796875}, 
    {662.88385009766,-1487.4228515625,13.8515625}, 
    {824.06341552734,-849.47668457031,68.921806335449}, 
    {1271.7863769531,294.98532104492,19.656307220459}, 
    {2314.1171875,56.500453948975,25.480714797974}, 
    {2273.2758789063,-132.70761108398,27.153547286987}, 
    {609.37469482422,-559.22979736328,15.672647476196}, 
    {-1804.85,558.45,34.15}, 
    {-752.6,-131.6,64.8}, 
} 
progreso = 0 
  
function getNewLocation ( player, seat ) 
    local vehicle = getPedOccupiedVehicle ( player ) 
    local id = getElementModel ( vehicle ) 
    if ( id == 448 ) and ( seat == 0 ) and ( progreso == 0 ) then 
        outputChatBox ( "[iNFO]Ve a la pizza para ganar $",255,255,0 ) 
        local num = math.random ( #markersPosition ) 
        marker = createMarker ( markersPosition [ num ] [ 1 ], markersPosition [ num ] [ 2 ], markersPosition [ num ] [ 3 ], "cylinder", 3.5, 255, 255, 0 ) 
        blip = createBlipAttachedTo ( marker, 51 ) 
        progreso = 1  
        addEventHandler ( "onClientMarkerHit", marker,                  
            function ( hitElement ) 
                if ( hitElement and getElementType ( hitElement ) == "player" and hitElement == localPlayer ) then 
                    destroyElement ( marker ) 
                    destroyElement ( blip ) 
 outputChatBox ( "[iNFO]Entregaste una pizza y ganaste $2000 ",255,255,0 ) 
                   triggerServerEvent("dinerito", player, "dinero") 
                    setTimer ( getNewLocation, 2000, 1, localPlayer, seat ) 
                end 
            end 
        ) 
    end 
end 
addEventHandler ( "onClientVehicleEnter", root, getNewLocation ) 
  
  
function removebeagle ( thePlayer, seat, jacked ) 
    outputChatBox ("Tienes 10 Segundos para volver al vehiculo si no perderas la mision",255,255,0 ) 
    if ( getElementModel ( source ) == 448 and progreso == 0 ) then 
                local Timer = setTimer ( function(player)  
        outputChatBox ( "[EMPLEO]Mision Fracasada!!!",255,255,0 ) 
destroyElement ( marker ) 
destroyElement ( blip ) 
        end, 10000, 1 ) 
     end 
     end 
addEventHandler ( "onClientVehicleExit", getRootElement(), removebeagle ) 
  

Gracias :|

Link to comment
  
local markersPosition = { 
    {1715.3720703125, -2138.09375, 12.546875}, 
    {1684.328125, -2086.080078125, 12.546875}, 
    {2454.8046875, -1708.7099609375, 12.61628818512}, 
    {1938.380859375, -1066.4912109375, 23.417552947998}, 
    {1321.353515625, -1075.5107421875, 28.1796875}, 
    {662.88385009766,-1487.4228515625,13.8515625}, 
    {824.06341552734,-849.47668457031,68.921806335449}, 
    {1271.7863769531,294.98532104492,19.656307220459}, 
    {2314.1171875,56.500453948975,25.480714797974}, 
    {2273.2758789063,-132.70761108398,27.153547286987}, 
    {609.37469482422,-559.22979736328,15.672647476196}, 
    {-1804.85,558.45,34.15}, 
    {-752.6,-131.6,64.8}, 
} 
progreso = 0 
  
function getNewLocation ( player, seat ) 
    local vehicle = getPedOccupiedVehicle ( player ) 
    local id = getElementModel ( vehicle ) 
    if ( id == 448 ) and ( seat == 0 ) and ( progreso == 0 ) then 
        outputChatBox ( "[iNFO]Ve a la pizza para ganar $",255,255,0 ) 
        local num = math.random ( #markersPosition ) 
        marker = createMarker ( markersPosition [ num ] [ 1 ], markersPosition [ num ] [ 2 ], markersPosition [ num ] [ 3 ], "cylinder", 3.5, 255, 255, 0 ) 
        blip = createBlipAttachedTo ( marker, 51 ) 
        progreso = 1 
        addEventHandler ( "onClientMarkerHit", marker,                 
            function ( hitElement ) 
                if ( hitElement and getElementType ( hitElement ) == "player" and hitElement == localPlayer ) then 
                    destroyElement ( marker ) 
                    destroyElement ( blip ) 
 outputChatBox ( "[iNFO]Entregaste una pizza y ganaste $2000 ",255,255,0 ) 
                   triggerServerEvent("dinerito", player, "dinero") 
                    setTimer ( getNewLocation, 2000, 1, localPlayer, seat ) 
                end 
            end 
        ) 
    end 
end 
addEventHandler ( "onClientVehicleEnter", root, getNewLocation ) 
  
  
function removebeagle ( thePlayer, seat, jacked ) 
    outputChatBox ("Tienes 10 Segundos para volver al vehiculo si no perderas la mision",255,255,0 ) 
    if ( getElementModel ( source ) == 448 ) then 
    lol = isTimer(source)     
                setTimer (function(player) 
        outputChatBox ( "[EMPLEO]Mision Fracasada!!!",255,255,0 ) 
destroyElement ( marker ) 
destroyElement ( blip ) 
           end, 4000, 1, source) 
end 
addEventHandler ( "onClientVehicleExit", getRootElement(), removebeagle, source) 
  
        function enter(thePlayer , seat) 
if (getElementModel(source) == 448 ) and ( getElementModel (thePlayer) == 155 ) then 
if isTimer ( lol ) then killTimer ( lol ) end 
end 
end 
end 
addEventHandler ("OnClientVehicleEnter", getRootElement(), enter) 

intente haci pero no funciono ,dejo de funcionar la function removebeagle y salta un warning en el debugscript del addEventHandler de la function removebeagle

Link to comment
local markersPosition = { 
    {1715.3720703125, -2138.09375, 12.546875}, 
    {1684.328125, -2086.080078125, 12.546875}, 
    {2454.8046875, -1708.7099609375, 12.61628818512}, 
    {1938.380859375, -1066.4912109375, 23.417552947998}, 
    {1321.353515625, -1075.5107421875, 28.1796875}, 
    {662.88385009766,-1487.4228515625,13.8515625}, 
    {824.06341552734,-849.47668457031,68.921806335449}, 
    {1271.7863769531,294.98532104492,19.656307220459}, 
    {2314.1171875,56.500453948975,25.480714797974}, 
    {2273.2758789063,-132.70761108398,27.153547286987}, 
    {609.37469482422,-559.22979736328,15.672647476196}, 
    {-1804.85,558.45,34.15}, 
    {-752.6,-131.6,64.8}, 
} 
progreso = 0 
  
function getNewLocation ( player, seat ) 
    local vehicle = getPedOccupiedVehicle ( player ) 
    local id = getElementModel ( vehicle ) 
    if ( id == 448 ) and ( seat == 0 ) and ( progreso == 0 ) then 
        outputChatBox ( "[iNFO]Ve a la pizza para ganar $",255,255,0 ) 
        local num = math.random ( #markersPosition ) 
        marker = createMarker ( markersPosition [ num ] [ 1 ], markersPosition [ num ] [ 2 ], markersPosition [ num ] [ 3 ], "cylinder", 3.5, 255, 255, 0 ) 
        blip = createBlipAttachedTo ( marker, 51 ) 
        progreso = 1 
        addEventHandler ( "onClientMarkerHit", marker,                 
            function ( hitElement ) 
                if ( hitElement and getElementType ( hitElement ) == "player" and hitElement == localPlayer ) then 
                    destroyElement ( marker ) 
                    destroyElement ( blip ) 
 outputChatBox ( "[iNFO]Entregaste una pizza y ganaste $2000 ",255,255,0 ) 
                   triggerServerEvent("dinerito", player, "dinero") 
                    setTimer ( getNewLocation, 2000, 1, localPlayer, seat ) 
                end 
            end 
        ) 
if (getElementModel(source) == 448 ) and ( getElementModel (thePlayer) == 155 ) then 
if isTimer ( myTimer ) then  
killTimer ( myTimer )  
end 
end 
end 
addEventHandler ( "onClientVehicleEnter", root, getNewLocation ) 
  
  
function removebeagle ( thePlayer, seat, jacked ) 
    outputChatBox ("Tienes 10 Segundos para volver al vehiculo si no perderas la mision",255,255,0 ) 
               myTimer = setTimer ( function(player) 
        outputChatBox ( "[EMPLEO]Mision Fracasada!!!",255,255,0 ) 
destroyElement ( marker ) 
destroyElement ( blip ) 
progreso = 0 
        end, 10000, 1 ) 
     end 
end 
addEventHandler ( "onClientVehicleExit", getRootElement(), removebeagle ) 

Mira , puse el killtimer arriba en el evento de enter y sigue sin funcionar , y puse el ejemplo que vos me dijiste y nada , me podias ayudar a arreglarlo, por favor? :|

Link to comment

Te fixié unos cuantos debugs:

  
local markersPosition = { 
    {1715.3720703125, -2138.09375, 12.546875}, 
    {1684.328125, -2086.080078125, 12.546875}, 
    {2454.8046875, -1708.7099609375, 12.61628818512}, 
    {1938.380859375, -1066.4912109375, 23.417552947998}, 
    {1321.353515625, -1075.5107421875, 28.1796875}, 
    {662.88385009766,-1487.4228515625,13.8515625}, 
    {824.06341552734,-849.47668457031,68.921806335449}, 
    {1271.7863769531,294.98532104492,19.656307220459}, 
    {2314.1171875,56.500453948975,25.480714797974}, 
    {2273.2758789063,-132.70761108398,27.153547286987}, 
    {609.37469482422,-559.22979736328,15.672647476196}, 
    {-1804.85,558.45,34.15}, 
    {-752.6,-131.6,64.8}, 
} 
progreso = 0 
  
function getNewLocation ( player, seat ) 
    local vehicle = getPedOccupiedVehicle ( player ) 
    local id = getElementModel ( vehicle ) 
if (getElementModel(source) == 448 ) and ( getElementModel (player) == 155 ) then 
if isTimer ( myTimer ) then 
killTimer ( myTimer ) 
end 
end 
    if ( id == 448 ) and ( seat == 0 ) and ( progreso == 0 ) then 
        outputChatBox ( "[iNFO]Ve a la pizza para ganar $",255,255,0 ) 
        local num = math.random ( #markersPosition ) 
        marker = createMarker ( markersPosition [ num ] [ 1 ], markersPosition [ num ] [ 2 ], markersPosition [ num ] [ 3 ], "cylinder", 3.5, 255, 255, 0 ) 
        blip = createBlipAttachedTo ( marker, 51 ) 
        progreso = 1 
        addEventHandler ( "onClientMarkerHit", marker,                 
            function ( hitElement ) 
                if ( hitElement and getElementType ( hitElement ) == "player" and hitElement == localPlayer ) then 
  
                    destroyElement ( marker ) 
                    destroyElement ( blip ) 
 outputChatBox ( "[iNFO]Entregaste una pizza y ganaste $2000 ",255,255,0 ) 
                   triggerServerEvent("dinerito", player, "dinero") 
                    setTimer ( getNewLocation, 2000, 1, localPlayer, seat ) 
                end 
            end 
        ) 
end 
end 
addEventHandler ( "onClientVehicleEnter", root, getNewLocation ) 
  
  
function removebeagle ( thePlayer, seat, jacked ) 
    outputChatBox ("Tienes 10 Segundos para volver al vehiculo si no perderas la mision",255,255,0 ) 
    if isTimer(myTimer) then return end 
               myTimer = setTimer ( function(player) 
        outputChatBox ( "[EMPLEO]Mision Fracasada!!!",255,255,0 ) 
        if isElement(marker) and isElement(blip) then 
destroyElement ( marker ) 
destroyElement ( blip ) 
progreso = 0 
        end 
        end, 10000, 1 ) 
end 
addEventHandler ( "onClientVehicleExit", getRootElement(), removebeagle ) 
  

Link to comment
Te fixié unos cuantos debugs:
  
local markersPosition = { 
    {1715.3720703125, -2138.09375, 12.546875}, 
    {1684.328125, -2086.080078125, 12.546875}, 
    {2454.8046875, -1708.7099609375, 12.61628818512}, 
    {1938.380859375, -1066.4912109375, 23.417552947998}, 
    {1321.353515625, -1075.5107421875, 28.1796875}, 
    {662.88385009766,-1487.4228515625,13.8515625}, 
    {824.06341552734,-849.47668457031,68.921806335449}, 
    {1271.7863769531,294.98532104492,19.656307220459}, 
    {2314.1171875,56.500453948975,25.480714797974}, 
    {2273.2758789063,-132.70761108398,27.153547286987}, 
    {609.37469482422,-559.22979736328,15.672647476196}, 
    {-1804.85,558.45,34.15}, 
    {-752.6,-131.6,64.8}, 
} 
progreso = 0 
  
function getNewLocation ( player, seat ) 
    local vehicle = getPedOccupiedVehicle ( player ) 
    local id = getElementModel ( vehicle ) 
if (getElementModel(source) == 448 ) and ( getElementModel (player) == 155 ) then 
if isTimer ( myTimer ) then 
killTimer ( myTimer ) 
end 
end 
    if ( id == 448 ) and ( seat == 0 ) and ( progreso == 0 ) then 
        outputChatBox ( "[iNFO]Ve a la pizza para ganar $",255,255,0 ) 
        local num = math.random ( #markersPosition ) 
        marker = createMarker ( markersPosition [ num ] [ 1 ], markersPosition [ num ] [ 2 ], markersPosition [ num ] [ 3 ], "cylinder", 3.5, 255, 255, 0 ) 
        blip = createBlipAttachedTo ( marker, 51 ) 
        progreso = 1 
        addEventHandler ( "onClientMarkerHit", marker,                 
            function ( hitElement ) 
                if ( hitElement and getElementType ( hitElement ) == "player" and hitElement == localPlayer ) then 
  
                    destroyElement ( marker ) 
                    destroyElement ( blip ) 
 outputChatBox ( "[iNFO]Entregaste una pizza y ganaste $2000 ",255,255,0 ) 
                   triggerServerEvent("dinerito", player, "dinero") 
                    setTimer ( getNewLocation, 2000, 1, localPlayer, seat ) 
                end 
            end 
        ) 
end 
end 
addEventHandler ( "onClientVehicleEnter", root, getNewLocation ) 
  
  
function removebeagle ( thePlayer, seat, jacked ) 
    outputChatBox ("Tienes 10 Segundos para volver al vehiculo si no perderas la mision",255,255,0 ) 
    if isTimer(myTimer) then return end 
               myTimer = setTimer ( function(player) 
        outputChatBox ( "[EMPLEO]Mision Fracasada!!!",255,255,0 ) 
        if isElement(marker) and isElement(blip) then 
destroyElement ( marker ) 
destroyElement ( blip ) 
progreso = 0 
        end 
        end, 10000, 1 ) 
end 
addEventHandler ( "onClientVehicleExit", getRootElement(), removebeagle ) 
  

Funciona :) gracias men , y solid tambien xD

Link to comment
  • Recently Browsing   0 members

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