You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is currently impossible to safely conduct transactions between players. The most common way is to use the AddMoney and RemoveMoney functions, but this causes several problems.
Firstly, it is not possible to see where money comes from. Yes, you do have a reason parameter, but this is optional.
You can't use SQL transactions to safely update players' balance, as the mutations are running separately.
Ideal solution
Store player balances separately from the player table in a dedicated table with support for different bank account types. Also have a table for tracking transactions between accounts and other bank account mutations. Also, have a dedicated function for transferring money between different accounts.
Alternative solutions
Implement a money transfer method. This would not require a dedicated table, which would lead to big migration overhead for existing servers. This transfer method would be able to transfer money of both cash and bank balances to different users, or be able to convert cash to bank balances and vice versa.
Additional context
No response
The text was updated successfully, but these errors were encountered:
You can't use SQL transactions to safely update players' balance, as the mutations are running separately.
I'm confused by your wording here, since I'm not sure if you are speaking about SQL Transactions or just a transaction, the act of exchanging something, so I'll propose a implementation assuming you are speaking about a normal transaction.
Upon reading thru the oxmysql documentation, there is a method, called a transaction that only executes at the same time, and if a problem occurs a rollback occurs, so this would be the indicated method to use on said implementation of your idea.
In your quoted line I'm talking about SQL transactions (not monetary transactions).
I am ware of oxmysql's support for SQL transactions, but you cannot use those if you wish to use the native QB-Core events as these do not allow you to pass a SQL transaction. Fruthermore, events to update a player's balance may also be triggered from the client in which case you can't create an SQL transaction outright.
The problem
It is currently impossible to safely conduct transactions between players. The most common way is to use the
AddMoney
andRemoveMoney
functions, but this causes several problems.Firstly, it is not possible to see where money comes from. Yes, you do have a
reason
parameter, but this is optional.You can't use SQL transactions to safely update players' balance, as the mutations are running separately.
Ideal solution
Store player balances separately from the player table in a dedicated table with support for different bank account types. Also have a table for tracking transactions between accounts and other bank account mutations. Also, have a dedicated function for transferring money between different accounts.
Alternative solutions
Implement a money transfer method. This would not require a dedicated table, which would lead to big migration overhead for existing servers. This transfer method would be able to transfer money of both cash and bank balances to different users, or be able to convert cash to bank balances and vice versa.
Additional context
No response
The text was updated successfully, but these errors were encountered: