Duplicate Trader NPC with different items

KirieZ

Core Developers
Staff member
Messages
245
Points
0
Location
Brazil
Github
guilherme-gm
Emulator
Hello everybody,

While doing some tests with the trader npc,  I noticed that when I duplicate my trader, if I change the item list of one, all of them are affected.

For example:

-  trader  MyNpc#id  -1,{OnInit:  .@i = 400 + rand(0,10);  sellitem Red_Potion, .@i;  waitingroom "id: " + strnpcinfo(2) + " ; " + .@i, 0;end;}prontera,164,170,4  duplicate(MyNpc#id)  MyNpc#1  101prontera,164,168,4  duplicate(MyNpc#id)  MyNpc#2  101prontera,164,166,4  duplicate(MyNpc#id)  MyNpc#3  101prontera,164,164,4  duplicate(MyNpc#id)  MyNpc#4  101prontera,164,162,4  duplicate(MyNpc#id)  MyNpc#5  101
This was a test to get 5 shops that sells the same thing but with different prices, but when testing, all of them have the same sell value (but the chat room is different).

Is there a way to make each duplicate have a different item list? Thanks in advance.

 
I found a "workaround", (I hope I'm not breaking any rule for double posting in less than 24h)

It seems that it is not possible to just duplicate the shop, so I made a function that all of these shops call when they init.

Code:

Code:
function	script	SetupShop	{	.@i = 400 + rand(0,10);	sellitem Red_Potion, .@i;	waitingroom "id: " + strnpcinfo(2) + " ; " + .@i, 0;	return;}prontera,164,170,4	trader	MyNpc#1	101,{OnInit:	callfunc("SetupShop");end;}prontera,164,168,4	trader	MyNpc#2	101,{OnInit:	callfunc("SetupShop");end;}prontera,164,166,4	trader	MyNpc#3	101,{OnInit:	callfunc("SetupShop");end;}prontera,164,164,4	trader	MyNpc#4	101,{OnInit:	callfunc("SetupShop");end;}prontera,164,162,4	trader	MyNpc#5	101,{OnInit:	callfunc("SetupShop");end;}
 
Back
Top