Auto login
#1

Hello,

My OnPlayerAutoLogin funtion doesn't work. It will show the "Enter password" dialog if I join the server.

I think this is wrong: if(!strcmp(AccountInfo[playerid][aIP], PlayerIP))

Thanks for helping!

Battleman


OnPlayerConnect
Код:
public OnPlayerConnect(playerid)
{
	GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
	AccountInfo[playerid][aIP]=PlayerIP;

	return 1;
}
OnPlayerRequestClass
Код:
public OnPlayerRequestClass(playerid, classid)
{
	if(IsUserNameAvailable(PlayerName[playerid]))
	{
	    if(OnPlayerAutoLogin(playerid))
	    {
         	LoadPlayer(playerid);
	        return SpawnPlayer(playerid);
	    }
		ShowPlayerDialog(playerid,DIALOGID+1,DIALOG_STYLE_MSGBOX,ServerInfo[sName],"The system found an account by your nickname. \nYou have to login to continue.","Login","Quit");
	}else{
		ShowPlayerDialog(playerid,DIALOGID+2,DIALOG_STYLE_MSGBOX,ServerInfo[sName],"The system didn't found an account by your nickname. You can play with or without an account. \nIf you don't register, you stats won't be restored. If you register your stats will be stored. \nPlease make your choice.","Register","Don't Reg.");
	}
	return 1;
}
My OnPlayerAutoLogin
Код:
stock OnPlayerAutoLogin(playerid)
{
	format(File, sizeof(File), "/accountfiles/%s.sav", PlayerName[playerid]);
	AutoLogin = dini_Int(File, "AutoLogin");
	if(AutoLogin)
	{
		GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
		AccountInfo[playerid][aIP] = dini_Int(File, "IP");
		if(!strcmp(AccountInfo[playerid][aIP], PlayerIP))
		{
			return 1;
		}
	}
	return 0;
}
Reply
#2

format(File, sizeof(File), "/accountfiles/%s.sav", PlayerName[playerid]);
AutoLogin = dini_Int(File, "AutoLogin");
if(AutoLogin)
?
Reply
#3

Yes, an account variable. AutoLogin 0 = you will not automatically login, AutoLogin 1 = you will automatically login
Reply
#4

Its not working ,i tested
Reply
#5

AccountInfo[playerid][aIP] = dini_Int(File, "IP");
Ip is a string, so you need dini_Get its not int.
Reply
#6

oh stupid :P

But if change that int to Get it give an error.

error 047: array sizes do not match, or destination array is too small

Код:
enum sAccount
{  
    aIP[16],// IP of the player
    //other account variables
};
new AccountInfo[MAX_PLAYERS][sAccount];
What wrong? If tryed this aIP[25], but that didn't fix it.
Reply
#7

Try the string 255.

This is a wrong bug from Dini.
Reply
#8

Just compare it directly.

pawn Код:
stock OnPlayerAutoLogin(playerid)
{
    format(File, sizeof(File), "/accountfiles/%s.sav", PlayerName[playerid]);
    AutoLogin = dini_Int(File, "AutoLogin");
    if(AutoLogin)
    {
        if(!strcmp(AccountInfo[playerid][aIP], dini_Get(File, "IP"))) return 1;
    }
    return 0;
}
Also in your OnPlayerConnect function, what's the point in doing that? Why not just save it directly to the variable in the first place? Like so:

pawn Код:
public OnPlayerConnect(playerid)
{
    GetPlayerIp(playerid, AccountInfo[playerid][aIP], sizeof(AccountInfo[playerid][aIP]));

    return 1;
}
Lastly, moved to the right section.
Reply
#9

Ok, now if got 2 errors.

By this line:
GetPlayerIp(playerid, AccountInfo[playerid][aIP], sizeof(AccountInfo[playerid][aIP])); // at on player connect
the follow errors:
Код:
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : error 001: expected token: "]", but found "-identifier-"
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : warning 215: expression has no effect
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : error 001: expected token: ";", but found "]"
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : error 029: invalid expression, assumed zero
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : fatal error 107: too many error messages on one line
and by this line:
AccountInfo[playerid][aIP] = dini_Get(File, "IP");

this error:
Код:
error 047: array sizes do not match, or destination array is too small
Reply
#10

Quote:
Originally Posted by Battleman
Посмотреть сообщение
Ok, now if got 2 errors.

By this line:
GetPlayerIp(playerid, AccountInfo[playerid][aIP], sizeof(AccountInfo[playerid][aIP])); // at on player connect
the follow errors:
Код:
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : error 001: expected token: "]", but found "-identifier-"
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : warning 215: expression has no effect
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : error 001: expected token: ";", but found "]"
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : error 029: invalid expression, assumed zero
Z:\Mijn documenten\PC\Game\Maxlife\Script\2011\januari 2011\MLRPG 2011 2 januari\MLRPG 2011 2 januari\gamemodes\mlrpg.pwn(29) : fatal error 107: too many error messages on one line
and by this line:
AccountInfo[playerid][aIP] = dini_Get(File, "IP");

this error:
Код:
error 047: array sizes do not match, or destination array is too small
Why are you adding:

pawn Код:
AccountInfo[playerid][aIP] = dini_Get(File, "IP");
You don't need to do that with the example I've shown. Also just use this instead to fix the other errors.

pawn Код:
public OnPlayerConnect(playerid)
{
    GetPlayerIp(playerid, AccountInfo[playerid][aIP], 16); // Assuming 16 is the size of your array, since that's the maximum length of an IP address.

    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)