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

TFS 0.X Offer expire auction system

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:
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
 
Solution
Lua:
function getPlayerNameByGUID(guid)
local name = 0
      local resultId = db.getResult("SELECT `name` FROM `players` WHERE `id` = " .. guid)
      if(resultId:getID() ~= -1) then
    name = resultId.getDataString(resultId, "name")
          resultId:free()
      end
      return name
end

 function onStartup()
   local result = db.getResult("SELECT `id`, `player`, `item_id`, `item_name`, `count`, `cost`, `date` 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 player = result:getDataString("player")
       local item_id = result:getDataInt("item_id")
       local...
you need to check if result exists before freeing it
i'd also recommend you rename the variable "result" because it has a naming conflict with the result table
 
you need to check if result exists before freeing it
i'd also recommend you rename the variable "result" because it has a naming conflict with the result table

Could you help me? I'm starter :S

Code:
function onStartup()
   local r = 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(r and r:getID() ~= -1) then
     while(true) do
       local id = r:getDataInt("id")
       local date = r:getDataInt("date")
       local player = r:getDataInt("player")
       local itemid = r:getDataInt("item_id")
       local count = r: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 = r.getNumber(resultId, "sid") + 1
       r.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(r:next()) then
           break
       end
   end
   end
   r:free()
end

That's not the check u told?
Code:
if(r and r:getID() ~= -1) then
 
Back
Top