Znote / ZnoteAAC

Developement repository for the Znote AAC project. A website portal to represent and manage your Open Tibia server.
MIT License
145 stars 127 forks source link

House Bid #470

Closed htc16 closed 3 years ago

htc16 commented 3 years ago

Good afternoon!

Znote, I am not able to solve the problem regarding the purchase of house on the website. I use the Nostalrius base, and when I try to buy a house it says that I have no money. I imagine that the problem is associated with the balance, which in the case of nostalrius there is not. Everything is done by players_items. Would I have to change the balance check to look for money in players_items, in house.php?

$yourChars = mysql_select_multi("SELECTid,name,balanceFROMplayersWHEREaccount_id='". $user_data['id'] ."';");

How would I go about looking for money in the player instead of the balance on balance?

Thank you!

Znote commented 3 years ago

I would query depotitems table for itemids associated to currency, calculate and sum their values together for each player. I think in the olden days, if you wanted to buy or pay rent for carlin houses, you needed to place the money inside carlin depot. That narrows down the search in the SQL query to player id and depot id.

Getting the balance is the easy part though, removing the money can be a bit tricky. You need to keep track of the unique identifiers for each row containing some currency item, remove it until the last stack, and update the last stack to its appropriate value, or replace it with the remaining gold. The player has to be offline for this to work, so it might be best to do it in-game on server startup.

If you link me your database schema structure, I might build a few queries for you. But I don't have time to test them.

htc16 commented 3 years ago

Many thanks for the reply. But there is already a configuration that performs this form of payment. As seen here: https://github.com/TwistedScorpio/Nostalrius/issues/47#issuecomment-492620370 and https://github.com/V0RT4C/Nostalrius/commit/a63f33b345cefcd1eabbbd4781ce2c01440c19e8

The work of paying directly for the corresponding depot is already set up directly in the source as you can see. Now the only thing missing is the website to check if there is money in the player's database, because after that the lottery itself will do the rest ...

htc16 commented 3 years ago

In order to complement: https://github.com/TwistedScorpio/Nostalrius/issues/47#issuecomment-492703575

Znote commented 3 years ago

Aha, well you can try to replace $yourChars = mysql_select_multi ... with this:

$yourChars = mysql_select_multi("
    SELECT 
        `p`.`id`, 
        `p`.`name`,
        (
            SELECT 
                SUM(CASE 
                    WHEN `d`.`itemtype` = 3043 THEN (`d`.`count` * 10000)
                    WHEN `d`.`itemtype` = 3035 THEN (`d`.`count` * 100)
                    ELSE `d`.`count`
                END)
            FROM `player_depotitems` AS `d`
            WHERE 
                `d`.`player_id`=`p`.`id`
                AND `d`.`itemtype` IN (3031, 3035, 3043)
        ) AS `balance`
    FROM `players` AS `p`
    WHERE 
        `p`.`account_id`='{$user_data['id']}';
");
htc16 commented 3 years ago

Did not find the item, it looks like this: image

Znote commented 3 years ago

Thats weird, did the query work, just not the balance part? Does the character ADM Viper have money in the same depot id the house is connected to?

Are you using a custom version of Znote AAC to properly support Nostalrius? github URL?

htc16 commented 3 years ago

Znote, the query worked, but in the wrong way. She researched the money balance in players table, when the correct one was in the player_item table, right?

As for the version I'm using the correct one, I'm just stuck on it, I believe that this would solve the problem of other znote x nostalrius users ...

And thanks for your support!

htc16 commented 3 years ago

About the money, I left 100k in each city bank to be sure.

htc16 commented 3 years ago

@Znote any solution to help me?

Znote commented 3 years ago

@Heitortadeu I'm not sure what the solution is, but I'm fairly certain I could get this solved if I had a development environment I could connect into and code a bit freely. But currently, I'm to busy to set it up. What is your discord tag? You could try to reach me on Discord

htc16 commented 3 years ago

Ok @Znote I already sent the request, thanks!