• 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...
 
SImple, noobish script :)
LUA:
function onSay(cid, words, param, channel)
	local money = 0
	for id, price in ipairs({[7636] = 5, [7635] = 10}) do
		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
 
it was because of ipairs :p
Code:
function onSay(cid, words, param, channel)
	local money = 0
	for id, price in pairs({[7636] = 5, [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
 
BTW Cyko, could you make another script that do the same for containers, but if the container has items inside, it skip it, and sell the others without items inside?
 
try this


Code:
function onSay(cid, words, param, channel)
	local money = 0
	for id, price in pairs({[7636] = 5, [7635] = 10}) do
			if isContainer(id) then
				if getContainerCapById(id) == 20 then
				local a = getPlayerItemCount(cid, id)
					doPlayerRemoveItem(cid, id, a)
					money = money + a*price
				
			end
		end
	end
	if money == 0 then
		doPlayerSendCancel(cid, "You don't have any container!")
	else
		doPlayerSendCancel(cid, "Added "..money.." gp.")
		doPlayerAddMoney(cid, money)
	end
	return true
end
 
LUA:
function checkContainer(uid)
    if (getContainerSize(uid) < 1) then
        return doRemoveItem(uid)
    end
    
    for k = (getContainerSize(uid) - 1), 0, -1 do
        local t = getContainerItem(uid, k)
        if (t.itemid > 0) then
            if isContainer(t.uid) then
                checkContainer(t.uid)
            end
        end
    end
end

function onSay(cid, words, param, channel)
    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.uid)
            end
        end
    end
    return true
end
 
LUA:
function checkContainer(uid)
    if (getContainerSize(uid) < 1) then
        return doRemoveItem(uid)
    end
    
    for k = (getContainerSize(uid) - 1), 0, -1 do
        local t = getContainerItem(uid, k)
        if (t.itemid > 0) then
            if isContainer(t.uid) then
                checkContainer(t.uid)
            end
        end
    end
end

function onSay(cid, words, param, channel)
    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.uid)
            end
        end
    end
    return true
end

wouldn't that skip some backpacks? :p
o wait no, it searches container backwards.
 

Similar threads

Back
Top