Here's some code to fix the issue where storing items does not cost any zuly.
This code is written for Osirose, but i guess it will work in any version.
This code is included in osiRose [REV 87]
Component: World Server
File: worldpackets.cpp
Line: Around 2777
Action : Replace function pakChangeStorage with code below:
- bool CWorldServer::pakChangeStorage( CPlayer* thisclient, CPacket* P)
- {
- // Change Storage (Deposit/Withdraw items)
- // Modified by FransK ; storing items now cost money.
- // Thanks to [?] for already providing the function GetStorageFee and [?] for the basic function in the first place.
- // May 2013.
- /* Packet for this function
- ===========================
- [BYTE] Action
- [BYTE] Item Slot
- [WORD] Item Head
- [DWORD] Item Body
- [BYTE] Unk (0x00)
- */
- UINT bprice=0; // Item Price (from STB)
- UINT bpricerate=0; // Item Price Rate (from STB)
- UINT bfee=0; // Storage Fee (Calculated)
- BYTE action = GETBYTE((*P),0);
- switch (action)
- {
- case 0x00: //Deposit
- {
- int itemslot = (int)GETBYTE((*P),1);
- CItem clientitem = GetItemByHeadAndData( GETWORD((*P), 2), GETDWORD((*P), 4) );
- if (!CheckInventorySlot( thisclient, itemslot ))
- return false;
- CItem newitem = thisclient->items[itemslot];
- // Set the newitem's count to the count from the client for slot search
- newitem.count = clientitem.count;
- // find an empty or matching slot depending on new item type
- int newslot = thisclient->GetNewStorageItemSlot ( newitem );
- if (newslot==0xffff)
- return true;
- int count = clientitem.count;
- // Stops players from storing more items than they actually have.
- if (count > thisclient->items[itemslot].count)
- count = thisclient->items[itemslot].count;
- // Set the desired amount
- newitem.count = count;
- Log(MSG_INFO, "Request storage by %s, type=%i id=%i, amount=%i",thisclient->CharInfo->charname, newitem.itemtype, newitem.itemnum, newitem.count);
- // Retreive Price information for the item from the STB. Different item types are stored in different tables.
- if(newitem.itemtype<10)
- {
- bprice = EquipList[newitem.itemtype].Index[newitem.itemnum]->price;
- bpricerate = EquipList[newitem.itemtype].Index[newitem.itemnum]->pricerate;
- }
- else
- {
- switch(newitem.itemtype){
- case CONSUMIBLE:
- bprice = GServer->UseList.Index[newitem.itemnum]->price;
- bpricerate = GServer->UseList.Index[newitem.itemnum]->pricerate;
- break;
- case JEM:
- bprice = JemList.Index[newitem.itemnum]->price;
- bpricerate = JemList.Index[newitem.itemnum]->pricerate;
- break;
- case NATURAL:
- bprice = NaturalList.Index[newitem.itemnum]->price;
- bpricerate = NaturalList.Index[newitem.itemnum]->pricerate;
- break;
- case PAT:
- bprice = PatList.Index[newitem.itemnum]->price;
- bpricerate = PatList.Index[newitem.itemnum]->pricerate;
- break;
- }
- }
- // Ok, we got all STB item info, now calculate the storage fee.
- bfee = GetStorageFee(bprice,bpricerate, clientitem.count);
- // Check if client has enough zulies to complete the transaction.
- if (thisclient->CharInfo->Zulies >=bfee){
- if (newitem.itemtype >= 10 && newitem.itemtype <= 12) {
- //is it a stackable type, so must do some math with item counts etc.
- UINT bfee = GetStorageFee(bprice,bpricerate, clientitem.count);
- //add the new items to the storage slot
- if (thisclient->storageitems[newslot].count > 0)
- thisclient->storageitems[newslot].count += newitem.count;
- else
- thisclient->storageitems[newslot] = newitem;
- //delete the items from inventory slot
- thisclient->items[itemslot].count -= count;
- //Remove item + amount from client inventory slot
- if (thisclient->items[itemslot].count <= 0)
- ClearItem(thisclient->items[itemslot]);
- } else {
- // This item is not stackable, so remove it from client inventory slot and add to storage slot.
- ClearItem(thisclient->items[itemslot]);
- thisclient->storageitems[newslot] = newitem;
- }
- // Take the money.
- thisclient->CharInfo->Zulies -=bfee;
- } else {
- // Not Enough Zulie; too bad. Client already pops up a messagbox so we don't have to.
- }
- BEGINPACKET( pak, 0x7ae );
- ADDWORD ( pak, itemslot );
- ADDWORD ( pak, newslot );
- ADDWORD ( pak, BuildItemHead( thisclient->items[itemslot] ) );
- ADDDWORD ( pak, BuildItemData( thisclient->items[itemslot] ) );
- ADDWORD ( pak, BuildItemHead( thisclient->storageitems[newslot] ) );
- ADDDWORD ( pak, BuildItemData( thisclient->storageitems[newslot] ) );
- ADDQWORD ( pak, thisclient->CharInfo->Zulies );
- ADDBYTE ( pak, 0x00 );
- thisclient->client->SendPacket( &pak );
- }
- break;//thanks to anon for post that this break was missing
- case 0x01: //Withdraw
- {
- BYTE storageslot = GETBYTE((*P),1);
- CItem clientitem = GetItemByHeadAndData( GETWORD((*P), 2), GETDWORD((*P), 4) );
- if (storageslot>=160)
- {
- Log( MSG_HACK, "Invalid storage slot %i from %s", storageslot, thisclient->Session->username );
- return false;
- }
- CItem newitem = thisclient->storageitems[storageslot];
- newitem.count = clientitem.count;
- int newslot= thisclient->GetNewItemSlot ( newitem );
- if (newslot == 0xffff)
- return true;
- if (newitem.itemtype>9 && newitem.itemtype<14)
- {
- // This is a useitem.
- WORD count = clientitem.count;
- if ( count > thisclient->storageitems[storageslot].count )
- count = thisclient->storageitems[storageslot].count;
- newitem.count = count;
- if (thisclient->items[newslot].count > 0)
- thisclient->items[newslot].count += newitem.count;
- else
- thisclient->items[newslot] = newitem;
- thisclient->storageitems[storageslot].count -= count;
- if (thisclient->storageitems[storageslot].count<=0)
- ClearItem(thisclient->storageitems[storageslot]);
- }
- else
- //type 1 to 8; Clothing and other stuff that is not stackable etc.
- {
- ClearItem(thisclient->storageitems[storageslot]);
- thisclient->items[newslot] = newitem;
- }
- BEGINPACKET( pak, 0x7ae );
- ADDWORD ( pak, newslot );
- ADDWORD ( pak, storageslot );
- ADDWORD ( pak, BuildItemHead( thisclient->items[newslot] ) );
- ADDDWORD ( pak, BuildItemData( thisclient->items[newslot] ) );
- ADDWORD ( pak, BuildItemHead( thisclient->storageitems[storageslot] ) );
- ADDDWORD ( pak, BuildItemData( thisclient->storageitems[storageslot] ) );
- ADDQWORD ( pak, thisclient->CharInfo->Zulies );
- ADDBYTE ( pak, 0x00 );
- thisclient->client->SendPacket( &pak );
- }
- break;
- default:
- Log( MSG_INFO, "Storage unknown action: %i ", action);
- }
- return true;
- }