Scripting/Squirrel/Functions/Player.Health: 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
Line 12: Line 12:
if ( health < 100 )
if ( health < 100 )
{
{
// calculate the cost based on their health
// calculate the cost depends on their health
local cost = ( ( 250 / 100 ) * ( 100 - health ) );
local cost = ( ( 250 / 100 ) * ( 100 - health ) );
if ( player.Cash >= cost )
if ( player.Cash >= cost )
Line 19: Line 19:
stats[ player.ID ].Cash -= cost;
stats[ player.ID ].Cash -= cost;
player.Health = 100;
player.Health = 100;
Message( "[#DC26FF] Player [#ffffff][ " + player.Name + " ] [#DC26FF] buy heal [#ffffff](Cost: $" + cost + ")" );
Message( "[#DC26FF] Player [#ffffff][ " + player.Name + " ] [#DC26FF] has bought heal [#ffffff](Cost: $" + cost + ")" );
}
}
else MessagePlayer( "[#ffffff]Your no money (Cost: $" + cost + ")", player );
else MessagePlayer( "[#ffffff]You dont have enough money (Cost: $" + cost + ")", player );
}
}
else MessagePlayer( "[#ffffff]You heve 100hp :)", player );
else MessagePlayer( "[#ffffff]You Already Having 100hp :)", player );
}
}



Revision as of 17:39, 27 February 2015


This page needs a description, or needs a better one. Please help us complete the wiki by writing one.


Syntax

player.Health

Example

function onPlayerCommand( player, cmd, text );
	if ( cmd == "heal" )
	{
		local health = player.Health;
		if ( health < 100 )
		{
			// calculate the cost depends on their health
			local cost = ( ( 250 / 100 ) * ( 100 - health ) );
			if ( player.Cash >= cost )
			{
				player.Cash -= cost;
				stats[ player.ID ].Cash -= cost;
				player.Health = 100;
				Message( "[#DC26FF] Player [#ffffff][ " + player.Name + " ] [#DC26FF] has bought heal [#ffffff](Cost: $" + cost + ")" );
			}
			else MessagePlayer( "[#ffffff]You dont have enough money (Cost: $" + cost + ")", player );
		}
		else MessagePlayer( "[#ffffff]You Already Having 100hp :)", player );
	}

Notes

Call onPlayerCommand were used in this example. More info about them in the corresponding pages.