Little Problem
#1

Hi All, I have a problem whit a very simple command, but i'm very n00b.

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
     new idx;
	new cmd[256];
	cmd=strtok(cmdtext,idx);
	if(strcmp(cmd, "/help", true, 10) == 0)
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "* * * * * AIUTI * * * * *");
		SendClientMessage(playerid, COLOR_ORANGE, "Per la lista comandi digita /cmds");
		SendClientMessage(playerid, COLOR_ORANGE, "Per gli obiettivi digita /obiettivi");
		SendClientMessage(playerid, COLOR_ORANGE, "Per i teleport digita /tele");
		SendClientMessage(playerid, COLOR_ORANGE, "Per i crediti digita /crediti");
  	     return 1;
	}
	return 0;
}
The commands don't work and I have no error. Please Help!
Reply
#2

use [ pawn ] [ /pawn ] tags next time.

pawn Код:
if (!strcmp("/help", cmdtext, true))
{
    SendClientMessage(playerid, COLOR_LIGHTRED, "* * * * * AIUTI * * * * *");
    SendClientMessage(playerid, COLOR_ORANGE, "Per la lista comandi digita /cmds");
    SendClientMessage(playerid, COLOR_ORANGE, "Per gli obiettivi digita /obiettivi");
    SendClientMessage(playerid, COLOR_ORANGE, "Per i teleport digita /tele");
    SendClientMessage(playerid, COLOR_ORANGE, "Per i crediti digita /crediti");
    return 1;
}
Reply
#3

in this line
pawn Код:
if(strcmp(cmd, "/help", true, 10) == 0)
change it to -
pawn Код:
if(strcmp(cmd, "/help", true) == 0)

Reply
#4

Quote:
Originally Posted by ۞●•λвнiиаv•●۞
in this line
pawn Код:
if(strcmp(cmd, "/help", true, 10) == 0)
change it to -
pawn Код:
if(strcmp(cmd, "/help", true) == 0)

Yes, it is that line. But he is comparing the wrong strings. It should be
pawn Код:
if(strcmp(cmdtext, "/help", true) == 0)
since OnPlayerCommandText passes cmdtext

And this part of the code
pawn Код:
new idx;
    new cmd[256];
    cmd=strtok(cmdtext,idx);
is completly unnesesary
Reply
#5

well ... that code is not completely unnecessary bcoz he might have used some other commands which may use it.

And thanks for correcting my error :P

-Abhinav
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)