SERVER: Unknown Command 0.3d
#1

I get no errors but when i try and enter the command it wont work, Help? and don't say use ZCMD or any other StupidCMD.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new string1[256];
    new pName[MAX_PLAYER_NAME];
    new cmd[256];
    new tmp[256];
    new giveplayerid;
    new idx;
    cmd = strtok(cmdtext, idx);
    tmp = strtok(cmdtext, idx);
//-------------------------[Commands]-----------------------------
    if(strcmp(cmd, "/cmds", true) == 0)
    {
        SendClientMessage(playerid, 0x0000FFFF, "/cmds");
        return 1;
    }
    if(strcmp(cmd, "/gethealth", true) == 0)
    {
        if(PlayerInfo[playerid][Admin] >= 1)
        {
            new Float:Health;
            giveplayerid = ReturnUser(tmp);
            new pHealth;
            pHealth = GetPlayerHealth(giveplayerid, Health);
            GetPlayerName(giveplayerid, pName, sizeof(pName));
            format(string, sizeof(string), "Player: %s 's Health is %s", pName, pHealth);
            SendClientMessage(playerid, 0xFF9900FF, string);
            return 1;
        }
        else SendClientMessage(playerid, 0x99FF00FF, "You are not an Admin!");
        return 1;
    }
    if(strcmp(cmd, "/green", true) == 0)
    {
        SetPlayerColor(playerid, 0x00CC00FF);
        return 1;
    }
    if(strcmp(cmd, "/red", true) == 0)
    {
        SetPlayerColor(playerid, 0xFF0033FF);
        return 1;
    }
    if(strcmp(cmd, "/setmyskin", true) == 0)
    {
        new skin = strval(tmp);
        SetPlayerSkin(playerid, skin);
        return 1;
    }
    if(strcmp(cmd, "/givemoney", true) == 0)
    {
        if(PlayerInfo[playerid][Admin] >= 3)
        {
            GetPlayerName(giveplayerid, pName, sizeof(pName));
            new money = strval(tmp);
            GivePlayerMoney(giveplayerid, money);
            format(string, sizeof(string), "You have given %s $%s", pName, money);
            SendClientMessage(playerid, 0xFFFF00FF, string);
            format(string1, sizeof(string1), "You have recieved $%s from an Admin!", money);
            SendClientMessage(giveplayerid, 0xFFFF00FF, string1);
            return 1;
        }
        else SendClientMessage(playerid, 0x99FF00FF, "You are not an Admin!");
        return 1;
    }
    if(strcmp(cmd, "/sethealth", true) == 0)
    {
        if(PlayerInfo[playerid][Admin] >= 2)
        {
        new health = strval(tmp);
        GetPlayerName(giveplayerid, pName, sizeof(pName));
            SetPlayerHealth(giveplayerid, health);
            format(string, sizeof(string), "You have set Player: %'s health to %s", pName, health);
            SendClientMessage(playerid, 0xFFFF00FF, string);
            return 1;
        }
        else SendClientMessage(playerid, 0x99FF00FF, "You are not an Admin!");
        return 1;
    }
    return 1;
}
Reply
#2

try changing

pawn Код:
strcmp(cmd, "/cmds", true)
to
pawn Код:
strcmp(cmdtext, "/cmds", true)
Reply
#3

In your OnPlayerCommandText you are using strtok to detect an integer after the command "/cmds". If you don't want numbers then do what the dude above me has said.
Reply
#4

Fixed:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new string1[256];
    new pName[MAX_PLAYER_NAME];
    new cmd[256];
    new tmp[256];
    new giveplayerid;
    new idx;
    cmd = strtok(cmdtext, idx);
    tmp = strtok(cmdtext, idx);
//-------------------------[Commands]-----------------------------
    if(strcmp(cmd, "/cmds", true) == 0)
    {
        SendClientMessage(playerid, 0x0000FFFF, "/cmds");
        return 1;
    }
    if(strcmp(cmd, "/gethealth", true) == 0)
    {
        if(PlayerInfo[playerid][Admin] >= 1)
        {
            new Float:Health;
            giveplayerid = ReturnUser(tmp);
            new pHealth;
            pHealth = GetPlayerHealth(giveplayerid, Health);
            GetPlayerName(giveplayerid, pName, sizeof(pName));
            format(string, sizeof(string), "Player: %s 's Health is %s", pName, pHealth);
            SendClientMessage(playerid, 0xFF9900FF, string);
            return 1;
        }
        else SendClientMessage(playerid, 0x99FF00FF, "You are not an Admin!");
        return 1;
    }
    if(strcmp(cmd, "/green", true) == 0)
    {
        SetPlayerColor(playerid, 0x00CC00FF);
        return 1;
    }
    if(strcmp(cmd, "/red", true) == 0)
    {
        SetPlayerColor(playerid, 0xFF0033FF);
        return 1;
    }
    if(strcmp(cmd, "/setmyskin", true) == 0)
    {
        new skin = strval(tmp);
        SetPlayerSkin(playerid, skin);
        return 1;
    }
    if(strcmp(cmd, "/givemoney", true) == 0)
    {
        if(PlayerInfo[playerid][Admin] >= 3)
        {
            GetPlayerName(giveplayerid, pName, sizeof(pName));
            new money = strval(tmp);
            GivePlayerMoney(giveplayerid, money);
            format(string, sizeof(string), "You have given %s $%s", pName, money);
            SendClientMessage(playerid, 0xFFFF00FF, string);
            format(string1, sizeof(string1), "You have recieved $%s from an Admin!", money);
            SendClientMessage(giveplayerid, 0xFFFF00FF, string1);
            return 1;
        }
        else SendClientMessage(playerid, 0x99FF00FF, "You are not an Admin!");
        return 1;
    }
    if(strcmp(cmd, "/sethealth", true) == 0)
    {
        if(PlayerInfo[playerid][Admin] >= 2)
        {
        new health = strval(tmp);
        GetPlayerName(giveplayerid, pName, sizeof(pName));
            SetPlayerHealth(giveplayerid, health);
            format(string, sizeof(string), "You have set Player: %'s health to %s", pName, health);
            SendClientMessage(playerid, 0xFFFF00FF, string);
            return 1;
        }
        else SendClientMessage(playerid, 0x99FF00FF, "You are not an Admin!");
        return 1;
    }
    return 0;
}
Reply
#5

Neither works
Reply
#6

Nice, a good example of how to code badly. Only create variables when you need to. Currently, changing their colour (which requires nothing at all) uses so much variables it's madness.

You return TRUE on OnPlayerCommandText, when usually we return FALSE (So there player knows they entered an invalid command).

Your coding is stupid, use a command processor ffs.
Quote:

and don't say use ZCMD or any other StupidCMD.

Perfect for you.

Use print(), find out where your error is.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)