Narutimmy Posted November 11, 2014 Share Posted November 11, 2014 Hola intento hacer un anti Quiteros... pero nose porque no funciona el timmer Marcado, se queda en 59 y no baja function outputChange(dataName,oldValue) local Danado = getElementData(source,"Danado") or false if getElementType(source) == "player" and dataName == "blood" then local newValue = getElementData(source,dataName) if newValue-oldValue < 0 then if Danado == false then local time = getRealTime() setElementData ( source, "attacked", time.timestamp ) setElementData ( source, "Contador", 60 ) triggerClientEvent(source, "displayClientInfo", source, "Info", "Has Recibido Daño, espera 1 Minuto.", 200, 200, 22) setTimer ( triggerClientEvent, 60000, 1, source, "displayClientInfo", source, "Info", "Ya Puedes Desconectar.", 200, 200, 22 ) setTimer ( setElementData, 60000, 1, source, "Danado", false) setElementData(source,"Danado",true) Tiimer = getElementData(source,"Contador") setTimer ( setElementData, 1000, 60, source, "Contador", Tiimer-1 ) -- <== setTimer ( setElementData, 60000, 1, source, "Contador", 0 ) end end end end addEventHandler("onElementDataChange",getRootElement(),outputChange) Cuando deberia llegar a 0 , Gracias por la ayuda. Link to comment
MTA Team 0xCiBeR Posted November 12, 2014 MTA Team Share Posted November 12, 2014 Tenes que pasar source a source. Source como tal no existe dentro del timer. EJ: function outputChange(dataName,oldValue) local Danado = getElementData(source,"Danado") or false if getElementType(source) == "player" and dataName == "blood" then local newValue = getElementData(source,dataName) if newValue-oldValue < 0 then if Danado == false then local time = getRealTime() setElementData ( source, "attacked", time.timestamp ) setElementData ( source, "Contador", 60 ) triggerClientEvent(source, "displayClientInfo", source, "Info", "Has Recibido Daño, espera 1 Minuto.", 200, 200, 22) newSource = source setTimer ( triggerClientEvent, 60000, 1, newSource, "displayClientInfo", newSource, "Info", "Ya Puedes Desconectar.", 200, 200, 22 ) setTimer ( setElementData, 60000, 1, newSource, "Danado", false) setElementData(source,"Danado",true) Tiimer = getElementData(source,"Contador") setTimer ( setElementData, 1000, 60, newSource, "Contador", Tiimer-1 ) -- <== setTimer ( setElementData, 60000, 1, newSource, "Contador", 0 ) end end end end addEventHandler("onElementDataChange",getRootElement(),outputChange) Link to comment
Narutimmy Posted November 12, 2014 Author Share Posted November 12, 2014 Tenes que pasar source a source.Source como tal no existe dentro del timer. EJ: function outputChange(dataName,oldValue) local Danado = getElementData(source,"Danado") or false if getElementType(source) == "player" and dataName == "blood" then local newValue = getElementData(source,dataName) if newValue-oldValue < 0 then if Danado == false then local time = getRealTime() setElementData ( source, "attacked", time.timestamp ) setElementData ( source, "Contador", 60 ) triggerClientEvent(source, "displayClientInfo", source, "Info", "Has Recibido Daño, espera 1 Minuto.", 200, 200, 22) newSource = source setTimer ( triggerClientEvent, 60000, 1, newSource, "displayClientInfo", newSource, "Info", "Ya Puedes Desconectar.", 200, 200, 22 ) setTimer ( setElementData, 60000, 1, newSource, "Danado", false) setElementData(source,"Danado",true) Tiimer = getElementData(source,"Contador") setTimer ( setElementData, 1000, 60, newSource, "Contador", Tiimer-1 ) -- <== setTimer ( setElementData, 60000, 1, newSource, "Contador", 0 ) end end end end addEventHandler("onElementDataChange",getRootElement(),outputChange) No ententi mucho, pero eso es para Sv, pero y para cliente? es igual? probare... --------------------------------------------------------------- function playerGetDamageDayZ ( attacker, weapon, bodypart, loss ) if getElementData ( localPlayer, "PVP" ) or false == false then if weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then setTimer (outputChatBox, 30000, 1, "Ya puedes desconectarte",255,5,0) setTimer ( setElementData, 30000, 1, localPlayer, "PVP", false ) setTimer ( setElementData, 30000, 1, localPlayer, "Contador", 0 ) setElementData ( localPlayer, "PVP", true ) setElementData ( localPlayer, "Contador", 30 ) setTimer ( setElementData, 1000, 60, localPlayer, "Contador", getElementData(localPlayer,"Contador")-1 ) outputChatBox ( "Recibiste daño, no puedes desconectare hasta que pasen 30 segundos!", 255, 5, 0 ) setTimer ( function (localPlayer) Dano = getElementData(localPlayer,"Contador") setElementData(localPlayer,"Contador",Dano-1) end , 1000, 60 ) end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer (), playerGetDamageDayZ ) Link to comment
Tomas Posted November 12, 2014 Share Posted November 12, 2014 Está en Client-side, mira el evento. Link to comment
Narutimmy Posted November 12, 2014 Author Share Posted November 12, 2014 Está en Client-side, mira el evento. Por eso el segundo qu publique es otro EDIT: Todo funciona menos el contador, el setear PVP en false 30 seg despues funca, el que salga en el chat que puedes desconectar si sale, pero el contador los setea en 30, 29... y ahi se queda no baja mas function playerGetDamageDayZ ( attacker, weapon, bodypart, loss ) if getElementData ( localPlayer, "PVP" ) or false == false then if weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then setTimer (outputChatBox, 30000, 1, "Ya puedes desconectarte",255,5,0) newSource = localPlayer setTimer ( setElementData, 30000, 1, newSource, "PVP", false ) setTimer ( setElementData, 30000, 1, newSource, "Contador", 0 ) setElementData ( localPlayer, "PVP", true ) setElementData ( localPlayer, "Contador", 30 ) outputChatBox ( "Recibiste daño, no puedes desconectare hasta que pasen 30 segundos!", 255, 5, 0 ) Tiimer = getElementData(localPlayer,"Contador") setTimer ( setElementData, 1000, 60, newSource, "Contador", Tiimer-1 ) -- <== setTimer ( setElementData, 30000, 1, newSource, "Contador", 0 ) end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer (), playerGetDamageDayZ ) Link to comment
Recommended Posts