itsamayo / esx_tax

GTAV FiveM mod for tax
15 stars 23 forks source link

Not working with ESX 1.2 #2

Open RuisSoftware opened 4 years ago

RuisSoftware commented 4 years ago

Any idea how to fix this error?

SCRIPT ERROR: @esx_tax/server/main.lua:17: attempt to compare nil with number
> BankTax (@esx_tax/server/main.lua:17)
> RunTax (@esx_tax/server/main.lua:76)
> ref (@esx_tax/server/main.lua:8)
>  (@mysql-async/mysql-async.js:14959)

AllUser[i].bank is giving nil

christerjohansson commented 4 years ago

It works fine with ESX 1.2. I installed it, and it does calculate the right tax for vehicles. But the banking requires a re-write. As of now, the script selects the 'users' table, and the column 'bank', but essx 1.2 uses a column called 'accounts' where it concatenates all accounts into one column and stores it as JSON.

{"money":89567234,"bank":15623245,"black_money":562000000}

So, one need to parse this before calculating the tax. The function BankTax takes all values stored in JSON format...it takes all users 'bank' column value...ie. you current amount in the bank. Now, we could maybe parse this from the accounts column instead and feed them all into an array of sorts...since that 'Alluser' seem to have the users id.

Or maybe select all from accounts instead, and parse out the value before setting it to the tax-variable.

I'll see if I have the time to get it working, or wait for the author to fix it.

RuisSoftware commented 4 years ago

I cannot fix it ymself. Can you fix it?

Zerofour04 commented 4 years ago

Hey, I got this problem:

SCRIPT ERROR: @esx_tax/server/main.lua:17: attempt to compare nil with number
> async void MySQLAsync.Operation<System.Collections.Generic.List<System.Collections.Generic.Dictionary<string, object>>>+<ExecuteAsync>d__7.MoveNext() (@mysql-async/MySQLAsync.net.dll:0)
> async Task<List<Dictionary<string, object>>> MySQLAsync.FetchAll.ReaderAsync(MySqlCommand command) (@mysql-async/MySQLAsync.net.dll:0)
> async Task<bool> MySqlConnector.Core.ResultSet.ReadAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) (@mysql-async/MySqlConnector.dll:0)
> async ValueTask<Row> MySqlConnector.Core.ResultSet.ScanRowAsync(IOBehavior ioBehavior, Row row, CancellationToken cancellationToken)+ScanRowAsyncAwaited(?) (@mysql-async/MySqlConnector.dll:0)
BrutalBirdie commented 4 years ago

@dutchplayers common you guys I know you can do it :D But here is the fix:

https://github.com/NebelBankNet/esx_tax/blob/master/server/main.lua#L13-L51

Creating a PR for this

Zerofour04 commented 4 years ago

Thank you very much. 👍