Destroyer.- Posted January 23, 2015 Posted January 23, 2015 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 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
Destroyer.- Posted January 23, 2015 Author Posted January 23, 2015 Algun error en el debugscript? No no da ninguno, es que cuando yo me salgo del vehiculo lo que quiero que haga es que me de 10 segundos para regresar , y si no regres oen esos 10 segundos fracase la mision, y quiero que si se metio devuelta al vehiculo se cansele el timer
Castillo Posted January 23, 2015 Posted January 23, 2015 Tu timer es local, osea que no existe fuera de esa funcion. Tenes que borrar el "local" al definirlo.
Destroyer.- Posted January 23, 2015 Author Posted January 23, 2015 NO no funciona , lo que quiero hacer es que cuando entre al vehiculo despues de salir se destruya el timer pero no se commo hacerlo , osea nose como hacerlo que al entrar al vehiculo se cancele ese timer que hice
Castillo Posted January 23, 2015 Posted January 23, 2015 Si queres hacer eso, porque nunca estas usando killTimer para matar el temporizador? usa isTimer para verificar que exista.
Destroyer.- Posted January 23, 2015 Author Posted January 23, 2015 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
Castillo Posted January 23, 2015 Posted January 23, 2015 isTimer devuelve true o false, tenes que definir el timer en setTimer.
Destroyer.- Posted January 23, 2015 Author Posted January 23, 2015 Me darias un ejemplo por que me sigue dando error y no anda la function
Destroyer.- Posted January 23, 2015 Author Posted January 23, 2015 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?
Tomas Posted January 23, 2015 Posted January 23, 2015 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 )
Destroyer.- Posted January 23, 2015 Author Posted January 23, 2015 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
Recommended Posts