22.10.2013, 13:17
Hey, I'm trying to put the following code in OnPlayerConnect - which checks if the player is banned, registered, if not then pops Registration, if so, the login window.
I have this code (i just want to move it to OnPlayerConnect):
help me, please
I have this code (i just want to move it to OnPlayerConnect):
Код:
//============================================================================// public OnQueryError( errorid, error[ ], resultid, extraid, callback[ ], query[ ], connectionHandle ) return printf( "errorid: %d | error: %s | resultid: %d | extraid: %d | callback: %s | query: %s", errorid, error, resultid, extraid, callback, query ); //============================================================================// public OnQueryFinish( query[ ], resultid, extraid, connectionHandle ) { session[ queries ]++; switch( resultid ) { case THREAD_CHECK_BANS_LIST: { mysql_store_result( ); if ( !IsPlayerConnected( extraid ) ) return mysql_free_result( ); gsString[ 0 ] = EOS; new bField[ 5 ][ 128 ], liDay, liMonth, liYear, Ban_Day, Ban_Month, Ban_Year ; if ( mysql_retrieve_row( ) ) { mysql_get_field( "Reason", bField[ 0 ] ); mysql_get_field( "Admin", bField[ 1 ] ); mysql_get_field( "BanDate", bField[ 2 ] ); mysql_get_field( "BanTime", bField[ 3 ] ); mysql_get_field( "BanDays", bField[ 4 ] ); mysql_free_result( ); getdate( liYear, liMonth, liDay ); sscanf( bField[ 4 ], "p<->iii", Ban_Day, Ban_Month, Ban_Year ); if ( Ban_Day > liDay || Ban_Month > liMonth || Ban_Year > liYear ) { TextDrawShowForPlayer( extraid, Ban_Backround ); TextDrawShowForPlayer( extraid, Ban_Info ); TextDrawShowForPlayer( extraid, Ban_Message ); TextDrawShowForPlayer( extraid, Ban_Details_TD ); TextDrawShowForPlayer( extraid, Ban_Mistake ); gsString[ 0 ] = EOS; format( gsString, sizeof( gsString ), "Banned by Administrator: %s~n~Ban Date: %s~n~Ban Time: %s~n~Ban Reason: %s~n~Un-Ban After: %s", bField[ 1 ], bField[ 2 ], bField[ 3 ], bField[ 0 ], bField[ 4 ] ); TextDrawSetString( Ban_Details[ extraid ], gsString ); TextDrawShowForPlayer( extraid, Ban_Details[ extraid ] ); SetTimerEx( "KickPlayer", 1000, false, "e", extraid ); } else { format( gsQuery, 128, "DELETE FROM `Banlist` WHERE `Name` = '%s'", PlayerName( extraid ) ); mysql_query( gsQuery, THREAD_NONE, extraid ); CheckPlayerAccount( extraid ); //OnPlayerConnectEx( extraid ); } } else { CheckPlayerAccount( extraid ); //OnPlayerConnectEx( extraid ); } return ( 1 ); } case THREAD_CHECK_ACCOUNT_USERNAME: { mysql_store_result( ); if ( !IsPlayerConnected( extraid ) ) return mysql_free_result( ); gsString[ 0 ] = EOS; new pField[ 20 ] ; if ( mysql_num_rows( ) == 0 ) { SetPlayerPos( extraid, 379.6912, -1820.0995, 14.5818 ); InterpolateCameraPos(extraid, 340.322845, -1787.762329, 36.462806, 359.668670, -1823.054565, 47.012962, 2000, 1); InterpolateCameraLookAt(extraid, 341.032104, -1783.830444, 36.656478, 357.083160, -1824.181030, 44.176395, 2000, 1); SendClientMessage( extraid, ~1, ""R"SE {7A7A7A}»{DBED15} {FFE4C4}This account is not registered. Register your account to gain access to bonus commands and features!" ); new RegisterDS [ 1024 ]; RegisterDS[0]='\0'; format(RegisterDS, sizeof(RegisterDS),""W"Welcome to "NAME_S", "YE"%s\n\n", PlayerName( extraid )); strcat(RegisterDS,""W"You are not registered yet on this server,\n"); strcat(RegisterDS,""W"Enter your password below to register\n"); strcat(RegisterDS,""W"By registering all your statistics will be saved in server database!\n\n"); strcat(RegisterDS,""R"Info"W":\n"); strcat(RegisterDS,""R"- "W"Your password must contain at least 4 characters\n"); strcat(RegisterDS,""R"- "W"Remember your password, you will need it for your next login\n"); strcat(RegisterDS,""R"- "W"You can easy acces "O"site"W"for password recover\n"); ShowPlayerDialog( extraid, RegDialog, DIALOG_STYLE_PASSWORD, ""R"#1 "W"Register Account", RegisterDS, "(Register)","" ); } else { mysql_retrieve_row( ); mysql_get_field( "IP", pField ); if ( !strcmp( GetPlayerIPEx( extraid ), pField, true ) ) { SetPlayerPos( extraid, 379.6912, -1820.0995, 14.5818 ); InterpolateCameraPos(extraid, 359.668670, -1823.054565, 47.012962, 388.264221, -1812.667846, 17.180328, 2000, 1); InterpolateCameraLookAt(extraid, 357.083160, -1824.181030, 44.176395, 384.659332, -1814.355346, 16.784107, 2000, 1); format( gsQuery, sizeof gsQuery, "SELECT * FROM `Accounts` WHERE `Name` = '%s'", PlayerName( extraid ) ); mysql_query( gsQuery, THREAD_PLAYER_ACCOUNT_LOGIN, extraid ); InfoTD_MSG( extraid, 4000, "You have been automatically ~g~~h~logged in" ); TogglePlayerSpectating( extraid, false ); } else { SetPlayerPos( extraid, 379.6912, -1820.0995, 14.5818 ); InterpolateCameraPos(extraid, 359.668670, -1823.054565, 47.012962, 388.264221, -1812.667846, 17.180328, 2000, 1); InterpolateCameraLookAt(extraid, 357.083160, -1824.181030, 44.176395, 384.659332, -1814.355346, 16.784107, 2000, 1); SendClientMessage( extraid, ~1, ""R"SE {7A7A7A}»{DBED15} {FFE4C4}This account is registered. Please login to get your status and to gain acces to all commands and features!" ); gsString[ 0 ] = EOS; format( gsString, sizeof( gsString ), "~r~~h~Welcome, ~b~~h~%s~r~~h~!~n~~w~You may login now (/login)!", PlayerName( extraid ) ); InfoTD_MSG( extraid, 7000, gsString ); TogglePlayerSpectating( extraid, false ); } } mysql_free_result( ); return ( 1 ); } //...code, code, code ; ) ... } return ( 1 ); }