Olá, galera, preciso de um script que só uma certa storage pode usar o talkaction /aloot
queria por essa storage em uma quest, ai fazendo essa quest, ele ganha a storage que desbloqueia o comando aloot
Olá, galera, preciso de um script que só uma certa storage pode usar o talkaction /aloot
queria por essa storage em uma quest, ai fazendo essa quest, ele ganha a storage que desbloqueia o comando aloot
Acredito que isso possa te ajudar:
Adicione:
if getPlayerStorageValue(cid, ID) >= 1 then
ID = sua storage
Exemplo:
if getPlayerStorageValue(cid, 12345) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Comando utilizado Com sucesso !") doPlayerAddItem(cid, 16163, 1) elseif getPlayerStorageValue(cid, 12345) <= 0 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Faça a missão X, para desbloquear esse comando") end end
não esqueça de na sua quest adicionar
setPlayerStorageValue(cid, 12345, 1)
para que seja adicionado a Storage
no script do /aloot onde posso adicionar?
1 hora atrás, Fawkzz12 disse:no script do /aloot onde posso adicionar?
Manda o script
2 horas atrás, mastof disse:Manda o script
esse é o talkaction
local stor, limit = 7575, 30 --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
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 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
2 horas atrás, mastof disse:Manda o script
essa é o creaturescript
Citarfunction onLogin(cid) registerCreatureEvent(cid, "aloot_kill") return true end local stor = 7575 function autoloot(cid, target, pos) local function doStack(cid, itemid, new) local count = getPlayerItemCount(cid, itemid) if (count > 100) then count = count - math.floor(count / 100) * 100 end local newCount = count + new if (count ~= 0) then local find = getPlayerItemById(cid, true, itemid, count).uid if (find > 0) then doRemoveItem(find) else newCount = new end end local item = doCreateItemEx(itemid, newCount) doPlayerAddItemEx(cid, item, true) end local function scanContainer(cid, uid, list) for k = (getContainerSize(uid) - 1), 0, -1 do local tmp = getContainerItem(uid, k) if (isInArray(list, tmp.itemid)) then if isItemStackable(tmp.itemid) and (getPlayerItemCount(cid, tmp.itemid) > 0) then doStack(cid, tmp.itemid, tmp.type) else local item = doCreateItemEx(tmp.itemid, tmp.type) doPlayerAddItemEx(cid, item, true) end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Looted ' .. tmp.type .. ' ' .. getItemNameById(tmp.itemid) .. '.') doRemoveItem(tmp.uid) elseif isContainer(tmp.uid) then scanContainer(cid, tmp.uid, list) end end end local items = {} for i = getTileInfo(pos).items, 1, -1 do pos.stackpos = i table.insert(items, getThingFromPos(pos)) end if (#items == 0) then return end local corpse = -1 for _, item in ipairs(items) do local name = getItemName(item.uid):lower() if name:find(target:lower()) then corpse = item.uid break end end if (corpse ~= -1) and isContainer(corpse) then scanContainer(cid, corpse, tostring(getPlayerStorageValue(cid, stor)):gsub('_', ''):explode(',')) end end function onKill(cid, target, lastHit) if not isPlayer(target) then local infos = getPlayerStorageValue(cid, stor) if (infos == -1) then return true end local list = tostring(infos):explode(',') if (#list == 0) then return true end addEvent(autoloot, 150, cid, getCreatureName(target), getCreaturePosition(target)) end return true end
Tenta dessa forma:
Talkaction
local stor, limit = 7575, 30 --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] local storage = 12345 if getPlayerStorageValue(cid, storage) >= 1 then doPlayerSendCancel(cid, "Você não tem permissão para utilizar esse comando") return true end 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 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 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
Me fala se deu algum erro, não sou programador experiente, então não me julgue ;-;
não deu certo
12 horas atrás, Fawkzz12 disse:não deu certo
![]()
Vou editar aqui e te mando, agora com computador posso fazer teste
Testa ai
local stor, limit = 7575, 30 --storage, limit to add.
local block = 12345 -- sua storage aqui
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 getPlayerStorageValue(cid, block) >= 1 then
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
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 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
local stor, limit = 7575, 30 --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 getPlayerStorageValue(cid, 123456712) >= 1 then
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
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 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
elseif getPlayerStorageValue(cid, 123456712) <= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce precisa completar a missao X")
return true
end
end
O cara ja postou acima, acredito que resolva, mas ta aqui de qualquer forma
Em 11/02/2020 em 16:15, mastof disse:local stor, limit = 7575, 30 --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 getPlayerStorageValue(cid, 123456712) >= 1 then
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
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 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
elseif getPlayerStorageValue(cid, 123456712) <= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce precisa completar a missao X")
return true
end
endO cara ja postou acima, acredito que resolva, mas ta aqui de qualquer forma
O seu é para funcionar também, está parecido com o do colega acima, mas o seu tem a verificação caso o player não tenha valor para storage acima de 0. Porém vou te dar um conselho, no seu caso, não precisava ter feito aquele elseif, pois se o valor da storage não for 1 ou maior que 1 já vai executar o else, então seria bem melhor só colocar else. E também é mais fácil e legível criar uma variável para a storage, pois fica mais fácil de mexer no código e também a chance de errar o valor na verificação é menor.
Enfim, se nenhum dos dois códigos dos colegas acima não funcionar, tente este, é para funcionar:
local stor, limit = 7575, 30 --storage, limit to add. local allow_container = false --empty! not looted with items, atleast for now. local storage_quest = 25425 -- ID DA STORAGE DA QUEST PARA USAR O TALKACTION local texto = "Você precisa completar uma quest para usar este comando." function onSay(cid, words, param) local expl = param:explode(':') local action, rst = expl[1], expl[2] if getPlayerStorageValue(cid, storage) < 1 then doPlayerSendTextMessage(cid, 27, texto) doPlayerSendCancel(cid, texto) return true end 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 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 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
Lembrando que irá precisar colocar a storage que está usando na quest na variável storage_quest.
8 minutos atrás, Yan18 disse:O seu é para funcionar também, está parecido com o do colega acima, mas o seu tem a verificação caso o player não tenha valor para storage acima de 0. Porém vou te dar um conselho, no seu caso, não precisava ter feito aquele elseif, pois se o valor da storage não for 1 ou maior que 1 já vai executar o else, então seria bem melhor só colocar else. E também é mais fácil e legível criar uma variável para a storage, pois fica mais fácil de mexer no código e também a chance de errar o valor na verificação é menor.
Enfim, se nenhum dos dois códigos dos colegas acima não funcionar, tente este, é para funcionar:
local stor, limit = 7575, 30 --storage, limit to add. local allow_container = false --empty! not looted with items, atleast for now. local storage_quest = 25425 -- ID DA STORAGE DA QUEST PARA USAR O TALKACTION local texto = "Você precisa completar uma quest para usar este comando." function onSay(cid, words, param) local expl = param:explode(':') local action, rst = expl[1], expl[2] if getPlayerStorageValue(cid, storage) < 1 then doPlayerSendTextMessage(cid, 27, texto) doPlayerSendCancel(cid, texto) return true end 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 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 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 endLembrando que irá precisar colocar a storage que está usando na quest na variável storage_quest.
Agradeço pela dica, estou aprendendo então esses conselhos são bem importantes
7 minutos atrás, mastof disse:Agradeço pela dica, estou aprendendo então esses conselhos são bem importantes
Magina, eu imaginei que está aprendendo mesmo ?, no caso eu não tive ajuda para aprender, aprendi sozinho. Então procura sempre ajuda quando posso.