Jump to content

[AYUDA] Implementar Modo Pasivo en F1


wambosf

Recommended Posts

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 by wambosf
Link to comment

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 by #Dv^
Link to comment
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
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
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

 

  • Like 1
Link to comment
  • Recently Browsing   0 members

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