- Joined
- Aug 6, 2007
- Messages
- 1,767
- Reaction score
- 36
Hi guys,
i made an Golden nugget support. But we are having some problems with the Int overflow (If an npc should give you loads of money it will give 100gn,164cc,164,plat,164 gold) And korn told me it's an int bug.
Altought my team mate dosen't has the time to fix it i'm asking some help on otland
here is the code that i made we are using 0.2.4!
i made an Golden nugget support. But we are having some problems with the Int overflow (If an npc should give you loads of money it will give 100gn,164cc,164,plat,164 gold) And korn told me it's an int bug.
Altought my team mate dosen't has the time to fix it i'm asking some help on otland
here is the code that i made we are using 0.2.4!
Hi,
(testen on Source 2.1+)
This is an very very very simple code but some people might use it. Thise code allows to acsept Golden nuggets/or pai with golden nuggets on your server.
Let's start!
Const.h
AFTER
ADDCode:ITEM_COINS_CRYSTAL = 2160,
Code:ITEM_GOLD_NUGGET = 2157,
Item.cpp
AFTER
ADDCode:case ITEM_COINS_CRYSTAL: return getItemCount() * 10000; break;
Code:case ITEM_GOLD_NUGGET: return getItemCount() * 1000000; break;
Game.cpp
BEFORE
ADDCode:int32_t crys = money / 10000; money -= crys * 10000;
Code:int32_t nugget = money / 1000000; money -= nugget * 1000000;
BEFORE
Code:if(crys != 0) { do { Item* remaindItem = Item::CreateItem(ITEM_COINS_CRYSTAL, std::min(100, crys)); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if(ret != RET_NOERROR) internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); crys -= std::min(100, crys); } while(crys > 0); }
ADD
Code:if(nugget != 0) { do { Item* remaindItem = Item::CreateItem(ITEM_GOLD_NUGGET, std::min(100, nugget)); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if(ret != RET_NOERROR) internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); nugget -= std::min(100, nugget); } while(nugget > 0); }
I hope you will find it usefull.
How to make sutch codes? You NEED to have a brain to know how to copy/paste and edit them!
//Mokerhamer