You put this on the top of your gm
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
Creating the command
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(heal, 4, cmdtext); //this is the same as if(strcmp(cmdtext, "/heal", true) == 0)
return 0;
}
The actual command itself. Put this on the very bottom of your script
This command will heal a player of your choice (the same example as on wiki)
playerid is the same as the player who typed the command
params, which is always a string!, is the text the player typed AFTER /heal.
So if the player typed "/heal 25", params will be "25"
pawn Код:
dcmd_heal(playerid, params[])
{
if (strlen(params)) //if the lenght of "params" is more then zero (if the player actually typed anything after /heal)
{
id = strval(params);
if (IsPlayerConnected(id))
{
SetPlayerHealth(id, 100.0);
SendClientMessage(id, 0x00FF00AA, "You have been healed");
SendClientMessage(playerid, 0x00FF00AA, "Player healed");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Player not found");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: /heal <playerid>");
}
return 1;
}