OnPlayerCommandText Problem
#1

I've been trying to fix this for a good 30 minutes and I feel like a idiot because I can't find the problem . Anyway, I was making a registration system, and the problem came when everytime I typed /register the command went to /login. I figured it had to do something with the returns so I was switching them around to see what I did wrong, That was my good 30 minutes: "Trying to fiqure out whats wrong with the returns". Here is my OnPlayerCommandText:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	//-----------login---------------
	if (strcmp(cmd, "/login", true) ==0 )
	{
	    if(gPlayerLogged[playerid] == 1)
			{
				SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
				return 1;
			}
			else
			{
  			new ss[128];
		  new loginnames[MAX_PLAYER_NAME];
		  GetPlayerName(playerid,loginnames,MAX_PLAYER_NAME);
		  format(ss,sizeof(ss),"Hello %s, Type in your password",loginnames);
		  ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"Login Password",ss,"Login","Cancel");
			}
			return 1;
	}
		//-----------Register---------------
	if (strcmp(cmd, "/register", true) ==0 )
	{
	    if(gPlayerLogged[playerid] == 1)
			{
				SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
				return 1;
			}
			else
			{
  			new s[128];
		  new loginname[MAX_PLAYER_NAME];
		  GetPlayerName(playerid,loginname,MAX_PLAYER_NAME);
		  format(s,sizeof(s),"Hello %s, Type in your password you will like to register with!",loginname);
		  ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Password",s,"Register","Cancel");
			}
			return 1;
	}
	return 0;
}
Since people on IRC failed to help me, I'm going to ask the community: "What is wrong with the returns?"
Reply
#2

pawn Код:
(strcmp(cmd, "/login", true) ==0 )
The string "cmd" is always empty in your case and string compare has a nasty habit of returning false when one string is empty
Reply
#3

I'm so stupid, I forgot to add
Код:
	new idx;
	cmd = strtok(cmdtext, idx);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)