Kaboo
New Member
- Joined
- Feb 14, 2009
- Messages
- 142
- Reaction score
- 0
Hi, I'm using Gesior Shop System to deliver Custom Spells, storageIds and Premium Time, I've modified the globalevents/scripts/shop.lua script and it works perfectly, except when many spells have to be delivered at the some time to various players, and one or more players that should receive them are offline.
I'm using TFS 0.4 rev 3884 for Tibia 8.60, and here's my shop.lua:
Gesior website will mark them as items on the item shop, but they will delivered as spells and storages: Item name is the spell name and item id is the storage id.
This is the error in console:
I've tried a lot of things, but unfortunately I could not solve it. Any help will be apreciated!
Thanks! :thumbup:
I'm using TFS 0.4 rev 3884 for Tibia 8.60, and here's my shop.lua:
Code:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
if(result_plr:getID() ~= -1) then
while(true) do
id = tonumber(result_plr:getDataInt("id"))
action = tostring(result_plr:getDataString("action"))
delete = tonumber(result_plr:getDataInt("delete_it"))
cid = getCreatureByName(tostring(result_plr:getDataString("name")))
if isPlayer(cid) == TRUE then
local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
local container_id = tonumber(result_plr:getDataInt("param3"))
local container_count = tonumber(result_plr:getDataInt("param4"))
local add_item_type = tostring(result_plr:getDataString("param5"))
local add_item_name = tostring(result_plr:getDataString("param6"))
local received_item = 0
local full_weight = 0
if add_item_type == 'item' then
received_item = doPlayerLearnInstantSpell(cid, add_item_name)
received_item = doPlayerSetStorageValue(cid, itemtogive_id, 1)
end
if received_item == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Received >> '.. add_item_name ..' << for donating.')
doPlayerSave(cid)
db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Received >> '.. add_item_name ..' << for donating.')
doPlayerSave(cid)
db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
end
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Received >> '.. add_item_name ..' << for donating.')
doPlayerSave(cid)
db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
end
if not(result_plr:next()) then
break
end
end
result_plr:free()
end
return TRUE
end
This is the error in console:
Code:
[11:35:56.281] [Error - GlobalEvent Interface]
[11:35:56.281] data/globalevents/scripts/shop.lua:onThink
[11:35:56.281] Description:
[11:35:56.281] data/globalevents/scripts/shop.lua:40: attempt to concatenate global 'add_item_name' (a nil value)
[11:35:56.281] stack traceback:
[11:35:56.281] data/globalevents/scripts/shop.lua:40: in function <data/globalevents/scripts/shop.lua:7>
[11:35:56.281] [Error - GlobalEvents::think] Couldn't execute event: shop
I've tried a lot of things, but unfortunately I could not solve it. Any help will be apreciated!
Thanks! :thumbup:
Last edited: