Commands not working -
John Rockie - 11.02.2012
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.
Re: Commands not working -
Johnson_boy - 11.02.2012
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.
Re: Commands not working -
[MG]Dimi - 11.02.2012
Quote:
Originally Posted by Johnson_boy
|
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
into
in every script you have. So inside code you return 1 and at the end return 0;
Re: Commands not working -
John Rockie - 11.02.2012
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;
}
Re: Commands not working -
Dr.Heinz - 11.02.2012
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
}
Re: Commands not working -
John Rockie - 11.02.2012
Still wont work
Re: Commands not working -
John Rockie - 12.02.2012
I was able to fix it, I was using zmc and sscanf. I don't know who its mattered. I am using strcmd now.
Re: Commands not working -
Johnson_boy - 12.02.2012
If you used both zcmd and strcmp that was the issue. If you use zcmd, you cannot use onplayercommandtext callback
Re: Commands not working -
[MG]Dimi - 12.02.2012
Ah Yes. Replace OnPlayerCommandText with OnPlayerCommandReceived
if you are using zcmd. Like that you won't have to edit your strcmp commands into zcmd.
Re: Commands not working -
KingHual - 12.02.2012
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.