OnPlayerCommandText Problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerCommandText Problem (
/showthread.php?tid=106161)
OnPlayerCommandText Problem -
Eazy_Efolife - 01.11.2009
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?"
Re: OnPlayerCommandText Problem -
dice7 - 01.11.2009
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
Re: OnPlayerCommandText Problem -
Eazy_Efolife - 01.11.2009
I'm so stupid, I forgot to add
Код:
new idx;
cmd = strtok(cmdtext, idx);