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
Line 13: Line 13:


== Example ==
== Example ==
The following example will set a player's immunity to whatever % you type want.
 
<source lang=squirrel>
<source lang=squirrel>
function onPlayerCommand( player, cmd, text );
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "immunity" )
{
{
if ( cmd == "im" )
MessagePlayer("Now you are immune to bullet/fire/explosion/collision/melee",player);
{
player.Immunity = 31;
if (!text) ClientMessage("/im <Nick> <Immunity>",player,255,255,0);
}
else
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
local im = GetTok( text, " ", 2, NumTok( text, " " ) );
plr.Immunity = im.tointeger();
ClientMessageToAll(player.Name+" has set "+plr.Name+"'s immunity to "+im+"!",198,213,0);
}
}
}
}
</source>
</source>
=== Notes ===
Call [[onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
Call [[ClientMessage]] were used in this example. More info about them in the corresponding pages.
Call [[ClientMessageToAll]] were used in this example. More info about them in the corresponding pages.

Revision as of 19:18, 27 August 2015

This function will set a player's immunity to whatever % you type want.

Syntax

Player.Immunity = flags;

Flags

1 = bulletproof | 2 = fireproof | 4 = explosion-proof | 8 = collision-proof | 16 = melee-proof

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.

Example

function onPlayerCommand( player, cmd, text )
{
if ( cmd == "immunity" )
{
MessagePlayer("Now you are immune to bullet/fire/explosion/collision/melee",player);
player.Immunity = 31;
}
}