Jump to content
  • 0
Sign in to follow this  
LyDe

Dynamic Shop

Question

Hey guys, I'm looking for a Dynamic Shop reaaly simple. Like this: trade 200 valor of badge for glorious itens... I just find a complex scripts to do that but I just wanna a simple one.

I got this one but isnt working:

 


bat_room,150,150,5    script    Glorious    756,{
 
goto EveryThing;
 
OnInit:
    setarray .ItList[0],503,100,504,100,505,200,506,1000;    /* [ID,Preço (zeny&item)]*/
    setarray .PayType[0],1,909;                                /* [Tipo,ID do item] [Tipos: 1 = item, 0 = zeny] [Para tipo = 0 ignore o segundo campo]*/
    npcshopdelitem "CShop#C",501;
    for(set .n,0;.n<getarraysize(.ItList);set .n,.n+2)
    npcshopadditem "CShop#C",.ItList[.n],.ItList[(.n+1)];
    end;
 
EveryThing:
    if(.PayType[0])
    {
        dispbottom "Shop de "+getitemname(.PayType[1]);
        dispbottom "Você possui "+countitem(.PayType[1])+" "+getitemname(.PayType[1])+"(s)";
        if(!countitem(.PayType[1])) end;
    }
    callshop "CShop#C";
    npcshopattach "CShop#C";
    end;
 
OnBuyItem:
    for(set @n,0;@n<getarraysize(@bought_nameid);set @n,@n+1)
    for(set @a,0;@a<getarraysize(.ItList);set @a,@a+2)
    if(@bought_nameid[@n]==.ItList[@a])
    {
        set @PriceT,.ItList[@a+1]*@bought_quantity[@n];
        if(.PayType[0])
        {
            if(countitem(.PayType[1])<@PriceT) end;
        }
        else
        {
            if(Zeny<@PriceT) end;
        }
        getitem @bought_nameid[@n],@bought_quantity[@n];
        if(.PayType[0]) delitem .PayType[1],@PriceT;
        else set Zeny,Zeny-@PriceT;
    }
    close;
}
 
-    shop    CShop#C    -1,501:-1

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I guess you are looking for Hercules trader npc. Trader npc its a kind of npc that can sell stuff, but, you can make it to accept zeny or items as payment. This is an example for a trader shop with items:
 

prontera,55,50,0	trader	HeroismExchanger	PORING,{	// You need to declare it as "trader" instead of "script"
	openshop();							// command to open the shop
	end;

OnInit:
	tradertype(NST_CUSTOM);						// allows you to set items as currency
	sellitem Krieger_Twohand_Sword1, 200;				// adds Krieger_Twohand_Sword1 to the shop at 200 valor badges
	end;

OnCountFunds:
	setcurrency countitem(BF_Badge2);				// sets BF_Badge2 (Valor Badge) as currency
	end;

OnPayFunds:
	if (countitem(BF_Badge2) < @price)
		end;
	delitem BF_Badge2, @price;					// discount valor badges
	purchaseok();							// closes shop
	end;
}

 
Also, you may want to read the following sections at script_commands.txt (control + f) :

** Define a shop/cashshop NPC.
12 - NPC Trader-Related Commands
 
Also can see /doc/sample/npc_trader_sample.txt for samples.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.