08.03.2015, 15:46
When I register, it goes through the tutorial fine but when I reconnect, I have to login then go through the tutorial steps again?
Код:
public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open( user_account_path ( playerid ) ); INI_SetTag(File, "statistics" ); INI_WriteInt(File, "Level", GetPlayerScore( playerid ) ); INI_WriteInt(File, "Admin", PlayerInfo[ playerid ][ pAdmin ]); INI_WriteInt(File, "RespectPoints", PlayerInfo[ playerid ][ pConnectTime ]); INI_WriteInt(File, "Registered", PlayerInfo[ playerid ][ pReg ]); INI_WriteInt(File, "Gender", PlayerInfo[ playerid ][ pSex ]); INI_WriteInt(File, "Age", PlayerInfo[ playerid ][ pAge ]); INI_WriteInt(File, "Cash", PlayerInfo[ playerid ][ pCash ]); INI_WriteInt(File, "Tutorial", PlayerInfo[ playerid ][ pTut ]); INI_WriteInt(File, "Job", PlayerInfo[ playerid ][ pJob ]); INI_Close(File); } return 1; }
Код:
public OnPlayerConnect(playerid) { if( fexist ( user_account_path ( playerid ) ) ) { INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome.Please log-in",""COL_WHITE"Type your "COL_GREEN"password "COL_WHITE"here to log-in", #Log-in, #Quit); SpawnPlayer(playerid); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registration!",""COL_WHITE"Type your "COL_GREEN"password "COL_WHITE"here to register", #Register, #Quit); PlayerInfo[ playerid ][ pLevel ] = 0; PlayerInfo[ playerid ][ pAdmin ] = 0; PlayerInfo[ playerid ][ pConnectTime ] = 0; PlayerInfo[ playerid ][ pReg ] = 0; PlayerInfo[ playerid ][ pSex ] = 0; PlayerInfo[ playerid ][ pAge ] = 0; PlayerInfo[ playerid ][ pCash ] = 0; PlayerInfo[ playerid ][ pTut ] = 0; PlayerInfo[ playerid ][ pJob ] = 0; } return 1; }
Код:
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_WHITE"Welcome.Please log-in","You have entered an "COL_RED"invalid"COL_WHITE" password\n"COL_WHITE"Type your "COL_GREEN"password "COL_WHITE"here to log-in", #Register, #Quit); new hashed_password[ 129 ]; WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext ); new INI:File = INI_Open( user_account_path( playerid ) ); INI_SetTag(File, "statistics" ); INI_WriteString(File, "Password", hashed_password ); INI_WriteInt(File, "Level", 0 ); INI_WriteInt(File, "Admin", 0 ); INI_WriteInt(File, "RespectPoints", 0 ); INI_WriteInt(File, "Registered", 0 ); INI_WriteInt(File, "Gender", 0 ); INI_WriteInt(File, "Age", 0 ); INI_WriteInt(File, "Cash", 0 ); INI_WriteInt(File, "Tutorial", 0 ); INI_WriteInt(File, "Job", 0 ); INI_Close(File); SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 ); SpawnPlayer( playerid ); } } case DIALOG_LOGIN: { if ( !response ) return Kick ( playerid ); if( response ) { new hashed_password[ 129 ]; WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext ); if( !strcmp ( hashed_password, PlayerInfo[ playerid ][ pKey ] ) ) { INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid); GivePlayerMoney( playerid, PlayerInfo[ playerid ][ pCash ] ); SetPlayerScore( playerid, PlayerInfo[ playerid ][ pLevel ] ); } 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; } } } TUTORIAL UNDER HERE