Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.39 KB | None | 0 0
  1. BOOL BellatraServer::UpdateClanBellatra()
  2. {
  3.     if ( GAME_SERVER )
  4.         return TRUE;
  5.  
  6.     if ( dwClanBellatraUpdateTime > TICKCOUNT )
  7.         return TRUE;
  8.  
  9.     dwClanBellatraUpdateTime = TICKCOUNT + 30000;
  10.  
  11.  
  12.     char szCharName[32]     = { 0 };
  13.     char szCharName2[32]    = { 0 };
  14.     int iPoint              = 0;
  15.     int iCode               = 0;
  16.     int iTotalPoint         = 0;
  17.     int iSuccessUser        = 0;
  18.     int iCurrentClanPoint   = 0;
  19.     int iTotalPlayers       = 0;
  20.     char szClanName[32]     = { 0 };
  21.     char szClanName2[32]    = { 0 };
  22.     SQLConnection * pcDB    = SQLCONNECTION( DATABASEID_ClanDB );
  23.  
  24.     SYSTEMTIME sTime;
  25.     GetLocalTime( &sTime );
  26.     if ( sTime.wDayOfWeek == 6 && sTime.wDay != wLastDayResetSOD )
  27.     {
  28.         ResetBellatra();
  29.         wLastDayResetSOD = sTime.wDay;
  30.     }
  31.  
  32.     if ( pcDB->Open() )
  33.     {
  34.         // Get Sod Data
  35.         if ( pcDB->Prepare( "SELECT CharacterName,Code,TotalPoint,SuccessUser FROM BellatraTeamScore" ) )
  36.         {
  37.             // Have data?
  38.             if ( pcDB->Execute() && pcDB->Fetch() )
  39.             {
  40.                 // Fetch results
  41.                 while ( true )
  42.                 {
  43.                     pcDB->GetData( 1, PARAMTYPE_String, szCharName, 32 );
  44.                     pcDB->GetData( 2, PARAMTYPE_Integer, &iCode, 0 );
  45.                     pcDB->GetData( 3, PARAMTYPE_Integer, &iTotalPoint, 0 );
  46.                     pcDB->GetData( 4, PARAMTYPE_Integer, &iSuccessUser, 0 );
  47.  
  48.                     // Have points or more than 3 users in the room?
  49.                     if ( iTotalPoint > 0 || iSuccessUser >= iMinimalUserClanPoints )
  50.                     {
  51.                         // Get User Clan
  52.                         GetClanName( szCharName, szClanName );
  53.                         // Get current clan point
  54.                         iCurrentClanPoint       = GetClanPoint( szClanName );
  55.                         iTotalPlayers           = 1;
  56.                         SQLConnection * pcDB2   = SQLCONNECTION( DATABASEID_ClanDB_2 );
  57.                         if ( pcDB2->Open() )
  58.                         {
  59.                             // Get Users mistmatch point and room
  60.                             if ( pcDB2->Prepare( "SELECT CharacterName,Score FROM BellatraTeamScore WHERE (Code=?) AND (TotalPoint=?) AND (SuccessUser=?)" ) )
  61.                             {
  62.                                 pcDB2->BindParameterInput( 1, PARAMTYPE_Integer, &iCode );
  63.                                 pcDB2->BindParameterInput( 2, PARAMTYPE_Integer, &iTotalPoint );
  64.                                 pcDB2->BindParameterInput( 3, PARAMTYPE_Integer, &iSuccessUser );
  65.  
  66.                                 int iCount = 0;
  67.                                 if ( pcDB2->Execute()  && pcDB2->Fetch() )
  68.                                 {
  69.                                     // Fetch results
  70.                                     while ( true )
  71.                                     {
  72.                                         szCharName2[0] = '\0';
  73.                                         pcDB2->GetData( 1, PARAMTYPE_String, szCharName2, 32 );
  74.                                         pcDB2->GetData( 2, PARAMTYPE_Integer, &iPoint, 0 );
  75.  
  76.                                         // User have point?
  77.                                         if ( iPoint > 0 )
  78.                                         {
  79.                                             // Not current user?
  80.                                             if ( !STRINGCOMPAREI( szCharName, szCharName2 ) )
  81.                                             {
  82.                                                 // Get clan name of this next user
  83.                                                 GetClanName( szCharName2, szClanName2 );
  84.                                                 // Mismatch clan? Add players of same clan
  85.                                                 if ( STRINGCOMPAREI( szClanName, szClanName2 ) )
  86.                                                     iTotalPlayers++;
  87.                                                 else
  88.                                                     iTotalPoint -= iPoint; // Decrease point
  89.                                             }
  90.                                         }
  91.                                         // Next user result
  92.                                         if ( !pcDB2->Fetch() )
  93.                                             break;
  94.                                     }
  95.                                 }
  96.                             }
  97.                             pcDB2->Close();
  98.                         }
  99.                         // More than 3 users in the room that is same clan and new Point is more than Old Point? Record clan point
  100.                         if ( iTotalPlayers >= iMinimalUserClanPoints && iTotalPoint > iCurrentClanPoint )
  101.                             RecordClanPoint( szClanName, iTotalPoint, iCurrentClanPoint );
  102.                     }
  103.                     // Next Sod data
  104.                     if ( !pcDB->Fetch() )
  105.                         break;
  106.                 }
  107.             }
  108.         }
  109.         pcDB->Close();
  110.     }
  111.     return TRUE;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement