Jokeℝ1472771893 Posted May 15, 2012 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?
TAPL Posted May 15, 2012 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)
Jokeℝ1472771893 Posted May 15, 2012 Author Posted May 15, 2012 its in ACL need to be Admin or need to be in Staff Team?
TAPL Posted May 15, 2012 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.
Jokeℝ1472771893 Posted May 15, 2012 Author 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
TAPL Posted May 15, 2012 Posted May 15, 2012 did you type in F8 gostaff ? did you see this in chat (Staff Mode is now on.) ?
Jokeℝ1472771893 Posted May 15, 2012 Author Posted May 15, 2012 did you type in F8 gostaff ?did you see this in chat (Staff Mode is now on.) ? yes
Castillo Posted May 15, 2012 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
Castillo Posted May 15, 2012 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.
Jokeℝ1472771893 Posted May 15, 2012 Author 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>
TAPL Posted May 15, 2012 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
Jokeℝ1472771893 Posted May 15, 2012 Author Posted May 15, 2012 yeh thnx i dont die but player who shot me dont loose health too what can i do?
TAPL Posted May 15, 2012 Posted May 15, 2012 hmmmmm i think you need to use setElementHealth from server side
Jokeℝ1472771893 Posted May 16, 2012 Author Posted May 16, 2012 where i add that? setElementHealth ( attacker, getElementHealth ( attacker ) - 10 )
Castillo Posted May 17, 2012 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.
Jokeℝ1472771893 Posted May 17, 2012 Author 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
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