TalatPlays Posted September 15, 2017 Share Posted September 15, 2017 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
DNL291 Posted September 16, 2017 Share Posted September 16, 2017 Replace 'player' with 'localPlayer'. 1 Link to comment
TalatPlays Posted September 16, 2017 Author Share Posted September 16, 2017 (edited) 8 minutes ago, DNL291 said: Replace 'player' with 'localPlayer'. it's working Thank you very much Edited September 16, 2017 by Moha|M| Link to comment
TalatPlays Posted September 16, 2017 Author Share Posted September 16, 2017 (edited) 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 September 16, 2017 by Moha|M| Link to comment
Dimos7 Posted September 16, 2017 Share Posted September 16, 2017 getScreenFromWorldPosition isLineOfSightClear 1 Link to comment
Rockyz Posted September 16, 2017 Share Posted September 16, 2017 1 hour ago, Moha|M| said: 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") https://wiki.multitheftauto.com/wiki/DxDrawTextOnElement 1 Link to comment
TalatPlays Posted September 16, 2017 Author Share Posted September 16, 2017 thank you all Link to comment
TalatPlays Posted September 16, 2017 Author Share Posted September 16, 2017 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 ) 1 Link to comment
Sami_~> Posted September 17, 2017 Share Posted September 17, 2017 (edited) 7 hours ago, Moha|M| said: ----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) add a 10 sec of timer to disable death match Edited September 17, 2017 by Sami_~> Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now