Jokeℝ1472771893 Posted May 15, 2012 Share Posted May 15, 2012 function togglestaffMode(thePlayer) local account = getPlayerAccount(thePlayer) if (not account or isGuestAccount(account)) then return end local accountName = getAccountName(account) if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then if getElementData(thePlayer,"invincible") then setElementData(thePlayer,"invincible",false) outputChatBox("Staff Mode is now off.",thePlayer,255,255,255) else setElementData(thePlayer,"invincible",true) outputChatBox("Staff Mode is now on.",thePlayer,255,255,255) end end end addCommandHandler("gostaff",togglestaffMode) How to make Admins Never Die and the player who whant to kill Admin loose Health? Link to comment
TAPL Posted May 15, 2012 Share Posted May 15, 2012 Server side function togglestaffMode(thePlayer) local account = getPlayerAccount(thePlayer) if (not account or isGuestAccount(account)) then return end local accountName = getAccountName(account) if isObjectInACLGroup("user.".. accountName, aclGetGroup("Admin")) then if getElementData(thePlayer,"invincible") then setElementData(thePlayer,"invincible",false) outputChatBox("Staff Mode is now off.",thePlayer,255,255,255) else setElementData(thePlayer,"invincible",true) outputChatBox("Staff Mode is now on.",thePlayer,255,255,255) end end end addCommandHandler("gostaff",togglestaffMode) Client Side addEventHandler("onClientPlayerDamage",localPlayer, function(attacker) if getElementData(source,"invincible") then setElementHealth(attacker,getElementHealth(attacker)-10) cancelEvent() end end) Link to comment
Jokeℝ1472771893 Posted May 15, 2012 Author Share Posted May 15, 2012 its in ACL need to be Admin or need to be in Staff Team? Link to comment
TAPL Posted May 15, 2012 Share Posted May 15, 2012 its in ACL need to be Admin or need to be in Staff Team? need to be in ACL group Admin. Link to comment
Jokeℝ1472771893 Posted May 15, 2012 Author Share Posted May 15, 2012 its in ACL need to be Admin or need to be in Staff Team? need to be in ACL group Admin. but i try its don't work Link to comment
Jokeℝ1472771893 Posted May 15, 2012 Author Share Posted May 15, 2012 what is not work? players can kill me Link to comment
TAPL Posted May 15, 2012 Share Posted May 15, 2012 did you type in F8 gostaff ? did you see this in chat (Staff Mode is now on.) ? Link to comment
Jokeℝ1472771893 Posted May 15, 2012 Author Share Posted May 15, 2012 did you type in F8 gostaff ?did you see this in chat (Staff Mode is now on.) ? yes Link to comment
Castillo Posted May 15, 2012 Share Posted May 15, 2012 Try this: -- client side: addEventHandler ( "onClientPlayerDamage", localPlayer, function ( attacker ) if getElementData ( source, "invincible" ) then if ( attacker and isElement ( attacker ) and getElementType ( attacker ) == "player" ) then setElementHealth ( attacker, getElementHealth ( attacker ) - 10 ) end cancelEvent ( ) end end ) -- server side: function toggleStaffMode ( thePlayer ) local account = getPlayerAccount ( thePlayer ) if ( not account or isGuestAccount ( account ) ) then return end local accountName = getAccountName ( account ) if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) then local status = ( not getElementData ( thePlayer, "invincible" ) ) setElementData ( thePlayer, "invincible", status ) outputChatBox ( "Staff Mode is now ".. ( status and "On" or "Off" ) ..".", thePlayer, 255, 255, 255 ) end end addCommandHandler ( "staffmode", toggleStaffMode ) Command: /staffmode Link to comment
Castillo Posted May 15, 2012 Share Posted May 15, 2012 Nothing That worked perfectly for me, so it has to work for you as well. As TAPL said, post your "meta.xml" content. Link to comment
Jokeℝ1472771893 Posted May 15, 2012 Author Share Posted May 15, 2012 <meta> <info author="Guso" type="play" name="Gu" description="My first MTA server" /> <script src="staff.lua" /> <script src="team.lua" /> </meta> Link to comment
TAPL Posted May 15, 2012 Share Posted May 15, 2012 you have to write the type of the file client or server if you didn't it will be server "Guso" type="script" name="Gu" description="My first MTA server" /> change "??" to server or client Link to comment
Jokeℝ1472771893 Posted May 15, 2012 Author Share Posted May 15, 2012 yeh thnx i dont die but player who shot me dont loose health too what can i do? Link to comment
TAPL Posted May 15, 2012 Share Posted May 15, 2012 hmmmmm i think you need to use setElementHealth from server side Link to comment
Jokeℝ1472771893 Posted May 16, 2012 Author Share Posted May 16, 2012 where i add that? setElementHealth ( attacker, getElementHealth ( attacker ) - 10 ) Link to comment
Castillo Posted May 17, 2012 Share Posted May 17, 2012 You must use triggerServerEvent on the client side, instead of setElementHealth, and there you trigger the "attacker" argument to server side to take the health. Link to comment
Jokeℝ1472771893 Posted May 17, 2012 Author Share Posted May 17, 2012 You must use triggerServerEvent on the client side, instead of setElementHealth, and there you trigger the "attacker" argument to server side to take the health. ok thnx 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