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

[GESIOR2012] Houses auctions on WWW for TFS 1.0

:p I just changed from last_bid to bid and it shows the current highest bid on all auctioned houses, which to me is more realistic
 
Does anyone know how to edit the !sellhouse command so that it will:

Code:
db.query("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())

OR does anyone know how to make it into a talkaction?
 
Hey @Gesior.pl , If I make this a globalevent, will it work just fine like it does on start up?

Like check for new owners every hour for example.

Code:
    -- 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
 
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:
PHP:
if balance >= lastBid then
db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
house:setOwnerGuid(highestBidder)
end
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').
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].
 
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:
PHP:
if balance >= lastBid then
db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
house:setOwnerGuid(highestBidder)
end
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').
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].

Thanks for the explanation!
 
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
 
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
---------------------------------------------------

Mr. Gesior.pl

The mistake that gave me yesterday, magically, was resolved only xDD
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.


You did a great job.
 
Hey @Gesior.pl

Auto select first town, small fix.

in houses.php
replace ~~ line 145:
Code:
if ($houses_town == $id)

to
Lua:
if ( ($houses_town == $id) or ($firstTown == false) )

1601943272734.png
 
Last edited:
Does it work in Othire 1.0???

I get this error:

Lua:
data/globalevents/scripts/startup.lua:9: attempt to call global 'House' (a table value)
 
Last edited:
Implemented to TFS 1.5 Downgrade and it's working (at server save after bid has ended, house transfers to player)
One issue is Gesior2012 doesn't come with "sbutton_bid.gif" and currently tibia.com uses the blue buttons while gesior uses the slate buttons so I just replaced with submit button for now. Could you please upload the bid button for us?

Also, I am currently using a banker w/ Guild Bank system. Could you help with updating the real tibia npc @Gesior.pl?

Naji.lua
 
If anyone needs the Place Bid icon here it is!
As gesior reminded me, there is a empty button in images so I created my own.

sbutton_bid.gif

Also if you guys would like to update the NPC file provided with the following code - the npc behaves more like the real tibia one.

Replace the following..
Code:
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

With..
Code:
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

Also to avoid players transferring money to the account manager or character samples;
Find:
Code:
transfer[cid] = msg

Paste Underneath: (should be 2 times)
Code:
                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

Complete Script fairly similar to Real Tibia:
 
Last edited:
has anyone tried to do such a script but without the bank system ?
Im doing ots 7.4 client and i dont wanna make bank system
 
Back
Top