29.07.2011, 20:38
rjjj theres more...
Here is the total fixed code.
Here is the total fixed code.
Код:
#include <a_samp> #include <SII> // Include SII.inc #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 enum pInfo { pName[25], pPass[34], pLevel, pMoney, pKills, pDeaths, pAdmin, } new PlayerInfo[MAX_PLAYERS][pInfo]; new Player_Name[MAX_PLAYERS][MAX_PLAYER_NAME]; new bool: player_loggedin[MAX_PLAYERS]; //kills and deaths // dialouge defines #define DIALOG_REGISTER 2000 #define DIALOG_LOGIN 2001 // colors define for login #define WHITE "{FFFFFF}" #define RED "{F81414}" #define GREEN "{00FF22}" #define LIGHTBLUE "{00CED1}" stock getINI(playerid) { new account[64]; format(account,30,"Users/%s.ini",PlayerInfo[playerid][pName]); return account; } main() { } public OnGameModeInit() { AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; } public OnPlayerConnect(playerid) { GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME); format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, "%s", Player_Name[playerid]); if (fexist(getINI(playerid))) { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit"); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""WHITE"Registering...",""WHITE"Type your password below to register a new account.","Register","Quit"); } return 1; } public OnPlayerDisconnect(playerid) { if(INI_Open(getINI(playerid))) { player_loggedin[playerid] = false; INI_WriteString("Name",PlayerInfo[playerid][pName]); INI_WriteString("Password",PlayerInfo[playerid][pPass]); INI_WriteInt("Level",PlayerInfo[playerid][pLevel]); INI_WriteInt("Money",PlayerInfo[playerid][pMoney]); INI_WriteInt("Kills",PlayerInfo[playerid][pKills]); INI_WriteInt("Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt("Admin",PlayerInfo[playerid][pAdmin]); INI_Save(); INI_Close(); } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch( dialogid ) { case DIALOG_REGISTER: { if (!response) return Kick(playerid); if (response) { if(!strlen(inputtext)) { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit"); } if(INI_Open(getINI(playerid))) { INI_WriteString("Name", PlayerInfo[playerid][pName]); INI_WriteString("Password",inputtext); INI_WriteInt("Level",1); INI_WriteInt("Money",5000); INI_WriteInt("Kills", PlayerInfo[playerid][pKills]); INI_WriteInt("Deaths", PlayerInfo[playerid][pDeaths]); INI_WriteInt("Admin",0); INI_Save(); INI_Close(); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit"); } } } case DIALOG_LOGIN: { if ( !response ) return Kick ( playerid ); if( response ) { if(!strlen(inputtext)) { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit"); } if(INI_Open(getINI(playerid))) { INI_ReadString(PlayerInfo[playerid][pPass],"Password",20); if(strcmp(inputtext,PlayerInfo[playerid][pPass],false)) { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit"); } player_loggedin[playerid] = true; SetPlayerScore( playerid, INI_ReadInt("Level" )); ResetPlayerMoney( playerid ); GivePlayerMoney( playerid, INI_ReadInt( "Money" )); PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin"); INI_Close(); } } } } return 1; } public OnPlayerDeath(playerid, killerid, reason) { PlayerInfo[killerid][pKills]++; // The killer value will be increased PlayerInfo[playerid][pDeaths]++; // The death value will be increased return 1; }