• 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...
Add this in SQL:
JavaScript:
ALTER TABLE `auction_system` ADD `itemid` INT(11) NOT NULL;

There is already this one
...
PHP:
[LIST=1]
[*]CREATE TABLE `auction_system` (
[*]  `id` int(11) NOT NULL auto_increment,
[*]  `player` int(11),
[*]  `item_id` int(11),
[*]  `item_name` varchar(255),
[*]  `count` int(11),
[*]  `cost` int(11),
[*]  `date` int(11),
[*]  PRIMARY KEY  (`id`)
[*]) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
[/LIST]
 
So.. search for:
JavaScript:
SELECT `id`, `date`, `player`, `itemid`, `count` FROM `auction_system` ORDER by `date` ASC; - MYSQL ERROR: Unknown column 'itemid'

And replace for TABLE information above!
 
So.. search for:
JavaScript:
SELECT `id`, `date`, `player`, `itemid`, `count` FROM `auction_system` ORDER by `date` ASC; - MYSQL ERROR: Unknown column 'itemid'

And replace for TABLE information above!

I'm sorry, but what are u saying, i dont understanding...
 
I'm sorry, but what are u saying, i dont understanding...
Edit marketcleaner.lua as below and try:
Lua:
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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       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
 
Edit marketcleaner.lua as below and try:
Lua:
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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       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

Thank you to try to help us...
Sorry this too long, i thought no one know how to do it...

But i got some errors when try to run this script:
Code:
       local depotid = 1
--       local depotid = player:getTown():getId()
-- [Error - GlobalEvent Interface]
-- data/globalevents/scripts/marketcleaner.lua:onStartup
-- Description:
-- data/globalevents/scripts/marketcleaner.lua:14: attempt to call method 'getTown' (a nil value)
-- stack traceback:
-- data/globalevents/scripts/marketcleaner.lua:14: in function <data/globalevents/scripts/marketcleaner.lua:1>

And
Code:
[11:8:02.642] [Error - GlobalEvent Interface]
[11:8:02.642] data/globalevents/scripts/marketcleaner.lua:onStartup
[11:8:02.642] Description:
[11:8:02.642] data/globalevents/scripts/marketcleaner.lua:24: attempt to call method 'getId' (a nil value)
[11:8:02.642] stack traceback:
[11:8:02.643]    data/globalevents/scripts/marketcleaner.lua:24: in function <data/globalevents/scripts/marketcleaner.lua:1>

Line 24:
Code:
local resultId = db.storeQuery("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = `" .. player:getId().. "` ORDER BY `sid` DESC LIMIT 1;")

Full script
Code:
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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")

       local depotid = 1
--       local depotid = player:getTown():getId()
-- [Error - GlobalEvent Interface]
-- data/globalevents/scripts/marketcleaner.lua:onStartup
-- Description:
-- data/globalevents/scripts/marketcleaner.lua:14: attempt to call method 'getTown' (a nil value)
-- stack traceback:
-- data/globalevents/scripts/marketcleaner.lua:14: in function <data/globalevents/scripts/marketcleaner.lua:1>

       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
 
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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       local chest = doCreateItemEx(2595)
       local time= os.time(nowtime) - date
       local duedate = time - days
       if duedate >= 0 then
           doAddContainerItem(chest, item_id, count)
           doPlayerSendMailByName(getPlayerNameByGUID(player), chest, getPlayerTown(getPlayerNameByGUID(player)))
           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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       local chest = doCreateItemEx(2595)
       local time= os.time(nowtime) - date
       local duedate = time - days
       if duedate >= 0 then
           doAddContainerItem(chest, item_id, count)
           doPlayerSendMailByName(getPlayerNameByGUID(player), chest, getPlayerTown(getPlayerNameByGUID(player)))
           db.executeQuery("DELETE FROM `auction_system` WHERE `id` = '".. id .."';")
       end
       if not(result:next()) then
           break
       end
   end
   end
   result:free()
end


When i start the server with 2 offers to clean:
Code:
[7:52:09.230] [Error - GlobalEvent Interface]
[7:52:09.230] data/globalevents/scripts/marketcleaner.lua:onStartup
[7:52:09.230] Description:
[7:52:09.230] (internalGetPlayerInfo) Player not found when requesting player info #7

