Jump to content
  • 0

Inventory NPC


Nana

Question


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  12/20/12
  • Last Seen:  

Hi

 

I want to know if there any chanse to make a NPC that have a random inventory of X items, so if the NPC sell that amount of that item anyone can buy it untill next day

 

I don't know if i'm explain correctly

 

NPC: tooldealer (for example)

Item: fly wings (i want to sell 100 monday, 150 tuesday, 0 wensday..etc)

 

so today is monday and i bougth 50, another char bougth anohter 50, so anyone else can uy flywings till tuesday

 

Can anyone helpme with an example of this =(?

 

Thanks a lot!!!

Link to comment
Share on other sites

13 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Hmm, ok yeah I think I know what you mean... I like the idea...

-	shop	custom_seller	-1,501:50

prontera.gat,95,99,5 script custom seller 100,{

mes "Welcome to my shop!";

for(set .@i,0; getd(".shop_list"+.day+"["+.@i+"]"); set .@i,.@i+1){ mes getitemname(getd(".shop_list"+.day+"["+.@i+"]"))+" ("+(getd(".amount_list"+.day+"["+.@i+"]")?"^007700In-Stock":"^CD0000Out-of-Stock")+"^000000) ["+getd(".amount_list"+.day+"["+.@i+"]")+"]"; }

callshop "custom_seller",1;

npcshopattach "custom_seller";

end;

OnBuyItem:

for(set @i,0; getd(".shop_list"+.day+"["+@i+"]"); set @i,@i+1) {

for(set @d,0; @d<getarraysize(@bought_nameid); set @d,@d+1){

if(@bought_nameid[@d]==getd(".shop_list"+.day+"["+@i+"]")){

if(Zeny >= (getd(".price_list"+.day+"["+@i+"]")*@bought_quantity[@d])) {

if(checkweight(getd(".shop_list"+.day+"["+@i+"]"),((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]))){

if(getd(".amount_list"+.day+"["+@i+"]")>0){

set Zeny,Zeny-(getd(".price_list"+.day+"["+@i+"]")*((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]));

getitem @bought_nameid[@d],((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]);

setd ".amount_list"+.day+"["+@i+"]",getd(".amount_list"+.day+"["+@i+"]")-((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]);

} else { dispbottom "I'm sorry but we're currently out of "+getitemname(getd(".shop_list"+.day+"["+@i+"]"))+"s."; }

} else { dispbottom "I'm sorry but you can't hold that many "+getitemname(getd(".shop_list"+.day+"["+@i+"]"))+"s."; }

} else { dispbottom "I'm sorry you don't have enough money for "+getitemname(getd(".shop_list"+.day+"["+@i+"]"))+"s."; }

}

}

}

deletearray @bought_quantity, getarraysize(@bought_quantity);

deletearray @bought_nameid, getarraysize(@bought_nameid);

close;

OnHour0000:

OnInit:

//=================Configuration================

set .day,gettime(4);

//Itemlist

setarray .shop_list0,502,503,504,505,506; //Sunday

setarray .shop_list1,501,502,503,504,505; //Monday

setarray .shop_list2,501,503,504,505,506; //Tuesday

setarray .shop_list3,501,502,503,504,505; //Wednesday

setarray .shop_list4,502,503,504,505,506; //Thursday

setarray .shop_list5,501,502,503,504,505; //Friday

setarray .shop_list6,502,503,504,505,506; //Saturday

//Pricelist

setarray .price_list0,20,40,300,400,500; //Sunday

setarray .price_list1,20,40,300,400,500; //Monday

setarray .price_list2,20,40,300,400,500; //Tuesday

setarray .price_list3,20,40,300,400,500; //Wednesday

setarray .price_list4,20,40,300,400,500; //Thursday

setarray .price_list5,20,40,300,400,500; //Friday

setarray .price_list6,20,40,300,400,500; //Saturday

//Stock

setarray .amount_list0,100,100,100,100,0; //Sunday

setarray .amount_list1,100,100,100,100,0; //Monday

setarray .amount_list2,100,100,100,100,0; //Tuesday

setarray .amount_list3,100,100,100,100,0; //Wednesday

setarray .amount_list4,100,100,100,100,0; //Thursday

setarray .amount_list5,100,100,100,100,0; //Friday

setarray .amount_list5,100,100,100,100,0; //Saturday

//==================By Skorm=====================

OnTimer10000:

npcshopitem "custom_seller",0,0; // Don't touch any coding beyond here

for(set .i,0; getd(".shop_list"+.day+"["+.i+"]"); set .i,.i+1){ if(getd(".amount_list"+.day+"["+.i+"]")){ npcshopadditem "custom_seller",getd(".shop_list"+.day+"["+.i+"]"),getd(".price_list"+.day+"["+.i+"]"); } }

initnpctimer;

end;

}

5ea2ae369487cbbe929671e15eb4ad45.png?136 Edited by Skorm
  • Upvote 2
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Modify configuration here:

//=================Configuration================
set .day,gettime(4);
//Itemlist
setarray .shop_list0,502,503,504,505,506; //Sunday
setarray .shop_list1,501,502,503,504,505; //Monday
setarray .shop_list2,502,503,504,505,506; //Tuesday
setarray .shop_list3,501,502,503,504,505; //Wednesday
setarray .shop_list4,502,503,504,505,506; //Thursday
setarray .shop_list5,501,502,503,504,505; //Friday
setarray .shop_list6,502,503,504,505,506; //Saturday

//Pricelist
setarray .price_list0,20,40,300,400,500; //Sunday
setarray .price_list1,20,40,300,400,500; //Monday
setarray .price_list2,20,40,300,400,500; //Tuesday
setarray .price_list3,20,40,300,400,500; //Wednesday
setarray .price_list4,20,40,300,400,500; //Thursday
setarray .price_list5,20,40,300,400,500; //Friday
setarray .price_list6,20,40,300,400,500; //Saturday

//Stock
setarray .amount_list0,1,1,1,1,0; //Sunday
setarray .amount_list1,1,1,1,1,0; //Monday
setarray .amount_list2,1,1,1,1,0; //Tuesday
setarray .amount_list3,1,1,1,1,0; //Wednesday
setarray .amount_list4,1,1,1,1,0; //Thursday
setarray .amount_list5,1,1,1,1,0; //Friday
setarray .amount_list5,1,1,1,1,0; //Saturday
//=================================================
You can have 127 values per-array, but try to keep each corresponding ID list the same length.
  •        Ex: .amount_list2, .price_list2, and shop_list2 can all have 2 values while the others remain at 5.
  •               Just as long as the 3 respective lists remain the same length.
Each shop_list doesn't need to have the same IDs.
  •        Ex: The npc can sell 501,502,503 on Monday, and 1599,2202,2199 on Wednesday.
============================================================================
OnHour0000:
OnInit:
Shop inventory is reset on day change, server-reload, and script-reload.

============================================================================

 

If you want the npc to update in real-time, which will increase server-load, but will also show current items in-stock only.

 

After:

//=================================================

 Add:
OnTimer10000:
initnpctimer;
Where 10000 is time in milliseconds currently set to refresh every 10 seconds.

 

============================================================================

I had a lot of fun making this NPC. Thank you for the very good idea, and if you have any problems keep me posted.

Edited by Skorm
  • Upvote 3
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  12/20/12
  • Last Seen:  

wow thanks a lot!!! really!!!

 

just another thing, if I want that for example wensday hide the npc, i just add

 

if (gettime(4)=3)

{

disablenpc custom_seller;

}

 

right??

 

Thanks!! really!!!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

If you want to actively disable the npc, you need a label to trigger it.

OnInit:
OnWed:
	if (gettime(4)=3)
		disablenpc strnpcinfo(3);
	end;
(don't forget, you'll also need a label to trigger enablenpc when you want to enable it)

 

If you want to passively disable the npc (just have it display a message to users), you could add this after the script heading:

prontera,95,99,5	script	custom seller	100,{
	if (gettime(4)=3) {
		mes "The custom shop is closed today.";
		close;
	}
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  12/20/12
  • Last Seen:  

Great!!! thanks a lot!!! :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

how to change zeny into TCG? like if i buy something from the shop it'll take TCG Card instead of zeny?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  1302
  • Reputation:   77
  • Joined:  12/04/12
  • Last Seen:  

this is super nice. how u can think like this topic owner ~!!!!!

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

how to change zeny into TCG? like if i buy something from the shop it'll take TCG Card instead of zeny?

 

This should do the trick.

 

Find:

set Zeny,Zeny-(getd(".price_list"+.day+"["+@i+"]")*((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]));

Replace With:

delitem .itemid,getd(".price_list"+.day+"["+@i+"]")*((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]);


Find:

if(Zeny >= (getd(".price_list"+.day+"["+@i+"]")*@bought_quantity[@d])) {

Replace With:

if(countitem(.itemid) >= (getd(".price_list"+.day+"["+@i+"]")*@bought_quantity[@d])) {


After:

set .day,gettime(4);

Add:

set .itemid,7227;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  242
  • Reputation:   3
  • Joined:  01/01/12
  • Last Seen:  

error i have 2 npc zeny and TCG and said i dont have money to buy bla bla but i have tcg and zeny hahahaha

 

-	shop	custom_seller1	-1,501:50
morocc,159,97,5	script	Inventory NPC [ TCG ] 	60,{
mes "Welcome to my shop!";
for(set .@i,0; getd(".shop_list"+.day+"["+.@i+"]"); set .@i,.@i+1){ mes getitemname(getd(".shop_list"+.day+"["+.@i+"]"))+" ("+(getd(".amount_list"+.day+"["+.@i+"]")?"^007700In-Stock":"^CD0000Out-of-Stock")+"^000000) ["+getd(".amount_list"+.day+"["+.@i+"]")+"]"; }
callshop "custom_seller1",1;
npcshopattach "custom_seller1";
end;
OnBuyItem:
for(set @i,0; getd(".shop_list"+.day+"["+@i+"]"); set @i,@i+1) {
	for(set @d,0; @d<getarraysize(@bought_nameid); set @d,@d+1){
		if(@bought_nameid[@d]==getd(".shop_list"+.day+"["+@i+"]")){
			if(countitem(.itemid) >= (getd(".price_list"+.day+"["+@i+"]")*@bought_quantity[@d])) {
				if(checkweight(getd(".shop_list"+.day+"["+@i+"]"),((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]))){
					if(getd(".amount_list"+.day+"["+@i+"]")>0){
						delitem .itemid,getd(".price_list"+.day+"["+@i+"]")*((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]);
						getitem @bought_nameid[@d],((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]);
						setd ".amount_list"+.day+"["+@i+"]",getd(".amount_list"+.day+"["+@i+"]")-((@bought_quantity[@d]>getd(".amount_list"+.day+"["+@i+"]"))?getd(".amount_list"+.day+"["+@i+"]"):@bought_quantity[@d]);
					} else { dispbottom "I'm sorry but we're currently out of "+getitemname(getd(".shop_list"+.day+"["+@i+"]"))+"s."; }
				} else { dispbottom "I'm sorry but you can't hold that many "+getitemname(getd(".shop_list"+.day+"["+@i+"]"))+"s."; }
			} else { dispbottom "I'm sorry you don't have enough money for "+getitemname(getd(".shop_list"+.day+"["+@i+"]"))+"s."; }
		}
	}
}
deletearray @bought_quantity, getarraysize(@bought_quantity);
deletearray @bought_nameid, getarraysize(@bought_nameid);
close;
OnHour0000:
OnInit:
//=================Configuration================
set .itemid,7227;
//Itemlist
setarray .shop_list0,12114,12115,12280,12117,12116; //Sunday
setarray .shop_list1,12117,12114,12115,12116,12280; //Monday
setarray .shop_list2,12280,12117,12114,12115,12279; //Tuesday
setarray .shop_list3,12279,12280,12117,12114,12115; //Wednesday
setarray .shop_list4,12280,12279,12116,12117,12114; //Thursday
setarray .shop_list5,12279,12116,12280,12115,12114; //Friday
setarray .shop_list6,12116,12279,12114,12117,12115; //Saturday
//Pricelist
setarray .price_list0,10,10,10,10,10; //Sunday
setarray .price_list1,10,10,10,10,10; //Monday
setarray .price_list2,10,10,10,10,10; //Tuesday
setarray .price_list3,10,10,10,10,10; //Wednesday
setarray .price_list4,10,10,10,10,10; //Thursday
setarray .price_list5,10,10,10,10,10; //Friday
setarray .price_list6,10,10,10,10,10; //Saturday
//Stock
setarray .amount_list0,100,100,100,100,100; //Sunday
setarray .amount_list1,100,100,100,100,100; //Monday
setarray .amount_list2,100,100,100,100,100; //Tuesday
setarray .amount_list3,100,100,100,100,100; //Wednesday
setarray .amount_list4,100,100,100,100,100; //Thursday
setarray .amount_list5,100,100,100,100,100; //Friday
setarray .amount_list5,100,100,100,100,100; //Saturday
//=================================================
OnTimer10000:
npcshopitem "custom_seller1",0,0; // Don't touch any coding beyond here
for(set .i,0; getd(".shop_list"+.day+"["+.i+"]"); set .i,.i+1){ if(getd(".amount_list"+.day+"["+.i+"]")){ npcshopadditem "custom_seller1",getd(".shop_list"+.day+"["+.i+"]"),getd(".price_list"+.day+"["+.i+"]"); } }
initnpctimer;
end;
}

 

TCG NPC

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Make sure that you have enough zeny to carry, although the zeny won't be deducted but it's still needed when doing the transaction.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

error i have 2 npc zeny and TCG and said i dont have money to buy bla bla but i have tcg and zeny hahahaha

 

TCG NPC

Worked fine for me the itemid is 7227. Make sure you have 10 Zeny as well as 10 TCGs.

Edit:

I see your problem now!

I said Add set .itemid,7227; After set .day,gettime(4); you just replaced it.

//=================Configuration================
set .day,gettime(4);
set .itemid,7227;
//Itemlist
Edited by Skorm
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  1302
  • Reputation:   77
  • Joined:  12/04/12
  • Last Seen:  

why the npc doesnt change the itemlist ? T_T

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

[solved]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...