02.10.2014, 04:49
pawn Код:
new Timer[MAX_PLAYERS];
CMD:gethp(playerid, params)
{
new lookupid;
if(sscanf(params, "u", lookupid)) return SendClientMessage(playerid, -1, "Usage: /gethp (id/name).");
Timer[playerid] = SetTimerEx("TransferHealth", 1000, true, "ii", playerid, lookupid);
return 1;
}
forward public TransferHealth(playerid, lookupid);
{
new string[144], Float:health;
GetPlayerHealth(playerid, health);
if(health <= 1)
{
KillTimer(Timer[playerid]);
return 1;
}
GetPlayerHealth(lookupid, health);
if(health >= 100)
{
KillTimer(Timer[playerid]);
return 1;
}
SetPlayerHealth(playerid, GetPlayerHealth(playerid) - 1);
format(string, sizeof(string), "Transfering health to~n~%s (%d)", PlayerName(lookupid), lookupid);
GameTextForPlayer(playerid, string, 5000, 2);
SetPlayerHealth(lookupid, GetPlayerHealth(lookupid) + 1);
format(string, sizeof(string), "Receiving health from~n~%s (%d)", PlayerName(playerid), playerid);
GameTextForPlayer(lookupid, string, 5000, 2);
return 1;
}
stock PlayerName(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
return pname;
}