23.08.2013, 16:46
(
Последний раз редактировалось CrazyChoco; 23.08.2013 в 21:50.
)
Well i spotted a issue with your code, instead of
it would be better with:
I hope you see the difference with your code and my code. And the detection to check player health, might not be working correctly.
pawn Код:
CMD:buyhealth(playerid, params[])
{
if(GetPlayerMoney(playerid) > 5500)
{
GivePlayerMoney(playerid, -5500);
}
SetPlayerHealth(playerid,100); // we heal him a.k.a give him full health
SendClientMessage(playerid,-1,"You paid 5500$ to heal your self !");
} else SendClientMessage(playerid,-1,"You don't have 5500$ !");
return 1;
}
pawn Код:
CMD:buyhealth(playerid, params[])
{
if(GetPlayerMoney(playerid) <= 5499) return SendClientMessage(playerid, -1, "You don't have enough cash to buy heal."); //This detects if player have enough money or not. If he don't he can't go to the next step.
else if(GetPlayerMoney(playerid) >= 5500) //Instead of just putting an else statement, I rather prefer to detect if he more than $5500 so it won't be messed up.
{
new string[128]; //It's a string, simple as that.
format(string, sizeof(string), "You have been healed from %f to 100 for $5500!", GetPlayerHealth(playerid)); //We are using the format function, which does formats a string to include variables and other strings inside it.
SendClientMessage(playerid, -1, string); //We are sending the string out to the specfied playerid about the message above.
SetPlayerHealth(playerid, 100); //Set's player health, simple as that.
GivePlayerMoney(playerid, -5500);
}
return true;
}