- for (int i=0; i<sellcount; i++)
- {
- BYTE slotid = GETBYTE((*P), 8+(buycount*4)+(i*3));
- WORD count = GETWORD((*P), 9+(buycount*4)+(i*3));
- if (thisclient->items[slotid].count < count)
- return true;
- CItem thisitem = thisclient->items[slotid];
- thisitem.count = count;
- if (thisclient->items[slotid].count<thisitem.count)
- {
- Log(MSG_HACK, "[NPC-SELL] Player %s tryes to sell %i [%i:%i], but has only %i",thisclient->CharInfo->charname,thisitem.count,thisitem.itemtype,thisitem.itemnum,thisclient->items[slotid].count);
- return true;
- }
- switch(thisitem.itemtype)
- {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 8:
- case 9:
- case 14:
- {
- float price = 0;
- price = 7.142857E-05F * 5000;
- if(thisitem.itemtype<10)
- {
- price *= EquipList[thisitem.itemtype].Index[thisitem.itemnum]->price;
- }
- else
- {
- price *= PatList.Index[thisitem.itemnum]->price;
- }
- price *= thisitem.durability + 0xc8;
- price *= 40;
- price *= 0xc8 - 0x62; //town rate
- price *= 1.000000E-06;
- //Should fix the merchandising skill
- for(int i = 0;i<MAX_CLASS_SKILL;i++)
- {
- if(thisclient->cskills[i].id == 2286)
- {
- price += (((price * thisclient->cskills[i].thisskill->value2[0]) / 100));
- Log(MSG_INFO,"%i percent added to selling price.", thisclient->cskills[i].thisskill->value2[0]);
- }
- }
- price = (float)floor(price);
- Log( MSG_INFO, "%s:: Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f",thisclient->CharInfo->charname,thisitem.itemnum, thisitem.itemtype, thisitem.count, price);
- thisclient->CharInfo->Zulies += (long int)price*count;
- }
- break;
- case 10:
- case 12:
- {
- // this values are the same from packet 753
- BYTE values[11] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
- UINT type = 0;
- UINT bprice = 0;
- UINT pricerate = 0;
- UINT pvalue = 0;
- if(thisitem.itemtype==10)
- {
- type = UseList.Index[thisitem.itemnum]->type;
- bprice = UseList.Index[thisitem.itemnum]->price;
- pricerate = UseList.Index[thisitem.itemnum]->pricerate;
- pvalue = UseList.Index[thisitem.itemnum]->pricevalue;
- }
- else
- {
- type = NaturalList.Index[thisitem.itemnum]->type;
- bprice = NaturalList.Index[thisitem.itemnum]->price;
- pricerate = NaturalList.Index[thisitem.itemnum]->pricerate;
- pvalue = NaturalList.Index[thisitem.itemnum]->pricevalue;
- }
- unsigned int value = 0;
- float price = 0;
- bool flag;
- if(type<421)
- {
- if(type<311)
- flag = false;
- else
- if(type>312)
- flag = false;
- else
- flag = true;
- }
- else
- {
- if(type<=428)
- flag = true;
- else
- if(type<311)
- flag = false;
- else
- flag = true;
- }
- //Some items don't sell for right price o.O
- if(type == 437 || type == 429 || type == 435 || type == 442)
- flag = false;
- if(flag)
- {
- value = pvalue;
- if(value>=11)
- value ^= 0xffffffff;
- else
- value = values[value];
- value -= 0x32;
- value *= pricerate;
- value += 1000;
- value *= bprice;
- value *= (200 - 0x62); //town rate ( 100)
- price = value * 5.555555555555556E-06;
- //Should fix the merchandising skill
- for(int i = 0;i<MAX_CLASS_SKILL;i++)
- {
- if(thisclient->cskills[i].id == 2286)
- {
- price += (((price * thisclient->cskills[i].thisskill->value2[0]) / 100));
- Log(MSG_INFO,"%i percent added to selling price.", thisclient->cskills[i].thisskill->value2[0]);
- }
- }
- price = (float)floor(price);
- Log( MSG_INFO, "%s:: Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f",thisclient->CharInfo->charname,thisitem.itemnum, thisitem.itemtype, thisitem.count, price);
- thisclient->CharInfo->Zulies += (long int)price*count;
- }
- else
- {
- float price = pricerate;
- unsigned int value = 0x61 - 0x32; // misc rate -0x32
- price *= value;
- price += 1000;
- price *= bprice;
- price *= (200 - 0x62); //town rate ( 100)
- price *= 5.555555555555556E-06;
- //Should fix the merchandising skill
- for(int i = 0;i<MAX_CLASS_SKILL;i++)
- {
- if(thisclient->cskills[i].id == 2286)
- {
- price += (((price * thisclient->cskills[i].thisskill->value2[0]) / 100));
- Log(MSG_INFO,"%i percent added to selling price.", thisclient->cskills[i].thisskill->value2[0]);
- }
- }
- price = (float)floor(price);
- Log( MSG_INFO, "%s:: Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f",thisclient->CharInfo->charname,thisitem.itemnum, thisitem.itemtype, thisitem.count, price);
- thisclient->CharInfo->Zulies += (long int)price*count;
- }
- }
- break;
- case 7:
- case 11:
- case 13:
- {
- float price = 0;
- UINT bprice = 0;
- UINT pricerate = 0;
- switch(thisitem.itemtype)
- {
- case 7:
- pricerate = EquipList[thisitem.itemtype].Index[thisitem.itemnum]->pricerate;
- bprice = EquipList[thisitem.itemtype].Index[thisitem.itemnum]->price;
- break;
- case 11:
- pricerate = JemList.Index[thisitem.itemnum]->pricerate;
- bprice = JemList.Index[thisitem.itemnum]->price;
- break;
- case 13:continue;//can we sell quest items? :S
- }
- price = pricerate;
- price *= 0x61 - 0x32; // misc rate -0x32
- price += 1000;
- price *= bprice;
- price *= (200 - 0x62); //town rate ( 100)
- price *= 5.555555555555556E-06;
- //Should fix the merchandising skill
- for(int i = 0;i<MAX_CLASS_SKILL;i++)
- {
- if(thisclient->cskills[i].id == 2286)
- {
- price += (((price * thisclient->cskills[i].thisskill->value2[0]) / 100));
- Log(MSG_INFO,"%i percent added to selling price.", thisclient->cskills[i].thisskill->value2[0]);
- }
- }
- price = (float)floor(price);
- Log( MSG_INFO, "%s:: Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f",thisclient->CharInfo->charname,thisitem.itemnum, thisitem.itemtype, thisitem.count, price);
- thisclient->CharInfo->Zulies += (long int)price*count;
- }
- break;
- default:
- Log( MSG_WARNING, "Invalid Item Type: %i", thisitem.itemtype );
- }
- thisclient->items[slotid].count -= count;
- if( thisclient->items[slotid].count <=0 )
- ClearItem( thisclient->items[slotid] );
- ADDWORD( pak, slotid );
- ADDDWORD( pak, BuildItemHead( thisclient->items[slotid] ) );
- ADDDWORD( pak, BuildItemData( thisclient->items[slotid] ) );
- ADDDWORD( pak, 0x00000000 );
- ADDWORD ( pak, 0x0000 );
- ncount++;
- //Saving item in database now.
- thisclient->SaveSlot41(slotid);
- }
- SETQWORD( pak, 0, thisclient->CharInfo->Zulies );
- SETBYTE( pak, 8, ncount );
- thisclient->client->SendPacket( &pak );
- return true;
- }
we have the following code
the problem is that it give not stable zuly and not the right count of zully could one of u help us whit it?
hanks alot for reading and take the time to see the code message me if u go a solution or add me on discord stefan#3662
kind regards stefan from FrozenRose