• 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!

Talkaction bug

klekSu

Stroke my ego.
Joined
Nov 4, 2008
Messages
1,285
Reaction score
18
Hey there, I've got a problem with that talkaction. When I use /aloot add:itemName and add it up to 5 everything is fine, however, when I try to /aloot remove:itemName having 5 items on the list and then /aloot add:itemName it still says that I got 5 items even if my there are 4 items /aloot check, hope you understood :p

There is also bug that it doesn't loot from bags. I've been trying to fix it but that's like not possible, it also doesn't loot from some of the monsters, why's that?

I'll appreciate any help, thanks.

Lua:
  local stor, limit = 7575, 5        --storage, limit to add.

local allow_container = false    --empty! not looted with items, atleast for now.

function onSay(cid, words, param)
    local expl = param:explode(':')
    local action, rst = expl[1], expl[2]
    if (action:lower() == 'check') then
        local infos, list = getPlayerStorageValue(cid, stor), {}
        if (infos ~= -1) then
            list = tostring(infos):explode(',')
        end
        local txt = 'Autoloot List:\n'
        if (#list > 0) then
            for k, id in ipairs(list) do
                id = id:gsub('_', '')
                if tonumber(id) then
                    txt = txt .. getItemNameById(tonumber(id)) .. ((k < #list) and '\n' or '')
                end
            end
        else
            txt = 'Empty'
        end
        doPlayerPopupFYI(cid, txt)
    elseif (action:lower() == 'add') then
        local infos, list = getPlayerStorageValue(cid, stor), {}
        if (infos ~= -1) then
            list = tostring(infos):gsub('_', ''):explode(',')
        end
        if (#list >= limit) then
            return doPlayerSendCancel(cid, 'You already have ' .. limit .. ' autolooting items.')
        end
        local item = tonumber(rst)
        if not item then
            item = getItemIdByName(rst, false)
            if not item then
                return doPlayerSendCancel(cid, 'not valid item.')
            end
        end
        if not allow_container and isItemContainer(item) then
            return doPlayerSendCancel(cid, 'this item can not be autolooted.')
        end
        local attrs = getItemInfo(item)
        if not attrs then
            return doPlayerSendCancel(cid, 'not valid item.')
        elseif not attrs.movable or not attrs.pickupable then
            return doPlayerSendCancel(cid, 'this item can not be autolooted.')
        end
        if isInArray(list, item) then
            return doPlayerSendCancel(cid, 'already added.')
        end
        table.insert(list, tostring(item))
        local new = ''
        for v, id in ipairs(list) do
            new = new .. '_' .. id:gsub('_' ,'') .. ((v < #list) and ',' or '')
        end
        doPlayerSetStorageValue(cid, stor, tostring(new))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Item >>' .. getItemNameById(item) .. '<< has been added to the autoloot list.')
    elseif (action:lower() == 'remove') then
        local infos, list = getPlayerStorageValue(cid, stor), {}
        if (infos ~= -1) then
            list = tostring(infos):gsub('_', ''):explode(',')
        end
        if (#list == 0) then
            return doPlayerSendCancel(cid, 'You dont have any item added.')
        end

        local item = tonumber(rst)
        if not item then
            item = getItemIdByName(rst, false)
            if not item then
                return doPlayerSendCancel(cid, 'not valid item.')
            end
        end
        if not isInArray(list, item) then
            return doPlayerSendCancel(cid, 'This item is not in the list.')
        end
        local new = ''
        for v, id in ipairs(list) do
            if (tonumber(id) ~= item) then
                new = new .. '_' .. id:gsub('_' ,'') .. ((v < #list) and ',' or '')
            end
        end
        doPlayerSetStorageValue(cid, stor, tostring(new))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Item >>' .. getItemNameById(item) .. '<< removed from the autoloot list.')
    end        
    return true
end
 
here is the fix ;P

PHP:
local stor, limit = 7575, 5 --storage, limit to add.
 
local allow_container = false --empty! not looted with items, atleast for now.
 
function onSay(cid, words, param)
if isPremium(cid) then
    local expl = param:explode(':')
    local action, rst = expl[1], expl[2]
    if (action:lower() == 'check') then
        local infos, list = getPlayerStorageValue(cid, stor), {}
        if (infos ~= -1) then
            list = tostring(infos):explode(',')
        end
        local txt = 'Autoloot Lista:\n'
        if (#list > 0) then
            for k, id in ipairs(list) do
                id = id:gsub('_', '')
                if tonumber(id) then
                    txt = txt .. getItemNameById(tonumber(id)) .. ((k < #list) and '\n' or '')
                end
            end
        else
            txt = 'Vazio'
        end
        doPlayerPopupFYI(cid, txt)
    elseif (action:lower() == 'add') then
        local infos, list = getPlayerStorageValue(cid, stor), {}
        if (infos ~= -1) then
            list = tostring(infos):gsub('_', ''):explode(',')
        end
        if (#list >= limit) then
            return doPlayerSendCancel(cid, 'Você ja tem ' .. limit .. ' itens.(Maximo)')
        end
        local item = tonumber(rst)
        if not item then
            item = getItemIdByName(rst, false)
            if not item then
                return doPlayerSendCancel(cid, 'Item não é valido.')
            end
        end
        if not allow_container and isItemContainer(item) then
            return doPlayerSendCancel(cid, 'Este item nao pode ser lootado.')
        end
        local attrs = getItemInfo(item)
        if not attrs then
            return doPlayerSendCancel(cid, 'Item não é valido.')
        elseif not attrs.movable or not attrs.pickupable then
            return doPlayerSendCancel(cid, 'Este item nao pode ser lootado.')
        end
        if isInArray(list, item) then
            return doPlayerSendCancel(cid, 'já adicionado.')
        end
        table.insert(list, tostring(item))
        local new = ''
        for v, id in ipairs(list) do
            new = new .. '_' .. id:gsub('_' ,'') .. ((v < #list) and ',' or '')
        end
        doPlayerSetStorageValue(cid, stor, tostring(new))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Item >>' .. getItemNameById(item) .. '<< foi adicionado à lista de autoloot.')
    elseif (action:lower() == 'remove') then
        local infos, list = getPlayerStorageValue(cid, stor), {}
        if (infos ~= -1) then
            list = tostring(infos):gsub('_', ''):explode(',')
        end
        if (#list == 0) then
            return doPlayerSendCancel(cid, 'Você não tem nenhum item adicionado.')
        end
        local item = tonumber(rst)
        if not item then
            item = getItemIdByName(rst, false)
            if not item then
                return doPlayerSendCancel(cid, 'Item não é valido.')
            end
        end
        if not isInArray(list, item) then
            return doPlayerSendCancel(cid, 'Este item não está na lista.')
        end
        local new = ''
        for v, id in ipairs(list) do
            if (tonumber(id) ~= item) then
                new = new .. '_' .. id:gsub('_' ,'') .. ((v < #list) and ',' or '')
            end
        end
        doPlayerSetStorageValue(cid, stor, tostring(new))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Item >>' .. getItemNameById(item) .. '<< removido da lista autoloot.')
    end        
    return true
end
end

if i help you rep me ;P
sry my inglish
 
Back
Top