[7:52:09.660] [Error - GlobalEvent Interface]
[7:52:09.660] data/globalevents/scripts/marketcleaner.lua:onStartup
[7:52:09.660] Description:
[7:52:09.660] (internalGetPlayerInfo) Player not found when requesting player info #7
Segmentation fault
 
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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       local chest = doCreateItemEx(2595)
       local time= os.time(nowtime) - date
       local duedate = time - days
       local town_id = 1
       if duedate >= 0 then
           doAddContainerItem(chest, item_id, count)
           doPlayerSendMailByName(getPlayerNameByGUID(player), chest, town_id)
           db.executeQuery("DELETE FROM `auction_system` WHERE `id` = '".. id .."';")
       end
       if not(result:next()) then
           break
       end
   end
   end
   result:free()
end
 
Last edited:
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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       local chest = doCreateItemEx(2595)
       local time= os.time(nowtime) - date
       local duedate = time - days
       local town_id = 1
       if duedate >= 0 then
           doAddContainerItem(chest, item_id, count)
           doPlayerSendMailByName(getPlayerNameByGUID(player), chest, town_id)
           db.executeQuery("DELETE FROM `auction_system` WHERE `id` = '".. id .."';")
       end
       if not(result:next()) then
           break
       end
   end
   end
   result:free()
end


Code:
[15:36:34.783] [Error - GlobalEvent Interface]
[15:36:34.783] data/globalevents/scripts/marketcleaner.lua:onStartup
[15:36:34.783] Description:
[15:36:34.783] data/lib/004-database.lua:100: [Result:free] Result not set!
[15:36:34.783] stack traceback:
[15:36:34.783]    [C]: in function 'error'
[15:36:34.783]    data/lib/004-database.lua:100: in function 'free'
[15:36:34.783]    data/globalevents/scripts/marketcleaner.lua:38: in function <data/globalevents/scripts/marketcleaner.lua:11>

But items was sended to DP's owner
 
Everytime i see a sql, after finish i see a result:free
it's not necessary?

i mean, we will have no problem by using this script without this last result:free()

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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       local chest = doCreateItemEx(2595)
       local time= os.time(nowtime) - date
       local duedate = time - days
       if duedate >= 0 then
           doAddContainerItem(chest, item_id, count)
           doPlayerSendMailByName(getPlayerNameByGUID(player), chest, getTownName(getPlayerTown(cid)))
           db.executeQuery("DELETE FROM `auction_system` WHERE `id` = '".. id .."';")
       end
       if not(result:next()) then
           break
       end
        result:free()
   end
   end
end
 
Last edited:
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 item_name = result:getDataString("item_name")
       local count = result:getDataInt("count")
       local cost = result:getDataInt("cost")
       local date = result:getDataInt("date")
       local chest = doCreateItemEx(2595)
       local time= os.time(nowtime) - date
       local duedate = time - days
       if duedate >= 0 then
           doAddContainerItem(chest, item_id, count)
           doPlayerSendMailByName(getPlayerNameByGUID(player), chest, getTownName(getPlayerTown(cid)))
           db.executeQuery("DELETE FROM `auction_system` WHERE `id` = '".. id .."';")
       end
       if not(result:next()) then
           break
       end
        result:free()
   end
   end
end
Mine got an error, can u help me?

2022-09-07 05:40:27 - [Error - GlobalEvent Interface]
2022-09-07 05:40:27 - data/globalevents/scripts/marketcleaner.lua:eek:nStartup
2022-09-07 05:40:27 - Description:
2022-09-07 05:40:27 - (internalGetPlayerInfo) Player not found when requesting player info #7
2022-09-07 05:40:27 -
2022-09-07 05:40:27 - [Error - GlobalEvent Interface]
2022-09-07 05:40:27 - data/globalevents/scripts/marketcleaner.lua:eek:nStartup
2022-09-07 05:40:27 - Description:
2022-09-07 05:40:27 - data/lib/004-database.lua:66: [Result:getDataInt] Result not set!
2022-09-07 05:40:27 - stack traceback:
2022-09-07 05:40:27 - [C]: in function 'error'
2022-09-07 05:40:27 - data/lib/004-database.lua:66: in function 'getDataInt'
2022-09-07 05:40:27 - data/globalevents/scripts/marketcleaner.lua:17: in function <data/globalevents/scripts/marketcleaner.lua:11>
 
Back
Top