Scripting/Squirrel/Functions/Player.Health

From Vice City Multiplayer
Revision as of 08:06, 25 July 2014 by Mariu22S (talk | contribs) (Created page with "== Syntax == <pre>player.Health</pre> <source lang=squirrel> function onPlayerCommand( player, cmd, text ); if ( cmd == "heal" ) { local health = player.Health; if ( h...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

Syntax

player.Health
function onPlayerCommand( player, cmd, text );
	if ( cmd == "heal" )
	{
		local health = player.Health;
		if ( health < 100 )
		{
			// calculate the cost based 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] buy heal [#ffffff](Cost: $" + cost + ")" );
			}
			else MessagePlayer( "[#ffffff]Your no money (Cost: $" + cost + ")", player );
		}
		else MessagePlayer( "[#ffffff]You heve 100hp :)", player );
	}

Notes

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