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_INPUT, ""COL_GREY"Registering...",""COL_GREY"You have entered an invalid {FF6347}password{B4B5B7}.\n"COL_GREY"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",0);
INI_WriteInt(File,"VIP",0);
INI_WriteInt(File,"Wanted",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Jailed",0);
INI_WriteInt(File,"Muted",0);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Score",0);
INI_WriteInt(File,"Banned",0);
INI_Close(File);
}
}
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]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_LGREEN"Success",""COL_LGREEN"You have successfully logged in!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_GREY"Login",""COL_GREY"You have entered an incorrect {FF6347}password{B4B5B7}.\n"COL_GREY"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
/******************************************************************************/
/**********************************< STOCKS >**********************************/
stock UserPath(playerid)
{
new string[1000],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public OnPlayerDisconnect(playerid, reason)
{
if(IsBeingSpeced[playerid] == 1)
{
foreach(Player,i)
{
if(spectatorid[i] == playerid)
{
TogglePlayerSpectating(i, 0);
}
}
}
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVIP]);
INI_WriteInt(File,"Wanted",GetPlayerWantedLevel(playerid));
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Jailed",PlayerInfo[playerid][pJailed]);
INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
INI_Close(File);
IsOnDuty[playerid] = 0;
IsGodMode[playerid] = 0;
//from here
PlayerInfo[playerid][pAdmin] = 0;
PlayerInfo[playerid][pVIP] = 0;
//etc.
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_LBLUE"Login",""COL_GREY"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_LRED"Registering...",""COL_GREY"Type your password below to register this account","Register","Quit");
}
IsOnDuty[playerid] = 0;
IsGodMode[playerid] = 0;
return 1;
}
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("VIP",PlayerInfo[playerid][pVIP]);
INI_Int("Wanted",PlayerInfo[playerid][pWanted]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Jailed",PlayerInfo[playerid][pJailed]);
INI_Int("Muted",PlayerInfo[playerid][pMuted]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Score",PlayerInfo[playerid][pScore]);
INI_Int("Banned",PlayerInfo[playerid][pBanned]);
return 1;
}
enum pInfo
{
pPass,
pAdmin,
pVIP,
pWanted,
pKills,
pDeaths,
pJailed,
pMuted,
pCash,
pScore,
pBanned
}
new PlayerInfo[MAX_PLAYERS][pInfo];
#define PATH "/AdminSystem/Account/%s.ini"
forward LoadUser_data(playerid,name[],value[]);
stock UserPath(playerid)
{
new string[1000],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
Add a folder in AdminSystem/Account . Like i set #define UserPath "Users/%s.ini" and i created a new folder with name "Users" now after every registration data saves in that folder and new file is created whenever a person register him/herself
|