08.04.2016, 19:26
Hey, I used Kush's tutorial to make a simple login system, and for the most part it works OK. After spending ages trying to figure out how to stop files being created for players that haven't set a password I've come across a brand new issue. After I register the first account, any accounts made after take stats from the initial account. For example:
I create an account w/ username "Poo" and the stats look like so:
CASH: 100
ADMIN: 0
KILLS: 0
I then give "Poo" admin by editing the .ini:
CASH: 100
ADMIN: 4
KILLS: 0
I then make a new account called "Dog Poo" and the stats, instead of being default, will be like "Poo's":
CASH: 100
ADMIN: 4
KILLS: 0
I'm at a loss, any help would be appreciated!
I create an account w/ username "Poo" and the stats look like so:
CASH: 100
ADMIN: 0
KILLS: 0
I then give "Poo" admin by editing the .ini:
CASH: 100
ADMIN: 4
KILLS: 0
I then make a new account called "Dog Poo" and the stats, instead of being default, will be like "Poo's":
CASH: 100
ADMIN: 4
KILLS: 0
I'm at a loss, any help would be appreciated!
PHP код:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
SendClientMessage(playerid,COLOR_WHITE,"Welcome to EverGM. Use {00FF00}/help {FFFFFF}for information on commands.");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Admin Level",0);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Score",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
SpawnPlayer(playerid);
GivePlayerMoney(playerid, 10000);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Sign up successful! Relogging is recommended","Ok","");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
if(fexist(UserPath(playerid)))
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Admin Level",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
}
return 1;
}