29.08.2012, 14:48
pawn Код:
CMD:heal(playerid, params[])
{
new Float:Health, tbhealedhealth, healprice, healtime, string[128];
GetPlayerHealth(playerid, Health); //There is no need for the Float: tag, that is only when introducing it. (Eg. new Float:)
tbhealedhealth = 100-Health;
if(IsPlayerInRangeOfPoint(playerid, 5, HealPos1X, HealPos1Y, HealPos1Z)) //I'm assuming you have values for these saved somewhere else.
{
if(Health >= 100) return SendClientMessage(playerid, GREY, "You already have full health.");
if(Health > 40)
{
Player[playerid][HealTime] = tbhealedhealth; //Stores the to be healed health as a time in seconds to a player stat
Player[playerid][HealPrice] = tbhealedhealth*3; //Triples the to be healed health, this is the amount they must pay then stores it to a player stat
Player[playerid][BeingHealed] = 1; //Being healed at hospital 1 (Will put in hospital 2 if this can be fixed)
format(string, sizeof(string), "You are now undergoing hospital treatment. You will be released in %d seconds.", Player[playerid][HealTime]);
SendClientMessage(playerid, -1, string);
SetPlayerPos(playerid, 1161.2238, -1321.6235, 19); // Everything below is just setting cam pos etc. whilst they are in hospital
SetPlayerVirtualWorld(playerid, playerid);
TogglePlayerControllable(playerid, false);
SetPlayerCameraPos(playerid, 1217.4056, -1321.4524, 31.1270);
SetPlayerCameraLookAt(playerid, 1173.2889, -1322.7111, 19.4345);
}
else
{
if(Health >= 1)
{
Player[playerid][HealTime] = tbhealedhealth;
Player[playerid][HealPrice] = tbhealedhealth*6;
Player[playerid][BeingHealed] = 1;
format(string, sizeof(string), "You are now undergoing hospital treatment. You will be released in %d seconds.", Player[playerid][HealTime]);
SendClientMessage(playerid, -1, string);
SetPlayerPos(playerid, 1161.2238, -1321.6235, 19);
SetPlayerVirtualWorld(playerid, playerid);
TogglePlayerControllable(playerid, false);
SetPlayerCameraPos(playerid, 1217.4056, -1321.4524, 31.1270);
SetPlayerCameraLookAt(playerid, 1173.2889, -1322.7111, 19.4345);
}
}
}
return 1;
}