db.query("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())
-- 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
if balance >= lastBid then
db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
house:setOwnerGuid(highestBidder)
end
Script that 'deliver' houses can execute every hour, but page set 'end of auction' date to 5 minutes before restart of OTS. To make it 'safe' you must rewrite that part:
because it works fine at server start when all player ARE offline. If you execute it every hour you must check if player is online [new owner]. If he is you must use LUA function to check if he has enough money on account and LUA function to remove that money (not 'query').PHP:if balance >= lastBid then db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder) house:setOwnerGuid(highestBidder) end
If you want 'unlock' money that is on bank account [reserved for house] you must 'save' OTS after you deliver houses [to change 'owner' of house in database].
---------------------------------------------------Hello sir Gesior.pl
I followed every step and left me all ok, but the question I have is how to change the NPC Banker, since all have their own banker NPC script.
You switch to a banker npc script for your recommend, and neither worked, gold always goes 0) :.
If you can help me I would be very grateful
Cheers
My first OTS that uses house auctions:
http://huntia.org/index.php?subtopic=houses&world=0&show=34
Added Bootstrap style, jQuery table sorter (houses list), better town selector (JS, faast) and IMAGES OF ALL HOUSES.
Maybe I will make it TFS 1.x compatible (my ots uses 'otserv' engine) and release new version.
Soon I will release new version (v4) of:
OpenTibia - OTClient that unpack map.otbm to .png files - v2.0
with option to 'generate house images' by 1 click.
if ($houses_town == $id)
if ( ($houses_town == $id) or ($firstTown == false) )
data/globalevents/scripts/startup.lua:9: attempt to call global 'House' (a table value)
elseif msgcontains(msg, 'balance') then
local bid = getPlayerBiddedMoney(cid)
if(bid > 0) then
npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
else
npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
end
elseif msgcontains(msg, 'balance') then
local bid = getPlayerBiddedMoney(cid)
if(bid > 0) then
npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
elseif getPlayerBalance(cid) >= 100000000 then
npcHandler:say('I think you must be one of the richest inhabitants in the world! Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
return true
elseif getPlayerBalance(cid) >= 10000000 then
npcHandler:say('You have made ten millions and it still grows! Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
return true
elseif getPlayerBalance(cid) >= 1000000 then
npcHandler:say('Wow, you have reached the magic number of a million gp!!! Your account balance is ' .. getPlayerBalance(cid) .. ' gold!', cid)
return true
elseif getPlayerBalance(cid) >= 100000 then
npcHandler:say('You certainly have made a pretty penny. Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
return true
else
npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
return true
end
transfer[cid] = msg
local arrayDenied = {"accountmanager", "rooksample", "druidsample", "sorcerersample", "knightsample", "paladinsample"}
if isInArray(arrayDenied, string.gsub(transfer[cid]:lower(), " ", "")) then
npcHandler:say('This player does not exist.', cid)
npcHandler.topic[cid] = 0
return true
end