I hope it will work fine on your OTSes. I made it some time ago and it was compatible with TFS 1.0 house auctions system [which is implemented in every TFS 1.0].
Houses list:
House page:
Houses are delivered after server restart. You must use auto-restarter [search in google] and configure in config.lua to restart server every day at X hour.
If you don't have this in config.lua of OTS, add it:
You can change hour to any other (0-23). Server will close itself at this hour (show messages about it before close like rl tibia server). You need auto-restarter script to start it again everytime.
This is houses.php page with auctions [at top you can config auctions length]:
http://paste.ots.me/560433/text
You MUST use this Banker NPC script. It updates database every time you change balance of your bank account and don't let players buy houses for 0 gold coins (like it could with normal banker).
Banker NPC script:
http://paste.ots.me/560445/text
Check file data/globalevents/scripts/startup.lua , there should be this code (paste if it's not there):
-- EDIT, REASON: forgot to paste LUA fix (1 line) --
In LUA under:
Add:
After changes it should be:
Houses list:
House page:
Houses are delivered after server restart. You must use auto-restarter [search in google] and configure in config.lua to restart server every day at X hour.
If you don't have this in config.lua of OTS, add it:
PHP:
-- Server save
-- NOTE: serverSaveHour is the hour of the day when the server save will occur,
-- if you would rather save the server with intervals, disable server save and
-- use autoSaveEachMinutes.
serverSaveEnabled = "yes"
serverSaveHour = 10
shutdownAtServerSave = "yes"
This is houses.php page with auctions [at top you can config auctions length]:
http://paste.ots.me/560433/text
You MUST use this Banker NPC script. It updates database every time you change balance of your bank account and don't let players buy houses for 0 gold coins (like it could with normal banker).
Banker NPC script:
http://paste.ots.me/560445/text
Check file data/globalevents/scripts/startup.lua , there should be this code (paste if it's not there):
PHP:
-- Check house auctions
local resultId = db.storeQuery("SELECT `id`, `highest_bidder`, `last_bid`, (SELECT `balance` FROM `players` WHERE `players`.`id` = `highest_bidder`) AS `balance` FROM `houses` WHERE `owner` = 0 AND `bid_end` != 0 AND `bid_end` < " .. os.time())
if resultId ~= false then
repeat
local house = House(result.getDataInt(resultId, "id"))
if house ~= nil then
local highestBidder = result.getDataInt(resultId, "highest_bidder")
local balance = result.getDataLong(resultId, "balance")
local lastBid = result.getDataInt(resultId, "last_bid")
if balance >= lastBid then
db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
house:setOwnerGuid(highestBidder)
end
end
until not result.next(resultId)
result.free(resultId)
end
-- EDIT, REASON: forgot to paste LUA fix (1 line) --
In LUA under:
PHP:
if balance >= lastBid then
db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
house:setOwnerGuid(highestBidder)
end
PHP:
db.query("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())
PHP:
-- Check house auctions
local resultId = db.storeQuery("SELECT `id`, `highest_bidder`, `last_bid`, (SELECT `balance` FROM `players` WHERE `players`.`id` = `highest_bidder`) AS `balance` FROM `houses` WHERE `owner` = 0 AND `bid_end` != 0 AND `bid_end` < " .. os.time())
if resultId ~= false then
repeat
local house = House(result.getDataInt(resultId, "id"))
if house ~= nil then
local highestBidder = result.getDataInt(resultId, "highest_bidder")local balance = result.getDataLong(resultId, "balance")local lastBid = result.getDataInt(resultId, "last_bid")
if balance >= lastBid then
db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
house:setOwnerGuid(highestBidder)
end
-- here new code:
db.query("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())
end
until not result.next(resultId)
result.free(resultId)
end
Last edited: