Page 1 of 1

[DEV V Rev 12] Redeem Itemmall

PostPosted: Sat May 24, 2014 3:19 pm
by WiseGuy
if it is 'redeem' the item mall is taking all the items to the inventory, I use the following code:

  1.  
  2. bool CWorldServer::pakPremiumRedeem ( CPlayer* thisclient, CPacket* P )
  3. {
  4.     MYSQL_RES *result = GServer->DB->QStore("SELECT COUNT(*) FROM mileage WHERE owner='%i'", thisclient->Session->userid);
  5.     if(result==NULL) return false;
  6.     MYSQL_ROW row = mysql_fetch_row(result);
  7.     int numrow=atoi(row[0]);
  8.     GServer->DB->FreeResult( );
  9.  
  10.     if (numrow==0)
  11.     {
  12.         BEGINPACKET ( pak, 0x819 );
  13.         ADDBYTE     ( pak, 7 );
  14.         for(byte i=0;i<3;i++){
  15.            ADDDWORD ( pak, 0);
  16.         }
  17.         ADDWORD     ( pak, 0);
  18.         thisclient->client->SendPacket( &pak );
  19.         return true;
  20.     }
  21.  
  22.     int qty;
  23.     int slot;
  24.     for (int i=0; i<numrow; i++)
  25.     {
  26.         result = GServer->DB->QStore("SELECT count,slotnum FROM mileage WHERE owner='%i' LIMIT 1", thisclient->Session->userid);
  27.         MYSQL_ROW row = mysql_fetch_row(result);
  28.         qty=atoi(row[0]);
  29.         slot=atoi(row[1]);
  30.         GServer->DB->FreeResult( );
  31.         TakeItemMallList(thisclient,qty,slot);
  32.         GServer-DB->Query("DELETE FROM mileage WHERE owner='%i' AND slotnum='%i'", thisclient->Session->userid,slot);
  33.     }
  34.  
  35.     return true;
  36. }
  37.