jacobwi / new_banking

Banking system compatibile with ESX framework
GNU Lesser General Public License v3.0
9 stars 11 forks source link

transfer issue fix #10

Open kevinalex opened 5 years ago

kevinalex commented 5 years ago
RegisterServerEvent('bank:transfer')
AddEventHandler('bank:transfer', function(to, amountt)
    local _source = source
    local sourceXPlayer = ESX.GetPlayerFromId(_source)
    local targetXPlayer = ESX.GetPlayerFromId(tonumber(to))
    local balance = sourceXPlayer.getAccount('bank').money

    if _source == tonumber(to) then
                -- advanced notification with bank icon
        TriggerClientEvent('esx:showAdvancedNotification', _source, 'Bank', 'Transfer Money', 'No puedes transferirte a ti mismo!', 'CHAR_BANK_MAZE', 9)
    else
        if balance < 1 or balance < tonumber(amountt) or tonumber(amountt) < 1 then
                        -- advanced notification with bank icon
            TriggerClientEvent('esx:showAdvancedNotification', _source, 'Bank', 'Transfer Money', 'No tienes suficiente para transferir!', 'CHAR_BANK_MAZE', 9)
        else
            sourceXPlayer.removeAccountMoney('bank', tonumber(amountt))
            targetXPlayer.addAccountMoney('bank', tonumber(amountt))
                        -- advanced notification with bank icon
                TriggerClientEvent('esx:showAdvancedNotification', _source, 'Bank', 'Transfer Money', 'Has transferido ~r~$' .. amountt .. '~s~ a ~r~' .. to .. ' .', 'CHAR_BANK_MAZE', 9)
                TriggerClientEvent('esx:showAdvancedNotification', to, 'Bank', 'Transfer Money', 'Has recibido ~r~$' .. amountt .. '~s~ de ~r~' .. _source .. ' .', 'CHAR_BANK_MAZE', 9)
        end
    end
end)

(added missing tonumber to some strings)

iSentrie commented 5 years ago

ty