11.10.2012, 21:09
Check this code.. it's not tested.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
new bool:pOffersHeal[MAX_PLAYERS] = false;
new Float:HealthAmount;
CMD:heal(playerid, params[])
{
new giveplayerid,
Float:heal,
Float:X, Float:Y, Float:Z;
if(sscanf(params, "df", giveplayerid, heal))return SendClientMessage(playerid, -1, "Type: /heal (playerid) (health)");
{
if(!IsPlayerConnected(giveplayerid) || giveplayerid == playerid)
{
SendClientMessage(playerid, -1, "Error: Unable to find this player.");
return true;
}
GetPlayerPos(playerid, X, Y, Z);
if(!IsPlayerInRangeOfPoint(giveplayerid, 5.0, X, Y, Z))
{
SendClientMessage(playerid, -1, "Error: This player is too far from you!");
return true;
}
new string[128];
format(string, sizeof(string), "You've received an offer to heal you by %2.1f", heal);
SendClientMessage(giveplayerid, -1, string);
SendClientMessage(giveplayerid, -1, "Type in the chat \"Yes\" or \"No\" to reply the offer.");
pOffersHeal[giveplayerid] = true;
HealthAmount = heal;
}
return true;
}
public OnPlayerText(playerid, text[])
{
if(pOffersHeal[playerid])
{
if(strcmp(text, "Yes", true) == 0)
{
SetPlayerHealth(playerid, HealthAmount);
}
else if(strcmp(text, "No", true) == 0)
{
GameTextForPlayer(playerid, "Canceled heal offer", 3000, 3);
}
return true;
}
return true;
}