samandriel
Active Member
- Joined
- Oct 19, 2016
- Messages
- 242
- Solutions
- 1
- Reaction score
- 46
I have this auction system (made by @vDk ) :
https://otland.net/threads/offline-player-to-player-item-trader-auction-system.51447/
But i pretend to make a server with no resets, and be online for years, so if i never clean this auction system...
It will be a shit, full trash offer, to make my DB big for nothing
So i need to clean this thing, clean is not too hard...
The hard thing is send the item back from the owner
@andu made this script, but it's not complete and have a error
And i think he is not on forum anymore
https://otland.net/threads/offline-player-to-player-item-trader-auction-system.51447/
But i pretend to make a server with no resets, and be online for years, so if i never clean this auction system...
It will be a shit, full trash offer, to make my DB big for nothing
So i need to clean this thing, clean is not too hard...
The hard thing is send the item back from the owner
@andu made this script, but it's not complete and have a error
And i think he is not on forum anymore
Code:
<globalevent name="marketcleaner" type="startup" event="script" value="marketcleaner.lua"/>
Code:
-- local banana = knowledge
-- not sure is `town_id` or `town id` and same with `item_id` or `item id` etc
function onStartup()
local auctions = db.getResult("SELECT `id`, `player`, `date`, `item_id`, `count` FROM `auction_system` ORDER by `date` ASC;")
local players = db.getResult("SELECT `id`, `town_id` FROM `players`;")
local expireTime = 24 * 3600 * 1
local nowTime = os.date('*t')
if auctions:getID() ~= -1 then
while(true) do
local expired = time - expireTime
if expired >= 0 then
local a_id = auctions:getDataInt("id")
local a_player_id = auctions:getDataInt("player")
local a_itemid = auctions:getDataInt("item_id")
local a_itemcount = auctions:getDataInt("count")
local date = auctions:getDataInt("date")
local player_town = players:getDataInt("town_id")
local time = os.time(nowTime) - date
-- send item back to old owner
local depot_items = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = `"..a_player_id.."` AND `pid` = `"..player_town.."`;")
if depot_items:getID() ~= -1 then
local depotBlackBoxSid = depot_items:getDataInt("sid")
local black_depotbox_items = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = `"..a_player_id.."` AND `pid` = `"..depotBlackBoxSid.."` ORDER by `sid` ASC;")
local newSid = #black_depotbox_items + 1 -- not sure this is the way to check it
db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`) VALUES ("..a_player_id..", "..newSid..", "..depotBlackBoxSid..", "..a_itemid..", "..a_itemcount..")")
-- delete item
-- db.executeQuery("DELETE FROM `auction_system` WHERE `id` = '"..a_id.."';")
else
-- if player doesnt opened his depo yet, create new two lines in db then execute the same code up
-- bla bla bla
-- bla bla bla
end
end
if not(auctions:next()) then
break
end
end
auctions:free()
end
return true
end
Code:
12:45:02.944] [Error - GlobalEvent Interface]
[12:45:02.944] data/globalevents/scripts/marketcleaner.lua:onStartup
[12:45:02.944] Description:
[12:45:02.944] data/globalevents/scripts/marketcleaner.lua:10: attempt to perform arithmetic on global 'time' (a nil value)
[12:45:02.944] stack traceback:
[12:45:02.944] data/globalevents/scripts/marketcleaner.lua:10: in function <data/globalevents/scripts/marketcleaner.lua:3>