Scripting/Squirrel/Functions/Player.Immunity: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary
No edit summary
Line 19: Line 19:
if ( cmd == "showimmunity" )
if ( cmd == "showimmunity" )
{
{
        /* Show your immunity */
/* Show your immunity */
MessagePlayer( "Your immunity: "+ player.Immunity, player );
MessagePlayer( "Your immunity: "+ player.Immunity, player );
}
}
else if ( cmd == "setimmunity" )
else if ( cmd == "setimmunity" )
{
{
        /* You can also add up the numbers such as ( 1 + 2 + 4 + 6 + 8 + 16 ) is equal to 31 */
/* You can also add up the numbers such as ( 1 + 2 + 4 + 6 + 8 + 16 ) is equal to 31 */
player.Immunity = ( 1 | 2 | 4 | 8 | 16 );
player.Immunity = ( 1 | 2 | 4 | 8 | 16 );
MessagePlayer( "You are now immune to bullet, fire, explosion, collision and melee", player );
MessagePlayer( "You are now immune to bullet, fire, explosion, collision and melee", player );
}
}
}
}
</source>
</source>



Revision as of 13:59, 30 January 2018

This function is used to get or set a player's immunity.

Syntax

player.Immunity = flags;

Flags

1 = bulletproof | 2 = fireproof | 4 = explosion-proof | 8 = collision-proof | 16 = melee-proof | 32 = immune to falling down | 64 = immune to critical shot/headshot

0 means no immunity, 127 means full immunity. You can add all the numbers together or use bitwise OR/AND to toggle flags.

Example

function onPlayerCommand( player, cmd, text )
{
	if ( cmd == "showimmunity" )
	{
		/* Show your immunity */
		MessagePlayer( "Your immunity: "+ player.Immunity, player );
	}
	else if ( cmd == "setimmunity" )
	{
		/* You can also add up the numbers such as ( 1 + 2 + 4 + 6 + 8 + 16 ) is equal to 31 */
		player.Immunity = ( 1 | 2 | 4 | 8 | 16 );
		MessagePlayer( "You are now immune to bullet, fire, explosion, collision and melee", player );
	}
}

Related Functions

Player Game Functions

These functions exist for compatibility with the R2 Squirrel server.