Lucky Spin ...added a lucky choice...previously was unable to find luckyid in table..this is the fix i came up with..now delivers item to mileage storage
So first at top of WorldPackets.cpp add this line
- // Observe: Dirty way of loading LuckySpin Items
- int luckyArray[109];
- int luckychoice[109];
then replace pak spinwheel with this
- // Observe: Luckspin spin the wheel!
- bool CWorldServer::pakSpinWheel ( CPlayer* thisclient, CPacket* P )
- {
- BEGINPACKET ( pak, 0x7f1 );
- if(thisclient->CharInfo->LuckySpins < 1){ // Not enough Spins
- ADDBYTE ( pak, 2 );
- ADDDWORD ( pak, 0 );
- ADDDWORD ( pak, 0 );
- thisclient->client->SendPacket( &pak );
- } else { // Let the wheel spin
- int wonItem = RandNumber(1,12);
-
- Log(MSG_DEBUG,"%s won %i", thisclient->CharInfo->charname, luckychoice[wonItem]);
- thisclient->CharInfo->LuckySpins -= 1;
- thisclient->CharInfo->LuckyShuffles = 5;
- ADDBYTE ( pak, 1 );
- ADDDWORD ( pak, 0 );
- ADDDWORD ( pak, 1 );
-
- ADDDWORD ( pak, wonItem );
- ADDDWORD ( pak, luckychoice[wonItem] );
- ADDDWORD ( pak, 1 );
- ADDDWORD ( pak, 1 );
- thisclient->client->SendPacket( &pak );
-
- MYSQL_RES *winning = GServer->DB->QStore("SELECT itemid,itemtype FROM luckyspin WHERE id='%i'", luckychoice[wonItem]);
- MYSQL_ROW row = mysql_fetch_row(winning);
- int itemID = atoi(row[0]);
- int itemType = atoi(row[1]);
- GServer->DB->FreeResult( );
-
- int slotNum = 0;
- MYSQL_RES *result = GServer->DB->QStore("SELECT * FROM mileage WHERE owner='%i'", thisclient->Session->userid);
- if(result==NULL){
- slotNum = 0;
- } else {
- slotNum = mysql_num_rows(result)+1;
- }
- GServer->DB->FreeResult( );
-
- GServer->DB->Query("INSERT INTO mileage (`owner`,`itemnum`,`itemtype`,`count`,`slotnum`) VALUES ('%i','%i','%i','1','%i')",thisclient->Session->userid,itemID,itemType,slotNum);
- thisclient->savedata( );
-
- luckychoice[0] = 0;
- }
-
- return true;
- }
then replace pak luckyspin with this
-
- // Observe: Luckyspin initial items
- bool CWorldServer::pakLuckySpin( CPlayer* thisclient, CPacket* P )
- {
- MYSQL_RES *result = GServer->DB->QStore("SELECT itemid, itemtype, id FROM luckyspin WHERE active='1' ORDER BY rand() LIMIT 12");
- if(result==NULL) return false;
-
- if(!luckyArray[0] || luckyArray[0] == 0){
- int x = 0;
-
-
- while(MYSQL_ROW row = mysql_fetch_row(result)){
- int count = mysql_num_rows(result);
-
- if(x < count){
- luckyArray[x] = (atoi(row[1])*1000000) + atoi(row[0]);
- luckychoice[x] = (atoi (row[2]));
- Log(MSG_DEBUG,"luckyArray[%i] item: %i", x, luckyArray[x]);
- Log (MSG_DEBUG,"luckychoice[%i] item: %i",x, luckychoice[x]);
- x++;
- }
- }
- }
-
- BEGINPACKET ( pak, 0x7f2 );
- ADDDWORD ( pak, mysql_num_rows(result) );
- ADDDWORD ( pak, thisclient->CharInfo->LuckySpins );
- ADDDWORD ( pak, thisclient->CharInfo->LuckyShuffles );
- ADDDWORD ( pak, 12 );
-
- for(int i=0; i<12; i++){
- ADDDWORD ( pak, i );
- ADDDWORD ( pak, luckyArray[i] );
- ADDDWORD ( pak, luckychoice[i] );
- ADDDWORD ( pak, 1 );
- ADDDWORD ( pak, 1 );
- ADDDWORD ( pak, i );
- }
-
- thisclient->client->SendPacket( &pak);
-
- GServer->DB->FreeResult( );
- return true;
- }
-
and lastly replace pak luckyshuffle with this
- // Observe: Shuffle Luckyspin items
- bool CWorldServer::pakLuckySpinShuffle ( CPlayer* thisclient, CPacket* P )
- {
- if(thisclient->CharInfo->LuckyShuffles > 0){
- int shufflesleft = thisclient->CharInfo->LuckyShuffles -= 1;
- BEGINPACKET( pak, 0x7ef );
- ADDBYTE ( pak, 0x01 ); // Action
- ADDDWORD ( pak, shufflesleft ); // Shuffles Left
- ADDDWORD ( pak, 12 ); // Amount of item (Always 12)
-
- MYSQL_RES *result = GServer->DB->QStore("SELECT itemid,itemtype,id FROM luckyspin WHERE active='1' ORDER BY rand() LIMIT 12");
- if(result==NULL) return false;
-
- int x = 0;
- while(MYSQL_ROW row = mysql_fetch_row(result)){
- int count = mysql_num_rows(result);
-
- if(x < count){
- luckyArray[x] = (atoi(row[1])*1000000) + atoi(row[0]);
- luckychoice[x] = (atoi (row[2]));
- Log(MSG_DEBUG,"luckyArray[%i] item: %i", x, luckyArray[x]);
- Log(MSG_DEBUG,"luckychoice[%i] item: %i", x, luckychoice[x]);
- x++;
- }
- }
-
- for(byte i=0; i<12; i++)
- {
- ADDDWORD ( pak, i );
- ADDDWORD ( pak, luckyArray[i] );
- ADDDWORD ( pak, 1 );
- ADDDWORD ( pak, RandNumber(1,4));
- }
-
- GServer->DB->FreeResult( );
- thisclient->client->SendPacket( &pak );
- return true;
- } else {
- Log(MSG_WARNING,"%s tried to shuffle with %i shuffles!",thisclient->CharInfo->charname,thisclient->CharInfo->LuckyShuffles);
- return true;
- }
- }
-
now the item should be placed in the mileage storage