heal command
#1

Код:
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
Reply
#2

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;
    }
Reply
#3

Theres the problem "cmd[20]", make it something like "cmd[128]" that should help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)