stefutz101 Posted August 18, 2015 Share Posted August 18, 2015 Hello , yesterday i work at a script what make de admin invincible ( godmode). I dont have errors or warnings , but i can take damange . Server-side : function setInince(thePlayer) if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then if (getElementData(thePlayer, "INV") == "true") then setElementData(thePlayer,"INV", "false") outputChatBox("You are no longer Invincible", thePlayer) else setElementData(thePlayer,"INV", "true") outputChatBox("You are now Invincible", thePlayer) end else outputChatBox("You do not have permission for this", thePlayer) end end addCommandHandler("inv", setInince) Client-side function noadmdamage() if (getElementData(source, "INV") == "true") then cancelEvent() else end end addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) Link to comment
HUNGRY:3 Posted August 18, 2015 Share Posted August 18, 2015 dayz blood is not like gta blood so try client side function noadmdamage() if getElementData(getLocalPlayer(), "INV") == true then setElementData(getLocalPlayer(),"blood",250000) end end addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) Link to comment
HUNGRY:3 Posted August 18, 2015 Share Posted August 18, 2015 which dayz verison you're using? Link to comment
HUNGRY:3 Posted August 18, 2015 Share Posted August 18, 2015 server: function noDayZAdminDamge(thePlayer) if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then if not getElementData(thePlayer,"inv") == true then setElementData(thePlayer,"inv",true) outputChatBox("You are now Invincible", thePlayer,255,0,0) else setElementData(thePlayer,"inv",false) outputChatBox("You are no longer Invincible", thePlayer,255,0,0) end end end addCommandHandler("inv",noDayZAdminDamge) client function noadmdamage() if getElementData(getLocalPlayer(), "inv") == true then setElementData(getLocalPlayer(),"blood",2500000) end end addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) Link to comment
stefutz101 Posted August 18, 2015 Author Share Posted August 18, 2015 Version 1.4.1-9.07378.0 , i try to change version to 1.5 , didn't work . Server stat in 1.4 , i try to change version in mtaserver.conf or someting like that . I will test now the script , i will edit with the results . Ty Results : the same problem : "I am invincible but if i jump from a house i take damange . Link to comment
t3wz Posted August 18, 2015 Share Posted August 18, 2015 Well i don't know much about Dayz but you can try this: addEventHandler ( "onElementDataChange", root, function ( name, oldValue ) if name == "blood" then setElementData ( source, name, oldValue ) end end ) (serverside) Link to comment
stefutz101 Posted August 18, 2015 Author Share Posted August 18, 2015 All players are invincible now . I must add a "if " with test if localPlayer it's staff . TY But now it work Link to comment
Mr.Loki Posted August 18, 2015 Share Posted August 18, 2015 Well i don't know much about Dayz but you can try this: addEventHandler ( "onElementDataChange", root, function ( name, oldValue ) if name == "blood" then setElementData ( source, name, oldValue ) end end ) (serverside) it will work it will but also cause a C stack overflow It triggers itself over and over because "setElementData ( source, name, oldValue )" triggers onElementDataChange and an overflow = lag Link to comment
t3wz Posted August 18, 2015 Share Posted August 18, 2015 @loki my bad, this should do the trick: addEventHandler ( "onElementDataChange", root, function ( name ) if name == "blood" and getElementData ( source, name ) ~= 99999 then setElementData ( source, name, 99999 ) end end ) Link to comment
Mr.Loki Posted August 18, 2015 Share Posted August 18, 2015 @t3wz it did and @stefutz101 it should be something like this, thanks to t3wz function setInince(thePlayer) if hasObjectPermissionTo(thePlayer, "function.banPlayer") then if getElementData(thePlayer, "INV") then setElementData(thePlayer,"INV", false) outputChatBox("You are no longer Invincible", thePlayer) else setElementData(thePlayer,"INV", true) outputChatBox("You are now Invincible", thePlayer) end else outputChatBox("You do not have permission for this", thePlayer) end end addCommandHandler("inv", setInince) addEventHandler ( "onElementDataChange", root, function ( name ) if getElementData(source, "INV") then if name == "blood" and getElementData ( source, name ) ~= 12000 then setElementData ( source, name, 12000 ) elseif name == "thirst" and getElementData ( source, name ) ~= 100 then setElementData ( source, name, 12000 ) elseif name == "food" and getElementData ( source, name ) ~= 100 then setElementData ( source, name, 100 ) elseif name == "brokenbone" and getElementData ( source, name ) ~= false then setElementData ( source, name, false ) elseif name == "bleeding" and getElementData ( source, name ) ~= 0 then setElementData ( source, name, 0 ) elseif name == "pain" and getElementData ( source, name ) ~= false then setElementData ( source, name, false ) end end end ) everything is server sided Link to comment
stefutz101 Posted August 18, 2015 Author Share Posted August 18, 2015 @ loki2143 I want to make a godmode script for admins , when they are onduty they cant get damange . Thank you , you made my work more easy Now i can do the script . Script work but it calculate the diference between blood verry but verry hard and if someone attack you with m4 you are R.I.P. i will stay at setelementdata(theplayer, "blood" , 99999999999999999999999999) Link to comment
Lawliet Posted August 20, 2015 Share Posted August 20, 2015 Just try this (clientsided): local adminIsInvincible = false function setAdminInvincible(ps) if getElementData(ps,"admin") then if not adminIsInvincible then setElementData(ps,"invincible",true) adminIsInvincible = true outputChatBox("You are invincible.",0,255,0) else setElementData(ps,"invincible",false) adminIsInvincible = false outputChatBox("You are not invincible anymore.",255,0,0) end else outputChatBox("You are not an admin!",255,0,0) end end addCommandHandler("godmode",setAdminInvincible) function actOutInvincibility() if getElementData(source,"invincible") then setElementData(source,"blood",12000) end enda addEventHandler("onClientPlayerDamage",root,actOutInvincibility) The command is /godmode, and you have to be admin (via /add admin ) to become invincible. 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