• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Golden nugget support!

Mokerhamer

Retired Global Mod
Senator
Joined
Aug 6, 2007
Messages
1,767
Reaction score
36
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
Code:
	ITEM_COINS_CRYSTAL	= 2160,
ADD
Code:
    ITEM_GOLD_NUGGET	= 2157,




Item.cpp
AFTER
Code:
		case ITEM_COINS_CRYSTAL:
			return getItemCount() * 10000;
			break;
ADD
Code:
case ITEM_GOLD_NUGGET:
			return getItemCount() * 1000000;
			break;




Game.cpp
BEFORE
Code:
	int32_t crys = money / 10000;
	money -= crys * 10000;
ADD
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
 
For 0.3.4 PL2

Generally all what you to do, is edit worth attribute in items.xml

So find item 2157 and add inside:
Code:
<attribute key="worth" value="1000000"/>


+ if you want also to be it was exchangeable on click
actions/scripts/other/changegold.lua

Change:
Code:
 	[ITEM_CRYSTAL_COIN] = {
		from = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_TEAL
	}

To:
Code:
	[ITEM_CRYSTAL_COIN] = {
		from = ITEM_PLATINUM_COIN, to = 2157, effect = TEXTCOLOR_TEAL
	},
	[2157] = {
		from = ITEM_CRYSTAL_COIN, effect = 204
	}

Done! :)
 
Warning!

If npc's gives you to mutch Golden nuggets it will bug then!
 
For 0.3.4 PL2

Generally all what you to do, is edit worth attribute in items.xml

So find item 2157 and add inside:
Code:
<attribute key="worth" value="1000000"/>


+ if you want also to be it was exchangeable on click
actions/scripts/other/changegold.lua

Change:
Code:
 	[ITEM_CRYSTAL_COIN] = {
		from = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_TEAL
	}

To:
Code:
	[ITEM_CRYSTAL_COIN] = {
		from = ITEM_PLATINUM_COIN, to = 2157, effect = TEXTCOLOR_TEAL
	},
	[2157] = {
		from = ITEM_CRYSTAL_COIN, effect = 204
	}

Done! :)

Only that will not work, because the NPCs + talkactions wont recognize the new currencies as change, therefore if you use a "golden nugget" to pay something that costs lets say 1 gp, you will get massive amounts of packs of 100cc on you + the ground and get bugged.. Or well at least that happened to me bout 4 months ago when I was on that currencies issue until I checked sources and fixed it from there.

@Moker:
Remember to check function.lua and change this:

Lua:
function getPlayerMoney(cid)
	return ((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN) * 10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN) * 100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))
end

To this:

Lua:
function getPlayerMoney(cid)
	return ((getPlayerItemCount(cid, XXXX) * 1000000) + (getPlayerItemCount(cid, ITEM_CRYSTAL_COIN) * 10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN) * 100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))
end

Dont remember why I needed to add that back then, but it worked after doing it + everything else.

Anyways this is an useful guide+code, Id have loved it if you posted it like 4 months ago back then when I was desperated because I couldnt make it work :D I think it took me like 1 month to find the solution and get it working :D

This would've saved me that month lol :thumbup:

Keep it up +Repped.
 
This helped me alot, I really thank you!

In my server people used to get more than 20 backpack's full of crystal coins to buy stuff, now it's fixed! Thank you rep++!
 
I got it working.

The int overflow works fine now.

But i jumped up to an source bug.

Example:
If you want to sell between 22 and 100 at the same time it will remove max 21 items and it will give you the cash for all of them
 
If you want it in LUA:
/data/actions/scripts/other/ open changegold.lua, delete everything and insert this:
PHP:
local NUGGETS = 2157

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_TEAL)
	elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_YELLOW)
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - item.type)
		doPlayerAddItem(cid, EMERALDS, 1)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_WHITE)
	elseif item.itemid == ITEM_CRYSTAL_COIN and item.type < ITEMCOUNT_MAX then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
	elseif item.itemid == NUGGETS then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
		doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
	end

	doSendMagicEffect(fromPosition, CONST_ME_FIREWORK_RED)

	return TRUE
end
then go to /data/actions/actions.xml
PHP:
<action itemid="2157" event="script" value="other/changegold.lua"/>

And it should work :p

Edit: TESTED on tfs 0.3.4 and it works perfectly.
 
Last edited:
Great tutorial. Finally used it, my players appreciate it VERY much!

Red
 
Hey,I want it for a war server, ppl get a soul orb when they kill anyone, so i wanna npc sell items example [
Player:Hi
Player:Trade
He see items, he cant buy the items for gold, only soul orb ?:S i need help really i need!! :S!
 
Hey,I want it for a war server, ppl get a soul orb when they kill anyone, so i wanna npc sell items example [
Player:Hi
Player:Trade
He see items, he cant buy the items for gold, only soul orb ?:S i need help really i need!! :S!
On 0.3.x:
in items.xml edit crystal coin/platinum/gold and remove line with key "worth" and add "worth" parameter to orb.
 
Back
Top