SA-MP Forums Archive
Command Help! - 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)
+--- Thread: Command Help! (/showthread.php?tid=571905)



Command Help! - MrCallum - 23.04.2015

The problem with the command is that when I go in game and do /login it says USAGE: (/l)ogin and keeps doing it and won't let me login, why?

The command:

Код:
CMD:login(playerid, params[])
{
	if(IsPlayerConnected(playerid))
 	{
  		new tmppass[64];
  		new tmp[64];
  		new cmdtext[64];
  		new idx;
		if(gPlayerLogged[playerid] == 1)
		{
			SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "SERVER: You are already logged in.");
			return 1;
		}
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "USAGE: (/l)ogin [password]");
			return 1;
		}
		strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
		//Encrypt(tmppass);
		OnPlayerLogin(playerid, tmppass);
	}
	return 1;
}



Re: Command Help! - Fel486 - 23.04.2015

I never used strtok and don't know how it works for making commands, but there:

PHP код:
if(!strlen(tmp)) 
means that if you don't type 64 characters as tmp's length defined above, it'll give you the error.

So, try this:

PHP код:
if(strlen(tmp) > 64



Re: Command Help! - AberKane - 23.04.2015

Use strlen this way |
Код:
if(strlen(tmp) == 0)
    {
then reply back.

Btw, please don't use strtok, and better head to more optimized way of using commands and strings.