Jump to content

Immortality


DjMixCuma

Recommended Posts

Posted

You mean invulnerable player.

  • Toggle damage command: /togdamage

-- Check if the player is invulnerable 
addEventHandler("onClientPlayerDamage", localPlayer, 
    function(attacker, weapon, bodypart, loss) 
        if isPlayerInvulnerable(source) then 
            cancelEvent() 
        end 
    end 
) 
  
-- Command to toggle vulnerability 
addCommandHandler("togdamage", 
    function(cmd) 
        togglePlayerDamage(localPlayer) 
    end 
) 
  
-- Checking if the player is invulnerable 
function isPlayerInvulnerable(player) 
    if player then 
        if getElementData(player, "player.invulnerable") and getElementData(player, "player.invulnerable") == true then 
            return true 
        else 
            return false 
        end 
    end 
end 
  
-- Set the player either invulnerable or vulnerable 
function togglePlayerDamage(player) 
    if player then 
        if isPlayerInvulnerable(player) then 
            setElementData(player, "player.invulnerable", true, true) 
        else 
            setElementData(player, "player.invulnerable", false, true) 
        end 
    end 
end 

Not tested.

If I helped you, please click the like button on the right ;) Thanks!

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...