I have little bug
#1

When I write "/removetoga 0", appears to me "Unknown command"

Код:
if(strcmp(cmdtext, "/removetoga", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    	SendClientMessage(playerid, COLOR_WHITE, "/removetoga (playerid)");
    	return 1;
    }
    togaplayerid = ReturnUser(tmp);
    if(togaplayerid!= INVALID_PLAYER_ID)
    {
        if(PlayerInfo[togaplayerid][Toga] == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "This administrator not have a toga.");
        }
        else if(PlayerInfo[togaplayerid][Toga] == 1)
        {
            new rtoga[128];
            PlayerInfo[togaplayerid][aTog] = 0;
            format(rtoga, sizeof(rtoga),"You remove %s's toga.", GetName(togaplayerid));
            SendClientMessage(playerid, COLOR_LIGHTBLUE, rtoga);
        }
    }
    return 1;
}
Reply
#2

It will work if you convert that to ZCMD/YCMD and sscanf.
Reply
#3

The command is executed to
Код:
if(strcmp(cmdtext, "/removetoga", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    	SendClientMessage(playerid, COLOR_WHITE, "/removetoga (playerid)");
    	return 1;
    }
The rest does not work..
Reply
#4

Remove the return 1; @ parameter check, why is it there in the first place?

edit: oh and tip, you got a check if the playerid isn't invalid, but what about a message if it is..
Reply
#5

To remove the check for valid ID?
Reply
#6

I meant
Код:
    if(!strlen(tmp))
    {
    	SendClientMessage(playerid, COLOR_WHITE, "/removetoga (playerid)");
    	return 1;
    }
into
Код:
    if(!strlen(tmp))
    {
    	SendClientMessage(playerid, COLOR_WHITE, "/removetoga (playerid)");
    }
Just try..
Reply
#7

"SERVER: Unknown command."
Reply
#8

I see the problem here..
ok, so what u do is this.

put this under OnPlayerCommandText
pawn Код:
new cmd[256], idx, tmp[256];
cmd = strtok(cmdtext, idx);
tmp = strtok(cmdtext, idx);
replace your command with
pawn Код:
if(strcmp(cmd, "/removetoga", true) == 0)
{
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "/removetoga (playerid)");
    }
    togaplayerid = ReturnUser(tmp);
    if(togaplayerid!= INVALID_PLAYER_ID)
    {
        if(PlayerInfo[togaplayerid][Toga] == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "This administrator not have a toga.");
        }
        else if(PlayerInfo[togaplayerid][Toga] == 1)
        {
            new rtoga[128];
            PlayerInfo[togaplayerid][aTog] = 0;
            format(rtoga, sizeof(rtoga),"You remove %s's toga.", GetName(togaplayerid));
            SendClientMessage(playerid, COLOR_LIGHTBLUE, rtoga);
        }
    }
    return 1;
}
please notify me if this works.
Reply
#9

No longer gives "Unk ...", but when I enter ID of the player performs again
Код:
if (! strlen (tmp))
{
    SendClientMessage (playerid, COLOR_WHITE, "/ removetoga (playerid)");
}
Reply
#10

Do this then:
pawn Код:
if (! strlen (tmp))
{
    SendClientMessage (playerid, COLOR_WHITE, "/ removetoga (playerid)");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)