• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Idea!

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Have you seen that on your OT are thousands of bags and flask on the floor?

I have an idea... The idea is to make a talkaction that you say: !flask and it will remove all flask on your chars and will pay some cash for it...

7636 = 5 gp.
7635 = 10 gp.

Etc...
 
LUA:
local removable = {1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 7343, 7342, 5949, 5950, 10518, 10519, 10520, 10521, 10522, 9774, 3940, 5926, 11235, 11238}

function removeEmptyContainers(uid, ids)
	local ret, i = 0, 0
	while i < getContainerSize(uid) do
		local v = getContainerItem(uid, i)
		if isContainer(v.uid) then
			if getContainerSize(v.uid) ~= 0 then
				ret = ret + removeEmptyContainers(v.uid, removable)
				if isInArray(removable, v.itemid) and getContainerSize(v.uid) == 0 then
					i = i - 1
				end
			elseif isInArray(removable, v.itemid) then
				doRemoveItem(v.uid)
				i = i - 1
				ret = ret + 1
			end
		end
		i = i + 1
	end
	return ret
end

function onSay(cid, words, param, channel)
	local ret = 0
	for i = 1, 10 do
		local v = getPlayerSlotItem(cid, i).uid
		if v > 0 and isContainer(v) then
			ret = ret + removeEmptyContainers(v, removable)
		end
	end
	ret = tostring(ret)
	return doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, ret .. " empty container" .. (ret:sub(-1) == "1" and ret:sub(-2) ~= "11" and "" or "s") .. " removed.")
end

LUA:
function onSay(cid, words, param, channel)
	local money = 0
	for id, price in pairs({[7636] = 5, [7634] = 7, [7635] = 10}) do
		local a = getPlayerItemCount(cid, id)
		if a > 0 then
			doPlayerRemoveItem(cid, id, a)
			money = money + a*price
		end
	end
	if money == 0 then
		doPlayerSendCancel(cid, "You don't have any flask!")
	else
		doPlayerSendCancel(cid, "Added "..money.." gp.")
		doPlayerAddMoney(cid, money)
	end
	return true
end

Im using this two scripts... But I would like to make just one, that first remove flask, and then remove the empty bps, and then the message says "There was x flask removed and y empty containers removed, and added a total of z gps."

Also the flask should have a max of 100 items per time you use the command, because it can give debug on the client.
 
Last edited:
LUA:
local cont =
    {
        [1988] = 10
    }

local toAdd = {}

function checkContainer(item, cid)
    if (getContainerSize(item.uid) < 1) then
        if cont[item.itemid] then
            toAdd[cid] = toAdd[cid] + cont[item.itemid]
        end
        return doRemoveItem(item.uid)
    end

    for k = (getContainerSize(item.uid) - 1), 0, -1 do
        local tmp = getContainerItem(item.uid, k)
        if (tmp.itemid > 0) then
            if isContainer(tmp.uid) then
                checkContainer(tmp, cid)
            end
        end
    end
end

function onSay(cid, words, param, channel)
    toAdd[cid] = 0
    for slot = CONST_SLOT_FIRST, CONST_SLOT_LAST do
        local item = getPlayerSlotItem(cid, slot)
        if (item.itemid > 0) then
            if isContainer(item.uid) then
                checkContainer(item, cid)
            end
        end
    end
    if (toAdd[cid] ~= 0) then
            doPlayerAddMoney(cid, toAdd[cid])
    end
    return true
end
 

Similar threads

Back
Top