Elipse458 / el_business

Business system for FiveM (ESX)
Do What The F*ck You Want To Public License
55 stars 28 forks source link

ER_BAD_FIELD_ERROR New ESX #10

Open RuisSoftware opened 4 years ago

RuisSoftware commented 4 years ago

Can someone update this line to new ESX?

MySQL.Sync.execute('UPDATE users SET bank = bank + @bank WHERE identifier = @identifier',{['@bank'] = money, ['@identifier'] = identifier})

bank is not a bank column anymore. It's merged with money, black_money in the same column called accounts.

Elipse458 commented 4 years ago

not gonna be supporting new esx versions anytime soon, sorry

RuisSoftware commented 4 years ago

:(

RuisSoftware commented 4 years ago

Maybe someone else?

Can't you open it for a bit longer time ?

christerjohansson commented 4 years ago

Is the script working otherwise? Is it just the database query that is the problem? If it is, it should be possible to concatenate the result into a json-encoded result in that exact field (accounts). Check how the othe esx_banking scripts are doing the transaction, and do the same with this script. :) Something like this? xPlayer.addAccountMoney('bank', tonumber(amount))

Ref: ESX-Banking

EDIT: It is es_extended that works with MySQL and database queries (Ref. https://github.com/ESX-Org/es_extended/blob/master/server/main.lua)

xqth commented 4 years ago

MySQL.Async.fetchAll("SELECT accounts FROM users WHERE identifier = @identifier", {
    ["@identifier"] = identifier
}, function(result)
    if result[1].accounts and result[1].accounts ~= "" then
        local accounts = json.decode(result[1].accounts)
        accounts.bank = accounts.bank + money
        MySQL.Sync.execute("UPDATE users SET accounts = @accounts WHERE identifier = @identifier", {
            ["@accounts"] = json.encode(accounts),
            ["@identifier"] = identifier
        })
    end
end)