• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Script request, I have no idea how to make this script

TheNubCake

Noob
Joined
Nov 30, 2011
Messages
696
Reaction score
74
I want a command for the players, that shows them which npc sells the most items each week.
(Is this possible to make?)
Rep++ for whoever helps me

--------------------------------------------------------------------------------------------------------------------------------
I want it to show like for example:
Rashid:
Sold Items: 1000
Cash Made: 100000

for like all npcs.. over a weeks time and it would be a command like.. !npcprofit (or something) and a box would pop up and show all the npcs sales and profit made
 
Last edited:
yeah, it's possible, hmm i think u must add to libs npc to functions BuyItemFromPlayer~~ for example
setGlobalStorageValue(storage, last_value + price)
 
Yes this is possible, however you will have to edit every NPC thats selling stuff, some NPCs might have to be totally rewritten or/and a change in npcsystem's sellmodule code.

edit:
Lua:
function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
	local amount, subType, ignoreCap, item = amount or 1, subType or 1, ignoreCap and true or false, 0
	if(isItemStackable(itemid)) then
		if(isItemRune(itemid)) then
			amount = amount * subType
		end

		local count = amount
		repeat
			item = doCreateItemEx(itemid, math.min(100, count))
			if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
				return 0, 0
			end

			count = count - math.min(100, count)
		until count == 0
		return amount, 0
	end

	local a = 0
	if(inBackpacks) then
		local container, b = doCreateItemEx(backpack, 1), 1
		for i = 1, amount do
			item = doAddContainerItem(container, itemid, subType)
			if(itemid == ITEM_PARCEL) then
				doAddContainerItem(item, ITEM_LABEL)
			end

			if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then
				if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
					b = b - 1
					break
				end

				a = i
				if(amount > i) then
					container = doCreateItemEx(backpack, 1)
					b = b + 1
				end
			end
		end

		return a, b
	end

	for i = 1, amount do
		item = doCreateItemEx(itemid, subType)
		if(itemid == ITEM_PARCEL) then
			doAddContainerItem(item, ITEM_LABEL)
		end

		if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
			break
		end

		a = i
	end

	return a, 0
end

This is a part of the code taken from data/npc/lib/npc.lua
You have to update this, every successfull transaction will have to increase a storage value that is unique for that NPC with the sellammount. Actually quite easy.

You then have to work on the talkaction, which will look which storage value is biggest, this is the biggest job depending on how advanced and detailed you want it to be. Where it will list NPCs, how much they sold etc.
 
Last edited:
Back
Top