#define dregister 2011 #define dlogin 2012 #define UserPath "Users/%s.ini" native WP_Hash(buffer[],len,const str[]); new gTeam[MAX_PLAYERS]; enum PlayerInfo { Pass[129], Adminlevel, VIPlevel, Testerlevel, Money, Scores, Kills, Deaths, pBanned, BannedIP[22] } new pInfo[MAX_PLAYERS][PlayerInfo]; stock Path(playerid) { new str[128],name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); format(str,sizeof(str),UserPath,name); return str; } forward loadaccount_user(playerid, name[], value[]); public loadaccount_user(playerid, name[], value[]) { INI_String("Password", pInfo[playerid][Pass],129); INI_Int("AdminLevel",pInfo[playerid][Adminlevel]); INI_Int("VIPlevel",pInfo[playerid][VIPlevel]); INI_Int("Testerlevel",pInfo[playerid][Testerlevel]); INI_Int("Money",pInfo[playerid][Money]); INI_Int("Scores",pInfo[playerid][Scores]); INI_Int("Kills",pInfo[playerid][Kills]); INI_Int("Deaths",pInfo[playerid][Deaths]); INI_Int("pBanned",pInfo[playerid][pBanned]); INI_Int("BannedIP",pInfo[playerid][BannedIP]); return 1; } forward LoadIP_data(playerid, name[], value[]); public LoadIP_data(playerid, name[], value[]) { INI_String("Ip", pInfo[ playerid ][ BannedIP ], 33); return 1; } public OnPlayerDisconnect(playerid, reason) { new IP[22]; GetPlayerIp(playerid, IP, sizeof(IP)); new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player's Data"); INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]); INI_WriteInt(file,"Testerlevel",pInfo[playerid][Testerlevel]); INI_WriteInt(file,"Money",GetPlayerMoney(playerid)); INI_WriteString(file, "Ip", IP); INI_WriteInt(file,"Scores",GetPlayerScore(playerid)); INI_WriteInt(file,"Kills",pInfo[playerid][Kills]); INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]); INI_Close(file); return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == dregister) { if(!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) { ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_PASSWORD,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit"); return 1; } new hashpass[129]; WP_Hash(hashpass,sizeof(hashpass),inputtext); new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player's Data"); INI_WriteString(file,"Password",hashpass); INI_WriteInt(file,"AdminLevel",0); INI_WriteInt(file,"VIPLevel",0); INI_WriteInt(file,"Testerlevel",0); INI_WriteInt(file,"Money",0); INI_WriteInt(file,"Scores",0); INI_WriteInt(file,"Kills",0); INI_WriteInt(file,"Deaths",0); INI_Close(file); SendClientMessage(playerid,-1,"You have been successfully registered"); return 1; } } if(dialogid == dlogin) { if(!response) return Kick(playerid); if(response) { new hashpass[129]; WP_Hash(hashpass,sizeof(hashpass),inputtext); if(!strcmp(hashpass, pInfo[playerid][Pass], false)) { INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid); SetPlayerScore(playerid,pInfo[playerid][Scores]); GivePlayerMoney(playerid,pInfo[playerid][Money]); SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in"); } else { ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit"); return 1; } } } return 1; }
pInfo[playerid][Adminlevel] = 0;
pInfo[playerid][VIPlevel] = 0;
pInfo[playerid][Testerlevel] = 0;
pInfo[playerid][Money] = 0;
pInfo[playerid][Scores] = 0;
pInfo[playerid][Kills] = 0;
pInfo[playerid][Deaths] = 0;
pInfo[playerid][pBanned] = 0;
pInfo[playerid][BannedIP] = 0;
on player connect add:
PHP код:
|
new
resetpInfo[PlayerInfo];
pInfo[playerid] = resetpInfo;