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
(Created page with "This function will ,make a player immune. == Syntax == '''1''' <pre>player.Immunity = //Amount here, Max 255.</pre> == Arguments == '''1''' * ''player'' <= This will find...")
 
mNo edit summary
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This function will ,make a player immune.
This function is used to get or set a player's immunity.


== Syntax ==
== Syntax ==


'''1'''
<pre>player.Immunity = //Amount here, Max 255.</pre>


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


'''1'''
== Flags ==
* ''player'' <= This will find the player.
 
* ''Immunity'' <= This is the immunity you need to set.
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 ==
== Example ==
The following example will make a player's immunity 255%
 
<source lang=squirrel>
<source lang=squirrel>
function onPlayerCommand( player, cmd, text );
function onPlayerCommand( player, cmd, text )
{
{
if ( cmd == "im" )
if ( cmd == "showimmunity" )
{
{
if (!text) ClientMessage("/"+cmd+" <Nick> <Immunity>",255,255,0);
/* Show your immunity */
else
MessagePlayer( "Your immunity: "+ player.Immunity, player );
{
}
local plr = GetPlayer(GetTok( text, " ", 1)
else if ( cmd == "setimmunity" )
local im = GetTok( text, " ", 2)
{
ClientMessage(player.Name+" has set "+plr.Name+"'s immunity to "+im+"!",198,213,0);
/* You can also add up the numbers such as ( 1 + 2 + 4 + 6 + 8 + 16 ) is equal to 31 */
plr.Immunity = im
player.Immunity = ( 1 | 2 | 4 | 8 | 16 );
}
MessagePlayer( "You are now immune to bullet, fire, explosion, collision and melee", player );
}
}
}
</source>
</source>
==Notice==
Even in singleplayer Vice City, any immunity value is known to not work with M60, Revolver, Helicannon.
So, you will need to implement some changes on onPlayerHealthChange( player, lastHP, newHP ) , to create a anti spawn system correctly.
== Related Functions ==


=== Notes ===
{{Scripting/Squirrel/Functions/Player_Functions}}
Call [[onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
[[Category:Scripting/Squirrel/Functions/Player_Functions]]

Latest revision as of 20:20, 18 February 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 );
	}
}

Notice

Even in singleplayer Vice City, any immunity value is known to not work with M60, Revolver, Helicannon.

So, you will need to implement some changes on onPlayerHealthChange( player, lastHP, newHP ) , to create a anti spawn system correctly.

Related Functions

Player Game Functions

These functions exist for compatibility with the R2 Squirrel server.