Closed htc16 closed 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.
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 ...
In order to complement: https://github.com/TwistedScorpio/Nostalrius/issues/47#issuecomment-492703575
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']}';
");
Did not find the item, it looks like this:
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?
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!
About the money, I left 100k in each city bank to be sure.
@Znote any solution to help me?
@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
Ok @Znote I already sent the request, thanks!
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("SELECT
id,
name,
balanceFROM
playersWHERE
account_id='". $user_data['id'] ."';");
How would I go about looking for money in the player instead of the balance on balance?
Thank you!