Auto-login:
#1

For the last few days, I've been working on a mission switching gamemode and I came across a problem. Everytime the mission changes, I have to reload the Base.pwn filterscript, which includes the login and registration system and all the commands. The things is, it becomes annoying have to login everytime the mission switches, which the players will, at some point, get tired of doing.

I wanted to know if there's a workaround this, or If I really have to use the player's IP for this. What can be done? If it helps, the code on OnPlayerConnect will be left just below this paragraph. Thanks for your time.

pawn Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("tPoints", 3600000, true, "i", playerid);
   
    new pName[MAX_PLAYER_NAME],
        dialogTitle[21],
        string[48 + MAX_PLAYER_NAME+1];
       
    format(dialogTitle, sizeof(dialogTitle), "%s", SERVER_NAME);
   
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "{6FDD96}Server: {FFFFFF}%s has joined the server.", pName);
    SendClientMessageToAll(-1, string);
   
    if(fexist(Path(playerid)))
    {
        INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
        ShowPlayerDialog(playerid,dLogin,DIALOG_STYLE_PASSWORD,dialogTitle,"Welcome back. Your account is registered in our users database.\nProcceed by typing your password in the blank space below and logging in.","Login","Quit");//Login dialog
    }
    else
    {
        ShowPlayerDialog(playerid,dRegister,DIALOG_STYLE_PASSWORD,dialogTitle,"Welcome to our server. Your account is not registered in our users database.\nProcceed by typing your password in the blank space below and registering.","Register","Quit");//Registration dialog
        return 1;
    }
    return 1;
}
Reply
#2

I don't think using IP is optimal since multiple players can play on the same IP (if you've not restricted that). What you could do is doing something with filterscripts, seeing as they don't get reloaded on gamemode switches.

Maybe you can save the players name in a player variable and check if that playername joins on the same playerid after a gamemode switch.
Reply
#3

well there is a way of doint it
so here is it how it is done
Use unix time stamps you can read them about them here https://sampforum.blast.hk/showthread.php?tid=254915
so here is an example of how to do it
pawn Код:
public OnPlayerDisconnect(playerid)
{
new last = gettime();
new IP[16+1];
GetPlayerIp(playerid, IP, sizeof(IP));

//now save the these both in file //
//we will be loading them on player connect
return 1;
}

public OnPlayerConnect
{
//load the varaibes which we saved suppose you loaded them in Player[playerid[LastLoggedIn] and Player[playerid][IP]
new nip[17];
GetPlayerIp(playerid, nip, 17);

if(!strcmp(Player[playerid][IP], nip, true) && Player[playerid][LastLoggedIn] <= (60*120)/*2 hours*/)
{
//auto login procedure here
return 1;
}
//login procedure
return 1;
}
Reply
#4

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
well there is a way of doint it
so here is it how it is done
Use unix time stamps you can read them about them here https://sampforum.blast.hk/showthread.php?tid=254915
so here is an example of how to do it
pawn Код:
public OnPlayerDisconnect(playerid)
{
new last = gettime();
new IP[16+1];
GetPlayerIp(playerid, IP, sizeof(IP));

//now save the these both in file //
//we will be loading them on player connect
return 1;
}

public OnPlayerConnect
{
//load the varaibes which we saved suppose you loaded them in Player[playerid[LastLoggedIn] and Player[playerid][IP]
new nip[17];
GetPlayerIp(playerid, nip, 17);

if(!strcmp(Player[playerid][IP], nip, true) && Player[playerid][LastLoggedIn] <= (60*120)/*2 hours*/)
{
//auto login procedure here
return 1;
}
//login procedure
return 1;
}
As far as I'm concerned, this has a massive security hole since you can login to any account by using this method. It basically just checks if your IP has been logged in sometime the last 2 hours..

Also, you cannot use GetPlayerIp in OnPlayerDisconnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)