Jump to content
  • 0

R> Npc for Counting Total item in Inventory and Cart item or whole database?


Ryoma27

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  28
  • Reputation:   1
  • Joined:  10/20/20
  • Last Seen:  

let say the server has a total 2,000,000 apples and the players Farm of total 500,000 apples, npc will set the price of that item depends on the total price 2M/500k=4z for selling Price, and 1-3% buying price, like in stock exchange? the price will automatically change based on supply and demand every minute or every hour, any one? 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

something like this ?



prontera,155,181,5	shop	apple_shop	757,909:-1

-	script	apple_shop_main	-1,{
	
	OnInit:
		.item_id = 512;
		.max_amount = 2000000;
		
		.shop_npc$ = "apple_shop";
		
	OnMinute00: // update every hour
		hideonnpc .shop_npc$;
		npcshopdelitem .shop_npc$, .item_id;
		.@sql$ = .@sql$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		.@size = query_sql(.@sql$, .@amount);
		for (.@i = 0; .@i < .@size; .@i++)
			.@total_amount += .@amount[.@i];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / .@total_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / .@total_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / .@total_amount);
		hideoffnpc .shop_npc$;
		end;
}

 

Edited by Emistry
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  28
  • Reputation:   1
  • Joined:  10/20/20
  • Last Seen:  

23 hours ago, Emistry said:

something like this ?



prontera,155,181,5	shop	apple_shop	757,909:-1

-	script	apple_shop_main	-1,{
	
	OnInit:
		.item_id = 512;
		.max_amount = 2000000;
		
		.shop_npc$ = "apple_shop";
		
	OnMinute00: // update every hour
		hideonnpc .shop_npc$;
		npcshopdelitem .shop_npc$, .item_id;
		.@sql$ = .@sql$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		.@size = query_sql(.@sql$, .@amount);
		for (.@i = 0; .@i < .@size; .@i++)
			.@total_amount += .@amount[.@i];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / .@total_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / .@total_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / .@total_amount);
		hideoffnpc .shop_npc$;
		end;
}

 

let me try this Sir Emistry, 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  28
  • Reputation:   1
  • Joined:  10/20/20
  • Last Seen:  

On 3/5/2022 at 5:55 PM, Emistry said:

something like this ?



prontera,155,181,5	shop	apple_shop	757,909:-1

-	script	apple_shop_main	-1,{
	
	OnInit:
		.item_id = 512;
		.max_amount = 2000000;
		
		.shop_npc$ = "apple_shop";
		
	OnMinute00: // update every hour
		hideonnpc .shop_npc$;
		npcshopdelitem .shop_npc$, .item_id;
		.@sql$ = .@sql$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		.@size = query_sql(.@sql$, .@amount);
		for (.@i = 0; .@i < .@size; .@i++)
			.@total_amount += .@amount[.@i];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / .@total_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / .@total_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / .@total_amount);
		hideoffnpc .shop_npc$;
		end;
}

 

image.png.ec38ced58c7fe5f4032fe18799e9011f.png


new_zone04,93,108,5	shop	Wisteria_Shop	757,30006:-1

-	script	Wisteria_Shop_main	-1,{
	
	OnInit:
		.item_id = 30006;
		.max_amount = 20000000;
		
		.shop_npc$ = "Wisteria_Shop";
		
	OnMinute00: // update every hour
		hideonnpc .shop_npc$;
		npcshopdelitem .shop_npc$, .item_id;
		.@sql$ = .@sql$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		.@sql$ = .@sql$ + " UNION ";
		.@sql$ = .@sql$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		.@size = query_sql(.@sql$, .@amount);
		for (.@i = 0; .@i < .@size; .@i++)
			.@total_amount += .@amount[.@i];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / .@total_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / .@total_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / .@total_amount);
		hideoffnpc .shop_npc$;
		end;
}

image.png.be63ac39b9c27eff5447712b52a16b1d.png

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...