Jump to content

peace mode help


Samking

Recommended Posts

function centerWindow(center_window) 
    local screenW,screenH=guiGetScreenSize() 
    local windowW,windowH=guiGetSize(center_window,false) 
    local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
    guiSetPosition(center_window,x,y,false) 
end 
  
GUIEditor = { 
    checkbox = {}, 
    staticimage = {}, 
    label = {}, 
    button = {}, 
    window = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(542, 254, 348, 92, "Peacemode Interference", false)		
        centerWindow ( GUIEditor.window[1] ) 
		guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFF0D30E")
        guiWindowSetSizable(GUIEditor.window[1], false) 
        GUIEditor.label[1] = guiCreateLabel(10, 25, 283, 15, "You can enable/disable 'Peacemode'", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[1], "default-bold-small")
        guiLabelSetColor(GUIEditor.label[1], 253, 0, 0)
		GUIEditor.staticimage[1] = guiCreateStaticImage(10, 50, 34, 26, "icon.png", false, GUIEditor.window[1]) 
        GUIEditor.checkbox[1] = guiCreateCheckBox(49, 52, 234, 24, "Enable/Disable peacemode", false, false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.checkbox[1], "default-bold-small")
        guiSetProperty(GUIEditor.checkbox[1], "NormalTextColour", "FF30EB11") 
        GUIEditor.button[1] = guiCreateButton(303, 52, 31, 25, "X", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.button[1], "default-bold-small")
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF1428E7")	
        GUIEditor.label[2] = guiCreateLabel(78, 74, 120, 15, "Romania Chill Nation", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.label[2], "default-bold-small")
        guiLabelSetColor(GUIEditor.label[2], 12, 238, 193)		
        guiSetVisible(GUIEditor.window[1], false) 
        addEventHandler("onClientGUIClick", GUIEditor.button[1], onGuiClick,false) 
        addEventHandler("onClientGUIClick",GUIEditor.checkbox[1], checkBox, false) 
    end 
) 
  
  
addCommandHandler("passive", 
function()
	guiSetVisible(GUIEditor.window[1], true) 
    showCursor(true) 	
end 
) 
  
function onGuiClick() 
    guiSetVisible(GUIEditor.window[1], false) 
    showCursor(false) 
end 
  
  
function checkBox() 
        if ( guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then 
        setElementData(localPlayer, "invincible", true)  
        addEventHandler("onClientRender", root, dxRectangle) 
        else 
        setElementData(localPlayer, "invincible", false)  
        removeEventHandler( "onClientRender", root, dxRectangle ) 
    end 
end 
  
  
addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(source,"invincible") then 
           cancelEvent() 
      end
  end 
) 
  
  
  
function dxRectangle() 
		 dxDrawImage(90, 479, 27, 24, "icon.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)	 
		 dxDrawText("Peacemode Enabled", 123, 485, 294, 497, tocolor(255, 167, 0, 255), 0.70, "bankgothic", "left", "top", false, false, false, false, false) 
    end 
  
function disableWeaponOnGodMod (prev,new) 
    if getElementData(localPlayer, "invincible") then 
       setPedWeaponSlot(localPlayer, 0)	   
	   toggleControl ( "aim_weapon", false)    
       toggleControl ( "fire", false) 
	   toggleControl ( "vehicle_fire", false)
       toggleControl ( "vehicle_secondary_fire", false)	   
  else  
	   toggleControl ( "aim_weapon", true)  
	   toggleControl ( "vehicle_fire", true) 
       toggleControl ( "fire", true)
       toggleControl ( "vehicle_secondary_fire", true)	   
    end 
 end 
addEventHandler ( "onClientRender", root, disableWeaponOnGodMod )

function dmg(player) 
car = getPedOccupiedVehicle ( player) 
   if isVehicleDamageProof(car) == true then 
   setVehicleDamageProof(car, false) 
   else 
        setVehicleDamageProof(car, true)   
   end 
end 
addEventHandler ( "onClientVehicleExplode", root, dmg )

This Code is not made by me

I download this from MTA sa community

How I can make this command /passive 

which only can use by VIP acl group?

Link to comment

You might use something like this server side:

function goPeaceMode(plr)
  if (not hasObjectPermissionTo(plr, "command.passive", false)) then -- You can use whatever action you want instead of 'command.passive'
    return false
  end
  triggerClientEvent(plr, "peaceMode.toggle", resourceRoot)
end
addCommandHandler("passive", goPeaceMode)

 

And client side:

function goPeaceMode()
  guiSetVisible(GUIEditor.window[1], true) 
  showCursor(true)
end
addEvent("peaceMode.toggle", true)
addEventHandler("peaceMode.toggle", resourceRoot, goPeaceMode)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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