Jump to content

[HELP]How to make Admin never die


Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...