Command Help!
#1

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;
}
Reply
#2

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
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)