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 )