SA-MP Forums Archive
My Reg/Log system is not working fine - 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: My Reg/Log system is not working fine (/showthread.php?tid=574463)



My Reg/Log system is not working fine - baba1234 - 17.05.2015

Hey guys,

So I followed Kushˇs y_ini reg/log system but I found some kind of bug in it. When new player joins server they get
registration dialog and if they click cancel server will kick them but the problem is that their data get saved even if they didnt put any passoword or anything. And when they got saved next time when they come to the server with same name they cant login bcus there is no password. So my question is how do I fix this? If u wonder about code its
http://pastebin.com/r4htbbcJ.


Re: My Reg/Log system is not working fine - Konstantinos - 17.05.2015

It's because you open the file write in it and close it in OnPlayerDisconnect (it's called even if the player gets kicked).

Check if the file exists before
pawn Код:
if(fexist(UserPath(playerid)))
and if it does, do the procedure above.


Re: My Reg/Log system is not working fine - baba1234 - 17.05.2015

Oh so when player it kicked that is like OnPlayerDisconnect.. So what should I do about that should I save it somewhere else?


EDIT:

Yes that line exists
Код:
OnPlayerConnect if(fexist(UserPath(playerid)))
	{
	    new logstring[326];
	    new logname[64];
	    GetPlayerName(playerid,logname,sizeof(logname));
	    format(logstring,sizeof(logstring),""COL_ZLATNA"__________________________________________________\n\n"COL_BIJELA"Dobrodosao nazad"COL_ZLATNA" %s\n\n"COL_BIJELA"Ti imas: "COL_ZELENA"Account\n\n"COL_BIJELA"Upisi sifru za "COL_ZLATNA"Nastavak\n\n"COL_BIJELA"Ugodan ostatak dana zeli vam "COL_ZLATNA"Godfather Communnity!\n\n__________________________________________________",logname);
		INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_BIJELA"Balkan Godfather-"COL_ZLATNA"Login", logstring, "Login", "Odustani");
	}
Код:
public OnPlayerDisconnect(playerid, reason)
{
    //Info-TextDraws------------------------------------------------------------
	TextDrawHideForPlayer(playerid, InfoTextDraw);
	//--------------------------------------------------------------------------
	//Login/Reg-Sistem----------------------------------------------------------
	new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File,"data");
	INI_WriteInt(File,"Novac",GetPlayerMoney(playerid));
	INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
	INI_WriteInt(File,"Ubistva",PlayerInfo[playerid][pUbistva]);
	INI_WriteInt(File,"Smrti",PlayerInfo[playerid][pSmrti]);
	INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
	INI_Close(File);
	return 1;
}
case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_BIJELA"Balkan Godfather-"COL_ZLATNA"Registracija",""COL_ZLATNA"_______________________\n\n"COL_BIJELA"Unijeli ste pogresan format "COL_CRVENA"sifre!\n\n"COL_BIJELA"Pokusaj "COL_ZLATNA"Ponovo!\n"COL_ZLATNA"_______________________","Register","Odustani");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Novac",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Ubistva",0);
                INI_WriteInt(File,"Smrti",0);
                INI_WriteInt(File,"Level",0);
                INI_WriteInt(File,"Godine",0);
                INI_WriteInt(File,"Porijeklo",0);
                INI_WriteInt(File,"Spol",0);
                INI_Close(File);
				TogglePlayerSpectating(playerid, 0);
				SetSpawnInfo( playerid, 0, 0, 1714.8339, -1912.6870, 13.5666, 359.9943, 26, 36, 28, 150, 0, 0 );
				SpawnPlayer(playerid);
                GivePlayerMoney(playerid, 1000);
    		}



Re: My Reg/Log system is not working fine - Konstantinos - 17.05.2015

Actually it shouldn't write in it at all from 2 tutorials I just looked. Anyway, this will prevent it:
PHP код:
public OnPlayerDisconnect(playeridreason)
{
    if(
fexist(UserPath(playerid)))
    {
        new 
INI:File INI_Open(UserPath(playerid));
        
INI_SetTag(File,"data");
        
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
        
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
        
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
        
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
        
INI_Close(File);
    }
    return 
1;

TIP: Use Whirlpool for hashing passwords, udb_hash is bad.


Re: My Reg/Log system is not working fine - baba1234 - 17.05.2015

Okay thank you very much LOCK!