in OnGameModeInit:
[pawn] AddStaticPickup(5, 431, X, Y, Z); // we have added pickup with id 5 and it's modelid - 431. Add your X, Y, Z coords[/pawn]
in OnPickedUp:
[pawn]
if(pickupid==5) // we check if pickup's id is 5.
{
new pcash = GetPlayerMoney(playerid); // we get player money though "pcash" variable.
new Float:hp; // we create a new float - hp.
GetPlayerHealth(playerid, hp); // we get player health, expressing it in "hp" which we created before.
if(hp < 100) // we check if player's hp < 100, this'll let us heal him only if his health's not 100.
{
if(pcash < 500) // we check if player doesn't have enough money ($500)
{
new str[256]; // if he's not, we make a new string,
format(str, sizeof(str), "You don't have $500. You got only $%d", pcash); // we set the 1st string format
SendClientMessage(playerid, 0xFF0000AA, str); // we send him formated string, which explains him that he's bum
}
else // else ( it means if he's got $500)
{
SetPlayerHealth(playerid, 100); // we set his health to 100 (restore).
SetPlayerMoney(playerid, pcash - 500); // we take a bit of his cash.
new str2[256]; // we make a new string, now "str2".
format(str2, sizeof(str2), "You have been healed for $500. You got now $%d", pcash - 500); // we set it's format.
SendClientMessage(playerid, 0xFFFFFFAA, str2); // we send him the 2nd formated string, which says that we healed him and took $500 from his pocket
}
return 1;
} // we lock the condition which calls function if he's got enough money or he's not.
else // else if his hp's 100
{
SendClientMessage(playerid, 0xFF0000AA, "You don't need to heal yourself"); // we send him a message that he's healthy
}
}
return 1;[/pawn]
Done!