newby
Active Member
- Joined
- Jun 11, 2016
- Messages
- 183
- Reaction score
- 43
I do using this auction system:
TalkAction - Offline player to player item trader (Auction System).
Using some others script as base i'm trying to make a script to when auction get more then 30 days on auction list it came back to offer creator, but i'm not getting, someone could help me?
Error on init:
Script:
<globalevent name="marketcleaner" type="startup" event="script" value="marketcleaner.lua"/>
TalkAction - Offline player to player item trader (Auction System).
Using some others script as base i'm trying to make a script to when auction get more then 30 days on auction list it came back to offer creator, but i'm not getting, someone could help me?
Error on init:
Code:
[19:20:35.932] >> Checking world type... Open PvP
[19:20:35.932] >> Initializing game state and binding services...
[19:20:35.979] mysql_real_query(): SELECT `id`, `date`, `player`, `itemid`, `count` FROM `auction_system` ORDER by `date` ASC; - MYSQL ERROR: Unknown column 'itemid' in 'field list' (1054)
[19:20:35.979] [Error - GlobalEvent Interface]
[19:20:35.979] data/globalevents/scripts/marketcleaner.lua:onStartup
[19:20:35.979] Description:
[19:20:35.979] data/lib/004-database.lua:100: [Result:free] Result not set!
[19:20:35.979] stack traceback:
[19:20:35.979] [C]: in function 'error'
[19:20:35.979] data/lib/004-database.lua:100: in function 'free'
[19:20:35.979] data/globalevents/scripts/marketcleaner.lua:33: in function <data/globalevents/scripts/marketcleaner.lua:1>
[19:20:35.979] > Global IP address: 127.0.0.1
Script:
<globalevent name="marketcleaner" type="startup" event="script" value="marketcleaner.lua"/>
Code:
function onStartup()
local result = db.getResult("SELECT `id`, `date`, `player`, `itemid`, `count` FROM `auction_system` ORDER by `date` ASC;")
local days = 30*3600*24
local nowtime = os.date('*t')
if(result and result:getID() ~= -1) then
while(true) do
local id = result:getDataInt("id")
local date = result:getDataInt("date")
local player = result:getDataInt("player")
local itemid = result:getDataInt("item_id")
local count = result:getDataInt("count")
local depotid = player:getTown():getId()
local resultId = db.storeQuery("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = `" .. player:getId().. "` ORDER BY `sid` DESC LIMIT 1;")
local sid = result.getNumber(resultId, "sid") + 1
result.free(resultId)
local pid = 101
local time= os.time(nowtime) - date
local duedate = time - days
if duedate >= 0 then
-- send item back to the owner
db.storeQuery("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = `" .. player:getId().. "`;")
db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `depot_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ('".. player .."', '".. depotid .."', '".. sid .."', '".. pid .."', '".. itemid .."', '".. count .."');")
-- delete offer
db.executeQuery("DELETE FROM `auction_system` WHERE `id` = '".. id .."';")
end
if not(result:next()) then
break
end
end
end
result:free()
end