enum pInfo { pPass, pCash, pAdmin, pKills, pDeaths, pScore, pCaptures, God, GodCar, banned, Warnings, pPlayersloggedin, pPlayersregistered } public LoadUser_AccountData(playerid,name[],value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Banned",PlayerInfo[playerid][banned]); INI_Int("Warnings",PlayerInfo[playerid][Warnings]); INI_Int("Cash",PlayerInfo[playerid][pCash]); //INI_Int("Admin",PlayerInfo[playerid][pAdmin]); PlayerInfo[playerid][pAdmin]=0; INI_Int("Kills",PlayerInfo[playerid][pKills]); INI_Int("Deaths",PlayerInfo[playerid][pDeaths]); INI_Int("Score",PlayerInfo[playerid][pScore]); INI_Int("Captures",PlayerInfo[playerid][pCaptures]); INI_Int("Rank",ranklvl[playerid]); INI_Int("PlayersLoggedIn",PlayerInfo[playerid][pPlayersloggedin]); INI_Int("PlayersRegistered",PlayerInfo[playerid][pPlayersregistered]); return 1; }
//onplayerdisconnect INI_WriteString(File,"Name",name); INI_WriteString(File,"Ip",plrIP); INI_WriteInt(File,"Registered",fexist(UserPath(playerid))); INI_WriteInt(File,"LoggedIn",IsPlayerConnected(playerid)); INI_WriteInt(File,"LoggedIn",0); INI_WriteInt(File,"Warnings",PlayerInfo[playerid][Warnings]); INI_WriteInt(File,"Banned",PlayerInfo[playerid][banned]); INI_WriteInt(File,"Ping",GetPlayerPing(playerid)); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt(File,"Score",GetPlayerScore(playerid)); INI_WriteInt(File,"Rank",ranklvl[playerid]); INI_WriteInt(File,"Captures",capturedzones[playerid]); INI_WriteInt(File,"PlayersLoggedIn",playersloggedin); INI_WriteInt(File,"PlayersRegistered",playersregistered);
//onplayerupdate INI_WriteString(File,"Name",name); INI_WriteInt(File,"Registered",fexist(UserPath(playerid))); INI_WriteInt(File,"LoggedIn",IsPlayerConnected(playerid)); INI_WriteInt(File,"PlayersLoggedIn",playersloggedin); INI_WriteInt(File,"PlayersRegistered",playersregistered); INI_WriteInt(File,"Ping",GetPlayerPing(playerid)); new plrIP[16]; GetPlayerIp(playerid, plrIP, sizeof(plrIP)); INI_WriteString(File,"Ip",plrIP); //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_WriteInt(File,"Score",GetPlayerScore(playerid)); INI_WriteInt(File,"Rank",ranklvl[playerid]); INI_WriteInt(File,"Captures",capturedzones[playerid]);
//and the last one is the register(dialog) INI_WriteString(File,"Name",name); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteString(File,"Ip",plrIP); INI_WriteInt(File,"Registered",1); INI_WriteInt(File,"LoggedIn",1); INI_WriteInt(File,"Banned",0); INI_WriteInt(File,"Ping",0); INI_WriteInt(File,"PlayersLoggedIn",playersloggedin); INI_WriteInt(File,"PlayersRegistered",playersregistered); INI_WriteInt(File,"Cash",0); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"Score",0); INI_WriteInt(File,"Rank",0); INI_WriteInt(File,"Captures",0);
//dialog of register 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 plrIP[16]; GetPlayerIp(playerid, plrIP, sizeof(plrIP)); new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); INI_SetTag(File,"AccountData"); INI_WriteString(File,"Name",name); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteString(File,"Ip",plrIP); INI_WriteInt(File,"Registered",1); INI_WriteInt(File,"LoggedIn",1); INI_WriteInt(File,"Banned",0); INI_WriteInt(File,"Ping",0); INI_WriteInt(File,"PlayersLoggedIn",playersloggedin); INI_WriteInt(File,"PlayersRegistered",playersregistered); INI_WriteInt(File,"Cash",0); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"Score",0); INI_WriteInt(File,"Rank",0); INI_WriteInt(File,"Captures",0); PlayerInfo[playerid][pPlayersregistered]++; INI_Close(File); //new listitems1[] = "{FFFF00}Europe Alliance:0{FFFF00}\n{33CCFF}United States Of America:0{33CCFF}\n{00FF00}Sovjet Union:0{00FF00}\n{660000}Japan:0{660000}\n{FF8040}Asian Empire:0{FF8040}\n{FF00FF}Russia:0{FF00FF}\n{800080}Australiл:0{800080}\n{FFFFFF}Afghanistan:0{FFFFFF}"; //ShowPlayerDialog(playerid,3,DIALOG_STYLE_LIST,"**Select Your Team!**:",listitems1,"Select",""); //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",""); } }
//onplayerdisconnect public OnPlayerDisconnect(playerid, reason) { new string[64], name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,MAX_PLAYER_NAME); switch(reason) { case 0: format(string,sizeof string,"%s left the server. (Timed out)",name); case 1: format(string,sizeof string,"%s left the server. (Leaving)",name); case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name); } pCount[playerid] = 0; playersloggedin--; SendClientMessageToAll(COLOR_GREY,string); new INI:File = INI_Open(UserPath(playerid)); new plrIP[16]; INI_SetTag(File,"AccountData"); SetTimerEx("CheckSpawnPosition", 8000, false, "i", playerid); //time is in milliseconds (8000 Milliseconds = 8 Seconds) GetPlayerName(playerid, name, sizeof(name)); INI_WriteString(File,"Name",name); INI_WriteString(File,"Ip",plrIP); INI_WriteInt(File,"Registered",fexist(UserPath(playerid))); INI_WriteInt(File,"LoggedIn",IsPlayerConnected(playerid)); INI_WriteInt(File,"LoggedIn",0); INI_WriteInt(File,"Warnings",PlayerInfo[playerid][Warnings]); INI_WriteInt(File,"Banned",PlayerInfo[playerid][banned]); INI_WriteInt(File,"Ping",GetPlayerPing(playerid)); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt(File,"Score",GetPlayerScore(playerid)); INI_WriteInt(File,"Rank",ranklvl[playerid]); INI_WriteInt(File,"Captures",capturedzones[playerid]); INI_WriteInt(File,"PlayersLoggedIn",playersloggedin); INI_WriteInt(File,"PlayersRegistered",playersregistered); Delete3DTextLabel(label[playerid]); GetPlayerIp(playerid, plrIP, sizeof(plrIP)); INI_Close(File); return 1; }
Код:
//dialog of register 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 plrIP[16]; GetPlayerIp(playerid, plrIP, sizeof(plrIP)); new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); INI_SetTag(File,"AccountData"); INI_WriteString(File,"Name",name); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteString(File,"Ip",plrIP); INI_WriteInt(File,"Registered",1); INI_WriteInt(File,"LoggedIn",1); INI_WriteInt(File,"Banned",0); INI_WriteInt(File,"Ping",0); INI_WriteInt(File,"PlayersLoggedIn",playersloggedin); INI_WriteInt(File,"PlayersRegistered",playersregistered); INI_WriteInt(File,"Cash",0); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"Score",0); INI_WriteInt(File,"Rank",0); INI_WriteInt(File,"Captures",0); PlayerInfo[playerid][pPlayersregistered]++; INI_Close(File); //new listitems1[] = "{FFFF00}Europe Alliance:0{FFFF00}\n{33CCFF}United States Of America:0{33CCFF}\n{00FF00}Sovjet Union:0{00FF00}\n{660000}Japan:0{660000}\n{FF8040}Asian Empire:0{FF8040}\n{FF00FF}Russia:0{FF00FF}\n{800080}Australiл:0{800080}\n{FFFFFF}Afghanistan:0{FFFFFF}"; //ShowPlayerDialog(playerid,3,DIALOG_STYLE_LIST,"**Select Your Team!**:",listitems1,"Select",""); //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",""); } } Код:
//onplayerdisconnect public OnPlayerDisconnect(playerid, reason) { new string[64], name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,MAX_PLAYER_NAME); switch(reason) { case 0: format(string,sizeof string,"%s left the server. (Timed out)",name); case 1: format(string,sizeof string,"%s left the server. (Leaving)",name); case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name); } pCount[playerid] = 0; playersloggedin--; SendClientMessageToAll(COLOR_GREY,string); new INI:File = INI_Open(UserPath(playerid)); new plrIP[16]; INI_SetTag(File,"AccountData"); SetTimerEx("CheckSpawnPosition", 8000, false, "i", playerid); //time is in milliseconds (8000 Milliseconds = 8 Seconds) GetPlayerName(playerid, name, sizeof(name)); INI_WriteString(File,"Name",name); INI_WriteString(File,"Ip",plrIP); INI_WriteInt(File,"Registered",fexist(UserPath(playerid))); INI_WriteInt(File,"LoggedIn",IsPlayerConnected(playerid)); INI_WriteInt(File,"LoggedIn",0); INI_WriteInt(File,"Warnings",PlayerInfo[playerid][Warnings]); INI_WriteInt(File,"Banned",PlayerInfo[playerid][banned]); INI_WriteInt(File,"Ping",GetPlayerPing(playerid)); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt(File,"Score",GetPlayerScore(playerid)); INI_WriteInt(File,"Rank",ranklvl[playerid]); INI_WriteInt(File,"Captures",capturedzones[playerid]); INI_WriteInt(File,"PlayersLoggedIn",playersloggedin); INI_WriteInt(File,"PlayersRegistered",playersregistered); Delete3DTextLabel(label[playerid]); GetPlayerIp(playerid, plrIP, sizeof(plrIP)); INI_Close(File); return 1; } |
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pKills] = 0; // As for integers.
PlayerInfo[playerid][Coordinate] = 0.0; // As for floats.
format(PlayerInfo[playerid][BanMSG], sizeof(PlayerInfo[playerid][BanMSG]),"Not banned."); // As for strings.
}
As server doesn't restart, and when a player joins, he/she takes the first available id in order, the variables of that id still have the value set before for the first id user, so all you have to make is, when player connects, it sets all values to the default, for example:
pawn Код:
|