SA-MP Forums Archive
I have little bug - 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: I have little bug (/showthread.php?tid=322064)



I have little bug (+rep) - Join7 - 29.02.2012

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;
}



Re: I have little bug - Stylock - 29.02.2012

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


Re: I have little bug - Join7 - 29.02.2012

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..


Re: I have little bug - Mike_Peterson - 29.02.2012

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..


Re: I have little bug - Join7 - 29.02.2012

To remove the check for valid ID?


Re: I have little bug - Mike_Peterson - 29.02.2012

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..


Re: I have little bug - Join7 - 29.02.2012

"SERVER: Unknown command."


Re: I have little bug - Mike_Peterson - 29.02.2012

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.


Re: I have little bug - Join7 - 29.02.2012

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



Re: I have little bug - Joey^ - 29.02.2012

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