07.07.2012, 15:28
So basically I tried to script an admin command, called /heal ID. I just started using ZCMD, and I was wondering if anyone could help me with this one.
I get no error when compiling it, but when I try to do /heal 1(no id 1, offline), it shows "ERROR; correct usage /heal [ID]", the same when I do /heal 0(myself).
When I do it as non-admin it works properly giving me the message "ERROR: You're not an administrator".
Here' the code:
I get no error when compiling it, but when I try to do /heal 1(no id 1, offline), it shows "ERROR; correct usage /heal [ID]", the same when I do /heal 0(myself).
When I do it as non-admin it works properly giving me the message "ERROR: You're not an administrator".
Here' the code:
pawn Код:
COMMAND:heal(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new toplayer, health;
if(!sscanf(params,"ui",toplayer, health))
{
if(IsPlayerConnected(toplayer))
{
if(health <= 100)
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "&s has filled your HP.",name, health);
SendClientMessage(toplayer, 0xFFFFFF, string);
format(string, sizeof(string), "You gave %s full HP.",PlayerName, health);
SendClientMessage(playerid, 0xFFFFFF, string);
SetPlayerHealth(toplayer, 100);
}
else return SendClientMessage(playerid, 0xFFFFFF, "ERROR: This player already has full health!");
}
else return SendClientMessage(playerid, 0xFFFFFF, "ERROR: The player is offline.");
}
else return SendClientMessage(playerid, 0xFFFFFF, "Correct usage: /heal [ID]");
}
else return SendClientMessage(playerid, 0xFFFFFF, "ERROR, You're not an administrator");
return 1;
}