Jump to content

No deathmatch with VehicelDamageProof


TalatPlays

Recommended Posts

Hello all 

yesterday i find a script in Mta furom and i edited it and it's working 100%

but the problem is it sets godmode for a  Player  only ! 

i want  it to set godmode for player also vehicles  so the player's car will not exploded by any other player

so any help please i will very apreaciate it ?

 

 

Here's The code it's Client :

 

 

GUIEd itor = {
    checkbox = {},
    label = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        GUIEditor.label[1] = guiCreateLabel(540, 98, 145, 14, "     Disable Deathmatch", false)


        GUIEditor.checkbox[1] = guiCreateCheckBox(606, 112, 15, 15, "", false, false)

        GUIEditor.label[2] = guiCreateLabel(-50, -13, 123, 13, "", false, GUIEditor.checkbox[1])   
        addEventHandler("onClientGUIClick",GUIEditor.checkbox[1], checkBox, false)         
    end
)


function checkBox() 
        if ( guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then 
        setElementData(localPlayer, "invincible", true) 
        setVehicleDamageProof(getPedOccupiedVehicle(player),true) 

        else 
        setElementData(localPlayer, "invincible", false) 
            setVehicleDamageProof(getPedOccupiedVehicle(player),false) 
    end 
end 
  


addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(source,"invincible") then 
            cancelEvent() 
        end 
end) 

Link to comment

one more thing please  how do can i set a dxDrawtext on top positon of a player (head)

i added this but it's not working :           dxDrawText("Disabled death match ! (Cannot die)",sx,sy-30,sx,sy-30,tocolor(255,0,0),1.1,"default-bold","center","center")

Edited by Moha|M|
Link to comment

Here's the full script if anyone is interrested  : 

----Client--

GUIEditor = {
    checkbox = {},
    label = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        GUIEditor.label[1] = guiCreateLabel(614, 118, 130, 14, "Disable deathmatch", false)


        GUIEditor.checkbox[1] = guiCreateCheckBox(593, 117, 17, 15, "", false, false)    
		addEventHandler("onClientGUIClick",GUIEditor.checkbox[1], checkBox, false)
    end
)  
 

function checkBox() 
        if ( guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then 
        setElementData(localPlayer, "invincible", true) 
		setVehicleDamageProof(getPedOccupiedVehicle(localPlayer),true) 
        else 
        setElementData(localPlayer, "invincible", false) 
		    setVehicleDamageProof(getPedOccupiedVehicle(localPlayer),false) 
    end 
end 


addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(source,"invincible") then 
            cancelEvent() 
        end 
end) 

addEventHandler("onClientPlayerStealthKill",localPlayer,
function ()
    if getElementData(source,"invencible") then
        cancelEvent()
    end
end)


function renderDeathmatchTag()
	local streamedPlayers = getElementsByType ("player", root, true)
	if streamedPlayers and #streamedPlayers ~= 0 then
		local lpos = {getElementPosition(localPlayer)}
		for _,p in ipairs (streamedPlayers) do
			if p and isElement (p) then
				if getElementData (p, "invincible") then
					local ppos = {getElementPosition(p)}
					if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then
						local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2)
						if x and y then
							dxDrawText ("Disabled deathmatch ! (Can't die)", x, y, x, y, tocolor (255,0,0), 0.5, "bankgothic", "center")
						end
					end
				end
			end
		end
	end
end
addEventHandler ("onClientRender", root, renderDeathmatchTag)
--------Server

function disableWeaponOnGodMod (prev,new) 
    if getElementData(localPlayer, "invincible") then 
            setPedWeaponSlot(localPlayer, 0)
            setVehicleDamageProof ( root, true ) 	
    end 
end 
addEventHandler ( "onClientRender", root, disableWeaponOnGodMod )

 

  • Like 1
Link to comment
7 hours ago, Moha|M| said:
  1. ----Client--
  2.  
  3. GUIEditor = {
  4. checkbox = {},
  5. label = {}
  6. }
  7. addEventHandler("onClientResourceStart", resourceRoot,
  8. function()
  9. GUIEditor.label[1] = guiCreateLabel(614, 118, 130, 14, "Disable deathmatch", false)
  10.  
  11.  
  12. GUIEditor.checkbox[1] = guiCreateCheckBox(593, 117, 17, 15, "", false, false)
  13. addEventHandler("onClientGUIClick",GUIEditor.checkbox[1], checkBox, false)
  14. end
  15. )
  16.  
  17.  
  18. function checkBox()
  19. if ( guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then
  20. setElementData(localPlayer, "invincible", true)
  21. setVehicleDamageProof(getPedOccupiedVehicle(localPlayer),true)
  22. else
  23. setElementData(localPlayer, "invincible", false)
  24. setVehicleDamageProof(getPedOccupiedVehicle(localPlayer),false)
  25. end
  26. end
  27.  
  28.  
  29. addEventHandler ( "onClientPlayerDamage",localPlayer,
  30. function ()
  31. if getElementData(source,"invincible") then
  32. cancelEvent()
  33. end
  34. end)
  35.  
  36. addEventHandler("onClientPlayerStealthKill",localPlayer,
  37. function ()
  38. if getElementData(source,"invencible") then
  39. cancelEvent()
  40. end
  41. end)
  42.  
  43.  
  44. function renderDeathmatchTag()
  45. local streamedPlayers = getElementsByType ("player", root, true)
  46. if streamedPlayers and #streamedPlayers ~= 0 then
  47. local lpos = {getElementPosition(localPlayer)}
  48. for _,p in ipairs (streamedPlayers) do
  49. if p and isElement (p) then
  50. if getElementData (p, "invincible") then
  51. local ppos = {getElementPosition(p)}
  52. if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then
  53. local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2)
  54. if x and y then
  55. dxDrawText ("Disabled deathmatch ! (Can't die)", x, y, x, y, tocolor (255,0,0), 0.5, "bankgothic", "center")
  56. end
  57. end
  58. end
  59. end
  60. end
  61. end
  62. end
  63. addEventHandler ("onClientRender", root, renderDeathmatchTag)

add a 10 sec of timer to disable death match

Edited by Sami_~>
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...