heal command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: heal command (
/showthread.php?tid=458041)
heal command -
lsreskjn - 14.08.2013
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new index, cmd[20];
cmd = strtok(cmdtext, index); // error line
if (strcmp(cmd, "/heal", true) == 0)
{
new tmp[20];
tmp = strtok(cmdtext, index); // error line
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "Usage : /heal <ID>");
if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
SetPlayerHealth(strval(tmp), 100.0);
SendClientMessage(strval(tmp), 0x00FF00AA, "You have been healed");
SendClientMessage(playerid, 0x00FF00AA, "Player healed");
return 1;
}
Код:
error 047: array sizes do not match, or destination array is too small
error 047: array sizes do not match, or destination array is too small
Re : heal command -
Garwan50 - 14.08.2013
You try to get the argument of the function like /heal
<id>, just make a string compare of cmd text and youre cmd
pawn Код:
if(strcmp("/aheal", cmdtext, true, 6) == 0)
{
new temp[128];
new giveplayerid;
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
new str[128];
new idx;
temp = strtok(cmdtext[6], idx);
if(strlen(temp) == 0)
{
SendClientMessage(playerid, -1, "** [Utilisation]: /aheal [playerid/PartOfName]");
return 1;
}
else
{
if(IsPlayerpAdmin(playerid))
{
giveplayerid = ReturnUser(temp);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, playername, sizeof(playername));
if(IsPlayerConnected(giveplayerid))
{
format(str, sizeof(str), "L'admin %s a soignй le joueur %s", playername, giveplayer);
SendClientMessageToAll(COLOR_RED, str);
return 1;
}
else SendClientMessage(playerid, -1, "Le joueur n'est pas connectй/n'existe pas");
return 1;
}
else SendClientMessage(playerid, -1, "Vous n'йtes pas admin.");
}
return 1;
}
Re: heal command -
Edix - 14.08.2013
Theres the problem "cmd[20]", make it something like "cmd[128]" that should help.