I guess this is what you need?
Код:
enum pInfo
{
pPass,
pBanned,
pCash,
pAdmin,
pVip,
pKills,
pScore,
pIp,
pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward
LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Banned", PlayerInfo[playerid][pBanned]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Vip",PlayerInfo[playerid][pVip]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Score", PlayerInfo[playerid][pScore]);
INI_Int("Ip", PlayerInfo[playerid][pIp]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
Код:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
new IP[59];
GetPlayerIp(playerid, IP, sizeof(IP));
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "data");
INI_WriteString(File, "Ip", IP);
INI_Close(File);
if(!strcmp(IP, PlayerInfo[playerid][pIp], true))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true , .extra = playerid);
switch(PlayerInfo[playerid][pAdmin])
{
case 2:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Trial Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 3:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Trial Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 4:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Moderator, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 5:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Moderator, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 6:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Deputy Head Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 7:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Head Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 8:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Head Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 9:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Name: %s, "blue"Co-Owner, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
case 10:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), ""yellow"Name: %s, "blue"Main Owner"yellow", VIP level: %i, Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
default:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), ""yellow"Name %s: Score: %i, Deaths: %i, Kills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
SendClientMessage(playerid, Limegreen, string);
SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
}
}
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
loggedin[playerid]=1;
}
else
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true , .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login", "Login", "Quit");
}
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
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,"Vip",PlayerInfo[playerid][pVip]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File, "Score", PlayerInfo[playerid][pScore]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
Код:
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""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));
new IP[50], string[50];
GetPlayerIp(playerid, IP, sizeof(IP));
format(string, sizeof(string),"%s", IP);
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteString(File,"Real Password", inputtext);
INI_WriteInt(File, "Banned", 0);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File, "Vip", 0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File, "Score",0);
INI_WriteString(File, "Ip", IP);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
}
}
case DIALOG_LOGIN:
{
ShowPlayerDialog(playerid, -1, 2, "lol", "lol", "l","h");
if(PlayerInfo[playerid][pBanned] == 1)
{
Ban(playerid);
}
if(loggedin[playerid] == 1) return 0;
else
{
if ( !response ) return Kick ( playerid );
}
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
loggedin[playerid]=1;
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
switch(PlayerInfo[playerid][pAdmin])
{
case 2:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nTrial Admin\nScore: %i\nDeaths: %i\nKills: %i\nPassword: %s",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills], inputtext);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 3:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nTrial Admin\nScore: %i\nDeaths: %i\nKills: %i\nPassword: %s",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills], inputtext);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 4:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nModerator\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 5:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nModerator\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 6:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nDeputy Head Admin\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 7:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nHead Admin\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 8:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nHead Admin\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 9:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nCo-Owner\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
case 10:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nMain Owner\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
default:
{
new string[159], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
}
}
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""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 0;
}