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 1: Line 1:
This function will set a player's immunity to whatever % you type want.
This function is used to get or set a player's immunity.


== Syntax ==
== Syntax ==




<pre>Player.Immunity = flags;</pre>
<pre>player.Immunity = flags;</pre>


== Flags ==
== Flags ==


1 = bulletproof | 2 = fireproof | 4 = explosion-proof | 8 = collision-proof | 16 = melee-proof
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 to any damage, 31 means immunity to all damage. You can add all the numbers together or use bitwise OR/AND to toggle flags.
0 means no immunity, 127 means full immunity. You can add all the numbers together or use bitwise OR/AND to toggle flags.


== Example ==
== Example ==
Line 17: Line 17:
function onPlayerCommand( player, cmd, text )
function onPlayerCommand( player, cmd, text )
{
{
if ( cmd == "immunity" )
if ( cmd == "showimmunity" )
{
{
MessagePlayer("Now you are immune to bullet/fire/explosion/collision/melee",player);
        /* Show your immunity */
player.Immunity = 31;
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 );
}
}
}
</source>
</source>



Revision as of 13:55, 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.