Commands not working
#1

Okay, so If I type any command on the server it shows, SERVER: Unknown Command

Top of OnPlayerCommandText
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new giveplayerid;
    new specplayerid;
    new cmd[256];
    new tmp[256];
    new idx;
    cmd = strtok(cmdtext, idx);
This is the last command on OnPlayerCommand

pawn Код:
if(strcmp(cmd, "/how", true) == 0)
    {
        SendClientMessage(playerid, COLOR_SAY, "Help");
        SendClientMessage(playerid, COLOR_SAY, "Kill enemy, then you get +1 score.");
        SendClientMessage(playerid, COLOR_SAY, "Ranks is avabile: /rank");
        return 1;
    }

    return 1;
}
Please, Any help is appreciated.
Reply
#2

Seems like you're new to pawn and commands. Take a look at this topic https://sampforum.blast.hk/showthread.php?tid=91354.

Zcmd is easy to use + it's many times faster than strcmp.
Reply
#3

Quote:
Originally Posted by Johnson_boy
Посмотреть сообщение
Seems like you're new to pawn and commands. Take a look at this topic https://sampforum.blast.hk/showthread.php?tid=91354.

Zcmd is easy to use + it's many times faster than strcmp.
Damn man you fixed his problem. Well returning 1 at the end of OnPlayerCommandText will stop server from checking any other script for that command. Change last
pawn Код:
return 1;
into
pawn Код:
return 0;
in every script you have. So inside code you return 1 and at the end return 0;
Reply
#4

I appreciate your help but its still not working. I changed it, nothing
pawn Код:
if(strcmp(cmd, "/how", true) == 0)
    {
        SendClientMessage(playerid, COLOR_SAY, "Help");
        SendClientMessage(playerid, COLOR_SAY, "Kill enemy, then you get +1 score.");
        SendClientMessage(playerid, COLOR_SAY, "Ranks is avabile: /rank");
        return 1;

    }
    return 0;
}
Reply
#5

pawn Код:
if(strcmp(cmd, "/how", true) == 0)
    {
        SendClientMessage(playerid, COLOR_SAY, "Help");
        SendClientMessage(playerid, COLOR_SAY, "Kill enemy, then you get +1 score.");
        SendClientMessage(playerid, COLOR_SAY, "Ranks is avabile: /rank");
        return 1;
    }
    return 0; //you can change return 0; to SendClientMessage if you want to add a message if the command is wrong
}
Reply
#6

Still wont work
Reply
#7

I was able to fix it, I was using zmc and sscanf. I don't know who its mattered. I am using strcmd now.
Reply
#8

If you used both zcmd and strcmp that was the issue. If you use zcmd, you cannot use onplayercommandtext callback
Reply
#9

Ah Yes. Replace OnPlayerCommandText with OnPlayerCommandReceived

if you are using zcmd. Like that you won't have to edit your strcmp commands into zcmd.
Reply
#10

Quote:
Originally Posted by Johnson_boy
Посмотреть сообщение
Zcmd is easy to use + it's many times faster than strcmp.
I just couldn't help myself laughing at you comparing strcmp to zcmd... Since it looks like you have no idea what strcmp is, let me introduce it to you. Strcmp (string compare) compares string one (for example "pie") to string two (choose it yourself). If they are the same, it returns an integer - 0. Else, it returns a number less or more than 0. And zcmd has nothing to do with that, has it? I'm VERY sure that zcmd uses strcmp too. I just wanted to make this clear because such comments annoy me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)