Need a help with making 2 CMDS as 1
#1

Look
I got /login CMD:

Код:
if (strcmp("/login", cmd, true) == 0)
	{
		if(RestartTimer != DONT_RESTART)
		{
			format(string, sizeof(string), "The Server will be restarting, untill then login has been disabled.");
			SendClientMessage(playerid, COLOR_LIGHTRED, string);
			return 1;
		}

		if(gPlayerLogged[playerid] == 1)
		{
			SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
			return 1;
		}
		if(strcount(cmdtext, ' ') != 2)
		{
			SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /login [password]");
			return 1;
		}
		if(PlayerInfo[playerid][pSQLId] == INVALID_SQL_ID)
		{
			SendClientMessage(playerid, COLOR_YELLOW, "You dont have an account. Please register by using /register [password]");
			return 1;
		}

		new inputhash[50];
		new checkhash[33];
		new rawcheckhash[99];
		inputhash = MD5_Hash(strtok(cmdtext, idx));
		strmid(checkhash,PlayerInfo[playerid][pPassword],0,strlen(PlayerInfo[playerid][pPassword]),sizeof(checkhash));
    	strmid(rawcheckhash,PlayerInfo[playerid][pPassword],0,strlen(PlayerInfo[playerid][pPassword]),sizeof(checkhash));

		//printf("RAW CHECK HASH: %s",rawcheckhash);
		//printf("CHECK HASH: %s",checkhash);
		//printf("INPUT HASH: %s",inputhash);

    if (strfind(checkhash, inputhash, true) != -1)

		{
			gPlayerLogged[playerid] = 1;
			//printf("%s has entered his password",PlayerInfo[playerid][pName]);
			SendClientMessage(playerid, COLOR_WHITE,"Please hold while we log you in...");
			// new timer for login -> spawn
			SetTimerEx("SpawnPlayerEx",5000,0,"i",playerid);

		}



		else
		{
			SendClientMessage(playerid, COLOR_RED, "ERROR: Password does not match your name.");
		}
		return 1;
	}
And I got an /xlogin cmds in ANOTHER FS:

Код:
if (strcmp(cmd, "/xlogin", true) ==0 )
	{
	  if(IsPlayerConnected(playerid))
	  {
	    new tmppass[64];
			if(gPlayerLogged[playerid] == 1)
			{
				SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
				return 1;
			}
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /xlogin [password]");
				return 1;
			}
			strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
			Encrypt(tmppass);
			OnPlayerLogin(playerid,tmppass);
		}
		return 1;
	}
How to do that when I do /login [pass], it will automaticly log me in in the /xlogin [pass] CMD too?

Please I really need this help!
Reply
#2

just copy the code from the last script into the first script (using common sense and not duplicating "new" lines ofc )
Reply
#3

I can't its 2 different system, I just need to make an auto command.
If I will not do that, the players will have to /login [pass] and after that /xlogin [pass] to FULLY log in..

GUYS please help me I really need this help please
Reply
#4

Quote:
Originally Posted by tomnidi
I can't its 2 different system
Wanna bet? Didn't test it, but should work
pawn Код:
if (strcmp("/login", cmd, true) == 0)
{
    if(RestartTimer != DONT_RESTART)
    {
        format(string, sizeof(string), "The Server will be restarting, untill then login has been disabled.");
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        return 1;
    }
    if(gPlayerLogged[playerid] == 1)
    {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
        return 1;
    }
    if(strcount(cmdtext, ' ') != 2)
    {
        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /login [password]");
        return 1;
    }
    if(PlayerInfo[playerid][pSQLId] == INVALID_SQL_ID)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "You dont have an account. Please register by using /register [password]");
        return 1;
    }
    new inputhash[50];
    new checkhash[33];
    new rawcheckhash[99];
    inputhash = MD5_Hash(strtok(cmdtext, idx));
    strmid(checkhash,PlayerInfo[playerid][pPassword],0,strlen(PlayerInfo[playerid][pPassword]),sizeof(checkhash));
    strmid(rawcheckhash,PlayerInfo[playerid][pPassword],0,strlen(PlayerInfo[playerid][pPassword]),sizeof(checkhash));
    if (strfind(checkhash, inputhash, true) != -1) // this is if login is working, right?
    {
        gPlayerLogged[playerid] = 1;
        SendClientMessage(playerid, COLOR_WHITE,"Please hold while we log you in...");
        new tmppass[64];
        strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
        Encrypt(tmppass);
        OnPlayerLogin(playerid,tmppass); //dunno if you need this
        SetTimerEx("SpawnPlayerEx",5000,0,"i",playerid);
    } else {
        SendClientMessage(playerid, COLOR_RED, "ERROR: Password does not match your name.");
    }
    return 1;
}
Reply
#5

You don't understand me dude, one system as Gamemode, and the second one as FS,
Its like 2 different gPlayerLogged.
I tried to put what you said, it like spawns me 2 times on the gamemode that I have put it there, it didn't spawn me in the FS too.
That is my problem.. Can you think about something else?
I really need to fix that.
Reply
#6

another idea: make the second login (xlogin) a public function (forward xlogin(playerid); public xlogin(playerid)) and then call it in the first login (/login)
Reply
#7

Can you help me please?
I changed all the OnPlayerLogin to OnPlayerXLogin at the seconds FS (with the /xlogin), and I have to put something like this:

Код:
format (cmdstring, sizeof(cmdstring), "/xlogin %d", string);
      CallRemoteFunction("OnPlayerCommandText", "is", playerid, cmdstring);
at the orginal /login?

Because its kinda doesn't work, its log me in with the first /login but says incorrect password after that (for the second /xlogin)..
Reply
#8

Someone please?
Reply
#9

pawn Код:
format (cmdstring, sizeof(cmdstring), "/xlogin %s", >> string that contains the password <<);
CallRemoteFunction("OnPlayerCommandText", "is", playerid, cmdstring);
Reply
#10

I copied the tamppass from the second login and put it like this:

Код:
format (cmdstring, sizeof(cmdstring), "/xlogin %s", tmppass);
      CallRemoteFunction("OnPlayerCommandText", "is", playerid, cmdstring);
And now when I type /login [pass], it log me into my first account, and then writes USAGE: /XLOGIN [password], like I just typed /xlogin

What to do?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)