Nyx17 Posted January 31, 2017 Share Posted January 31, 2017 Hola, he intentado hacer que el modo AFK se desactive cuando el jugador haga un click, sin embargo no entiendo como va eso del onPlayerClick Seguramente lo que he modificado ni sentido tiene, me pueden ayudar? Por favor. CLIENT: Spoiler addEvent("god_mode",true) addEventHandler("god_mode",getRootElement(), function () addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelEventEvent) end) addEvent("disable_god_mode",true) addEventHandler ("disable_god_mode", getRootElement(), function() removeEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent) end) function cancelEventEvent () cancelEvent() end ------------------------------ addEvent("click", true) function detectar(player) addEventHandler("click", getRootElement(), detectar) end SERVER: Spoiler addEventHandler("onPlayerJoin",getRootElement(), function () setElementData(source,"afk_state","back") setElementData(source,"HideState","disabled") end) addEvent("click", true) function clicks( button, state, player ) if button == "mouse1" and state "down" then if getElementData(thePlayer,"afk_state") == "back" then triggerClientEvent ("click", thePlayer) triggerClientEvent(thePlayer,"disable_god_mode",thePlayer) setPedFrozen(thePlayer,false) setElementAlpha (thePlayer, 255 ) setElementData(source,"afk_state","back") toggleControl ( thePlayer, "fire", true ) toggleControl ( thePlayer, "aim_weapon", true) toggleControl ( thePlayer, "jump", true ) toggleControl ( thePlayer, "walk", true) toggleControl ( thePlayer, "sprint", true) toggleControl ( thePlayer, "accelerate", true) toggleControl ( thePlayer, "crouch", true) toggleControl ( thePlayer, "fowards", true) toggleControl ( thePlayer, "backwards", true) toggleControl ( thePlayer, "left", true) toggleControl ( thePlayer, "right", true) toggleControl ( thePlayer, "brake", true) toggleControl ( thePlayer, "reverse", true) toggleControl ( thePlayer, "handbrake", true) setPlayerNametagText (thePlayer, "" .. getPlayerName (thePlayer)) outputChatBox(getPlayerName(thePlayer).." is back!",getRootElement(),0,255,0) addEventHandler( "onPlayerClick", getRootElement(), clicks ) if getPedOccupiedVehicle(thePlayer) then setVehicleFrozen(getPedOccupiedVehicle(thePlayer),false) setVehicleDamageProof(getPedOccupiedVehicle(thePlayer),false) end end end addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()), function () for i,v in pairs (getElementsByType("player")) do setElementData(v,"afk_state","back") setElementData(v,"HideState","disabled") end end) addCommandHandler("afk", function (thePlayer) if getElementData(thePlayer,"afk_state") == "back" then triggerClientEvent(thePlayer,"god_mode",thePlayer) setPedFrozen(thePlayer,true) setElementAlpha (thePlayer, 170 ) toggleControl ( thePlayer, "fire", false ) toggleControl ( thePlayer, "aim_weapon", false) toggleControl ( thePlayer, "jump", false ) toggleControl ( thePlayer, "walk", false) toggleControl ( thePlayer, "sprint", false) toggleControl ( thePlayer, "accelerate", false) toggleControl ( thePlayer, "crouch", false) toggleControl ( thePlayer, "fowards", false) toggleControl ( thePlayer, "backwards", false) toggleControl ( thePlayer, "left", false) toggleControl ( thePlayer, "right", false) toggleControl ( thePlayer, "brake", false) toggleControl ( thePlayer, "reverse", false) toggleControl ( thePlayer, "handbrake", false) setPlayerNametagText (thePlayer, "|AFK|" .. getPlayerName (thePlayer)) outputChatBox(getPlayerName(thePlayer).." is AFK!",getRootElement(),255,50,0) setElementData(thePlayer,"afk_state","afk") if getPedOccupiedVehicle(thePlayer) then fixVehicle(getPedOccupiedVehicle(thePlayer),true) setVehicleFrozen(getPedOccupiedVehicle(thePlayer),true) setVehicleDamageProof(getPedOccupiedVehicle(thePlayer),true) end elseif getElementData(thePlayer,"afk_state") == "afk" then setElementData(thePlayer,"afk_state","back") triggerClientEvent(thePlayer,"disable_god_mode",thePlayer) setPedFrozen(thePlayer,false) setElementAlpha (thePlayer, 255 ) toggleControl ( thePlayer, "fire", true ) toggleControl ( thePlayer, "aim_weapon", true) toggleControl ( thePlayer, "jump", true ) toggleControl ( thePlayer, "walk", true) toggleControl ( thePlayer, "sprint", true) toggleControl ( thePlayer, "accelerate", true) toggleControl ( thePlayer, "crouch", true) toggleControl ( thePlayer, "fowards", true) toggleControl ( thePlayer, "backwards", true) toggleControl ( thePlayer, "left", true) toggleControl ( thePlayer, "right", true) toggleControl ( thePlayer, "brake", true) toggleControl ( thePlayer, "reverse", true) toggleControl ( thePlayer, "handbrake", true) setPlayerNametagText (thePlayer, "" .. getPlayerName (thePlayer)) outputChatBox(getPlayerName(thePlayer).." is back!",getRootElement(),0,255,0) if getPedOccupiedVehicle(thePlayer) then setVehicleFrozen(getPedOccupiedVehicle(thePlayer),false) setVehicleDamageProof(getPedOccupiedVehicle(thePlayer),false) end end end) Gracias de antemano. Link to comment
#Dv^ Posted January 31, 2017 Share Posted January 31, 2017 (edited) El evento que quieres usar es onPlayerClick addEventHandler("onPlayerClick", root, function) Edited January 31, 2017 by #Dv^ Link to comment
Recommended Posts