Jump to content
  • 0
Ryoma27

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

Question

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

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;
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		[email protected] = query_sql([email protected]$, [email protected]);
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
			[email protected]_amount += [email protected][[email protected]];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / [email protected]_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / [email protected]_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / [email protected]_amount);
		hideoffnpc .shop_npc$;
		end;
}

 

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

  • 0
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;
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		[email protected] = query_sql([email protected]$, [email protected]);
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
			[email protected]_amount += [email protected][[email protected]];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / [email protected]_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / [email protected]_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / [email protected]_amount);
		hideoffnpc .shop_npc$;
		end;
}

 

let me try this Sir Emistry, 

Link to comment
Share on other sites

  • 0
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;
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		[email protected] = query_sql([email protected]$, [email protected]);
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
			[email protected]_amount += [email protected][[email protected]];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / [email protected]_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / [email protected]_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / [email protected]_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;
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `cart_inventory` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `storage` WHERE `nameid` = "+.item_id;
		[email protected]$ = [email protected]$ + " UNION ";
		[email protected]$ = [email protected]$ + "SELECT `amount` FROM `guild_storage` WHERE `nameid` = "+.item_id;
		[email protected] = query_sql([email protected]$, [email protected]);
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
			[email protected]_amount += [email protected][[email protected]];
		
		setiteminfo .item_id, ITEMINFO_SELL, (.max_amount / [email protected]_amount);
		setiteminfo .item_id, ITEMINFO_BUY, (((.max_amount / [email protected]_amount) * 100) / rand(1, 3)));
		
		npcshopadditem .shop_npc$, .item_id, (.max_amount / [email protected]_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...

Important Information

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