wambosf Posted January 22, 2017 Share Posted January 22, 2017 (edited) Hola a todos, soy muy novato en esto del scripting. Hace unos días trato de incorporar una opción de modo pasivo en F1, algunos sabrán lo que es el Modo pasivo (Si te activas esto estás completamente fuera del deathmatch, nadie te puede matar y tu tampoco puedes hacerlo), y bueno, he tratado de hacerlo en una checkbox, de forma sencilla, pero una vez activado ya no se puede desactivar. Y nosé como puedo hacer que al desmarcar la checkbox, se vuelva al modo normal (deathmatch) y aparezca un mensaje en el Chatbox de "Modo Pasivo desactivado". Por favor necesito si alguien me puede ayudar, o sugerir algo, llevo todo el día de ayer y hoy intentándolo pero nada. --------------------------- -- Pasive Mode Player --------------------------- addEventHandler ("onClientPlayerDamage",getRootElement(),function(attacker,weapon,bodypart) if attacker then if getElementData (attacker,"antidm") ==true or getElementData(source,"antidm")==true then cancelEvent() end end end) --------------------------- -- Pasive Mode Vehicles --------------------------- addEventHandler ("onClientVehicleDamage",getRootElement(),function(theAttacker,theWeapon) if theAttacker then if getVehicleOccupant (source,0) then if getElementData (theAttacker,"antidm") or getElementData (getVehicleOccupant(source,0),"antidm") then cancelEvent() end end end end) --------------------------- --Pasive Mode --------------------------- function togglePasiveMode () guiCheckBoxSetSelected(getControl(wndMain, 'pasivo')) setElementData(source,"antidm",true) toggleControl (source, "fire", false) toggleControl (source, "aim_weapon", false) outputChatBox ("Modo Pasivo exitosamente activado!",0,255,0) end Todo esto lo puse dentro del fr_client.lua, y esto es lo que edité de él: {'chk', id='lightson', text='Lights on', onclick=forceLightsOn}, {'chk', id='lightsoff', text='Lights off', onclick=forceLightsOff}, {'chk', id='pasivo', text='Modo Pasivo', onclick=togglePasiveMode}, Muchas gracias de antemano! Edited January 22, 2017 by wambosf Link to comment
#Dv^ Posted January 22, 2017 Share Posted January 22, 2017 (edited) Debes usar la función guiCheckBoxGetSelected para comprobar si está en modo "true" o "false" la GUI if guiCheckBoxGetSelected(getControl(wndMain, 'pasivo'), true) then Y si está en false entonces cambia el elementData a false setElementData(source,"antidm",false) Así if guiCheckBoxGetSelected(getControl(wndMain, 'pasivo'), true) then setElementData(localPlayer, "antidm", true) else setElementData(localPlayer, "antidm", false) end Edited January 22, 2017 by #Dv^ Link to comment
wambosf Posted January 22, 2017 Author Share Posted January 22, 2017 20 minutes ago, #Dv^ said: Debes usar la función guiCheckBoxGetSelected para comprobar si está en modo "true" o "false" la GUI if guiCheckBoxGetSelected(getControl(wndMain, 'pasivo'), true) then Y si está en false entonces cambia el elementData a false setElementData(source,"antidm",false) Así if guiCheckBoxGetSelected(getControl(wndMain, 'pasivo'), true) then setElementData(localPlayer, "antidm", true) else setElementData(localPlayer, "antidm", false) end Muchísimas gracias men, me sirvió mucho! Pero una consulta, para colcarle un settimer como tendría que hacerlo? Para evitar que los jugadores activen esa opción muy rápido y no sea una molestia Link to comment
#Dv^ Posted January 22, 2017 Share Posted January 22, 2017 Usa esto para evitar que presionen muchas veces guiSetEnabled(getControl(wndMain, 'pasivo'), false) setTimer( function () guiSetEnabled(getControl(wndMain, 'pasivo'), true) end, 8000, 1) Link to comment
wambosf Posted January 23, 2017 Author Share Posted January 23, 2017 On 22/1/2017 at 17:50, #Dv^ said: Usa esto para evitar que presionen muchas veces guiSetEnabled(getControl(wndMain, 'pasivo'), false) setTimer( function () guiSetEnabled(getControl(wndMain, 'pasivo'), true) end, 8000, 1) Lo pongo en otra función aparte? Link to comment
Rose Posted January 23, 2017 Share Posted January 23, 2017 @wambosf debes colocarlo en la parte donde activas el modo pasivo Link to comment
#Dv^ Posted January 24, 2017 Share Posted January 24, 2017 if guiCheckBoxGetSelected(getControl(wndMain, 'pasivo'), true) then setElementData(localPlayer, "antidm", true) guiSetEnabled(getControl(wndMain, 'pasivo'), false) setTimer( function () guiSetEnabled(getControl(wndMain, 'pasivo'), true) end, 8000, 1) else setElementData(localPlayer, "antidm", false) guiSetEnabled(getControl(wndMain, 'pasivo'), false) setTimer( function () guiSetEnabled(getControl(wndMain, 'pasivo'), true) end, 8000, 1) end 1 Link to comment
wambosf Posted January 27, 2017 Author Share Posted January 27, 2017 Muchísimas gracias @#Dv^ @Hit+ cómo puedo borrar el tópico? Link to comment
Rose Posted January 27, 2017 Share Posted January 27, 2017 4 hours ago, wambosf said: Muchísimas gracias @#Dv^ @Hit+ cómo puedo borrar el tópico? Tiene que borrarlo un moderador (si ya lo solucionaste colocale [SOLUCIONADO], si quieres). Link to comment
Recommended Posts