jareczekjsp
Member
Hello Everyone I have problem with Autoloot because I would like add to my server and I try and have errors like thats
When I say !loot add, gold or remove or something like that
my cripts is
Can somebody help me?
Talkaction script
I have from here
otland.net
When I say !loot add, gold or remove or something like that
Lua:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/auto_loot.lua:onSay
data/talkactions/scripts/auto_loot.lua:12: attempt to call method 'getVipDays' (a nil value)
stack traceback:
[C]: in function 'getVipDays'
data/talkactions/scripts/auto_loot.lua:12: in function 'addQuickItem'
data/talkactions/scripts/auto_loot.lua:165: in function <data/talkactions/scripts/auto_loot.lua:141>
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/auto_loot.lua:onSay
data/talkactions/scripts/auto_loot.lua:12: attempt to call method 'getVipDays' (a nil value)
stack traceback:
[C]: in function 'getVipDays'
data/talkactions/scripts/auto_loot.lua:12: in function 'addQuickItem'
data/talkactions/scripts/auto_loot.lua:165: in function <data/talkactions/scripts/auto_loot.lua:141>
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/auto_loot.lua:onSay
data/talkactions/scripts/auto_loot.lua:248: attempt to call global 'trim' (a nil value)
stack traceback:
[C]: in function 'trim'
data/talkactions/scripts/auto_loot.lua:248: in function <data/talkactions/scripts/auto_loot.lua:141>
Post automatically merged:
Can somebody help me?
Talkaction script
Lua:
local function addQuickItem(playerId, itemId, itemName)
local player = Player(playerId)
if not player then
return false
end
local itemType = ItemType(itemId)
if not itemType then
return false
end
local maxItem = player:getVipDays() > 0 and AUTOLOOT_MAXITEM_VIP or AUTOLOOT_MAXITEM_FREE
maxItem = maxItem + math.max(0, player:getStorageValue(AUTOLOOT_INCREASE))
local itemId = itemType:getId()
local playerGuid = player:getGuid()
local resultId = db.storeQuery(string.format('SELECT `item_id` FROM `quick_loot_list` WHERE `item_id` = %d AND `player_id` = %d', itemId, playerGuid))
if resultId then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, string.format("[AUTO LOOT] - O item %s já está em sua lista de Loot.", itemName))
result.free(resultId)
return false
end
-- Check max item count
local count = 0
local resultId = db.storeQuery(string.format('SELECT COUNT(*) as `count` FROM `quick_loot_list` WHERE `player_id` = %d', playerGuid))
if resultId then
count = result.getNumber(resultId, "count")
result.free(resultId)
end
if count >= maxItem then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[AUTO LOOT] - A sua lista já está completa, por favor remova algum item.")
return false
end
db.query(string.format('INSERT INTO `quick_loot_list` (`player_id`, `item_id`, `date_added`) VALUES (%d, %d, %d)', playerGuid, itemId, os.time()))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, string.format("[AUTO LOOT] - O item %s foi adicionado em sua lista de Loot.", itemName))
AutoLootList:save(playerId)
return true
end
local function removeQuickItem(playerId, itemId, itemName)
local player = Player(playerId)
if not player then
return false
end
local playerGuid = player:getGuid()
local resultId = db.storeQuery(string.format('SELECT `item_id` FROM `quick_loot_list` WHERE `player_id` = %d AND `item_id` = %d', playerGuid, itemId))
if not resultId then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, string.format("[AUTO LOOT] - O item %s năo está em sua lista de Loot", itemName))
return false
end
db.query(string.format('DELETE FROM `quick_loot_list` WHERE `player_id` = %d and `item_id` = %d', playerGuid, itemId))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, string.format("[AUTO LOOT] - O item %s foi removido da sua lista de Loot.", itemName))
AutoLootList:save(playerId)
return true
end
local function quickLootIsInList(playerId, itemId)
local resultId = db.storeQuery(string.format('SELECT `item_id` FROM `quick_loot_list` WHERE `player_id` = %d AND `item_id` = %d', playerId, itemId))
if resultId then
result.free(resultId)
return ' - Adicionado!'
end
return ''
end
local function itemListMonsterModal(playerId, monsterName)
local player = Player(playerId)
if not player then
return false
end
local monsterType = MonsterType(monsterName)
if not monsterType then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[AUTO LOOT] - Esse monstro năo existe ou năo está no mapa.")
return false
end
if monsterType:isRewardBoss() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[AUTO LOOT] - Vocę năo pode visualizar os Loot de Bosses de Reward Chest.")
return false
end
local monsterName = monsterType:getName()
local window = ModalWindow {
title = string.format('Loot do monstro %s', monsterName:lower()),
message = 'Adiciona ou remova itens desse monstro da sua lista de loot.',
}
local windowCount = 0
local t = {}
local playerGuid = player:getGuid()
if monsterType:getLoot() then
for _, v in pairs(monsterType:getLoot()) do
if windowCount < 255 then
local itemId = v.itemId
if not isInArray(t, itemId) then
local itemType = ItemType(itemId)
if itemType then
local itemName = itemType:getName()
local choice = window:addChoice(itemName .. quickLootIsInList(playerGuid, itemId))
windowCount = windowCount + 1
choice.itemId = itemId
choice.itemName = itemName
table.insert(t, itemId)
end
end
end
end
end
window:addButton("Remover",
function(button, choice)
if player and choice then
removeQuickItem(player:getId(), choice.itemId, choice.itemName)
itemListMonsterModal(playerId, monsterName)
end
end
)
window:addButton("Adicionar",
function(button, choice)
if player and choice then
addQuickItem(player:getId(), choice.itemId, choice.itemName)
itemListMonsterModal(playerId, monsterName)
end
end
)
window:addButton("Sair")
window:setDefaultEscapeButton("Sair")
window:sendToPlayer(player)
end
function onSay(player, words, param)
local split = param:split(",")
local action = split[1]
local playerGuid = player:getGuid()
if action == "add" then
if not split[2] then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[AUTO LOOT] - Use o comando: !loot add, itemName")
return false
end
local item = split[2]:gsub("%s+", "", 1)
local itemType = ItemType(item)
local itemId = itemType:getId()
if itemId == 0 then
itemType = ItemType(tonumber(item))
if itemId == 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[AUTO LOOT] - Năo existe nenhum item com esse nome.")
return false
end
end
-- Checar se o item já está na lista do jogador.
local itemName = tonumber(split[2]) and itemType:getName() or item
addQuickItem(player:getId(), itemId, itemName)
elseif action == "remove" then
if not split[2] then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Use o comando: !loot remove, itemName")
return false
end
local item = split[2]:gsub("%s+", "", 1)
local itemType = ItemType(item)
local itemId = itemType:getId()
if itemId == 0 then
itemType = ItemType(tonumber(item))
if itemId == 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Năo existe nenhum item com esse nome.")
return false
end
end
local itemName = tonumber(split[2]) and itemType:getName() or item
local resultId = db.storeQuery(string.format('SELECT `item_id` FROM `quick_loot_list` WHERE `item_id` = %d', itemId))
if not resultId then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, itemName .." năo foi encontrado em sua lista.")
return false
end
result.free(resultId)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, itemName .." foi removido de sua lista.")
removeQuickItem(player:getId(), itemId, itemName)
elseif action == "list" then
local count = 0
local resultId = db.storeQuery(string.format('SELECT COUNT(*) as `count` FROM `quick_loot_list` WHERE `player_id` = %d', playerGuid))
if resultId then
count = result.getNumber(resultId, "count")
result.free(resultId)
end
if count == 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[AUTO LOOT] - Vocę năo possui nenhum item em sua lista.")
return false
end
local resultId = db.storeQuery(string.format('SELECT `item_id` FROM `quick_loot_list` WHERE `player_id` = %d', playerGuid))
if not resultId then
return false
end
local window = ModalWindow {
title = "Sua lista de itens",
message = 'Essa é sua lista de itens!\nAssim que algum desses itens forem dropados, e ao clicar no corpo do monstro\no item será enviado para a sua backpack!',
}
local lootList = queryToTable(resultId, {'item_id:number'})
for _, loot in pairs(lootList) do
local itemType = ItemType(loot.item_id)
if itemType then
local itemName = itemType:getName()
local choice = window:addChoice(itemName)
choice.itemId = itemType:getId()
choice.itemName = itemName
end
end
window:addButton("Remover",
function(button, choice)
if player and choice then
removeQuickItem(player:getId(), choice.itemId, choice.itemName)
end
end
)
window:addButton("Sair")
window:setDefaultEscapeButton("Sair")
window:sendToPlayer(player)
elseif (action == "gold info") then
local obtainedMoney = player:getObtainedMoneyAutoLoot()
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("[AUTO LOOT - GOLD]: Atualmente no sistema de Auto Loot Gold vocę já fez %s gold coin%s.", comma_value(obtainedMoney), obtainedMoney ~= 1 and 's' or ''))
else
if not split[1] then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] - Os itens serăo movidos para a sua Backpack quando vocę abrir o corpo:\n!autoloot list - irá listar todos os itens na sua lista.\n!autoloot monsterName - verificar o loot de um monstro (exemplo: !autoloot rat)\n!autoloot add, itemName - adicionar um item pelo o nome\n!autoloot remove, itemName - remover o item pelo o nome")
return false
end
local monsterName = trim(split[1])
itemListMonsterModal(player:getId(), monsterName)
end
return false
end
Post automatically merged:
I have from here

Action - [Tfs 1.x+] auto loot using modal windows
how to use it is all in the files. along with credits the auto loot is similar to the one in the photo below
Attachments
-
Auto+Loot.zip26 KB · Views: 0 · VirusTotal
Last edited: