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

Autoloot Error

Fabiaanzky

New Member
Joined
Nov 12, 2014
Messages
30
Reaction score
1
Location
Chile
I have an error in my autoloot MOD, at the time of adding an item to the list the system does not recognize me send a message to the player (this item does not exist)
and also throws the following console error.
mi tfs 0.4 (otxserv 2) version 8.60

this is the console error

Captura.PNG

this is my talkaction code that gives error when adding the item to my autoloot slots

Code:
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local param, slots = param:lower(), isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free
if not param or param == "" then
    ShowItemsTabble(cid) return true
elseif tonumber(param) then
    doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
elseif isInArray({"clean","limpar", "clear"}, param) then
    setPlayerStorageValue(cid, info.Storages[1], -1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
elseif isInArray({"start","stop","on","off"}, param) then
    setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "Stopped" or "Started")..".") return true
elseif isInArray({"money","gold","gps","dinheiro"}, param) then
    setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Gold Colleting "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled")..".") return true
end
local item = getItemIdByName(param, false)
if not item then
    doPlayerSendTextMessage(cid, MESSAGE_FIRST, "This item does not exist.") return true
end
local var = isInTable(cid, item)
if isInArray({2148,2152,2160},item) then
    doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Enter !autoloot money to add money in your list!") return true   
elseif isInArray(info.BlockItemsList, item) then
    doPlayerSendTextMessage(cid, MESSAGE_FIRST, "You can not add this item in the list!") return true
elseif not var and #getPlayerStorageTable(cid, info.Storages[1]) >= slots then
    doPlayerSendTextMessage(cid, MESSAGE_FIRST, "max "..slots.." from auto loot") return true
end
if not var then
    addItemTable(cid, item)
else
    removeItemTable(cid, item)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "You added the item "..param.." in the list" or "You removed the item "..param.." from the list")
return true]]></talkaction>
 
What command are you trying to execute in game?
Try to print what value is kept in "param" variable right before error-causing line (#18).
 
Last edited:
I can suggest you to debug it by printing. I cannot see any issues with the part code u provided.
Also getItemIdByName(param, false) should not print an error to console thanks to false value (//getItemIdByName(name[, displayError = true])).
Put some print between 17 and 18 line like:
print('param: ' .. param)
and some print between 18 and 19 just to ensure what is the value of item variable like:
print('item: ' .. tostring(item))

it should give you some details about your code behaviour.
 
Back
Top