Mythic_hospital billing problem

I am having trouble with this script I found here:
mythic_hospital

When the player is being treated, nothing happens and he stays in bed.
There is this error coming up in my server console:

SCRIPT ERROR: @mythic_hospital/server/hospital/hospital/events.lua:66: attempt to call a nil value (global 'BillPlayer')

The script is this:

RegisterServerEvent('mythic_hospital:server:EnteredBed')
AddEventHandler('mythic_hospital:server:EnteredBed', function()
    local src = source
    local totalBill = CalculateBill(GetCharsInjuries(src), Config.InjuryBase)

    
    if BillPlayer(src, totalBill) then
        TriggerClientEvent('mythic_notify:client:SendAlert', src, { text = 'You\'ve Been Treated & Billed', type = 'inform', style = { ['background-color'] = '#760036' }})
        TriggerClientEvent('mythic_hospital:client:FinishServices', src, false, true)
    else
        TriggerClientEvent('mythic_notify:client:SendAlert', src, { text = 'You were revived, but did not have the funds to cover further medical services', type = 'inform', style = { ['background-color'] = '#760036' }})
        TriggerClientEvent('mythic_hospital:client:FinishServices', src, false, false)
    end
end)

RegisterServerEvent('mythic_hospital:server:LeaveBed')
AddEventHandler('mythic_hospital:server:LeaveBed', function(id)
    beds[id].taken = false
end)

I am using esx_billing if it means anything.
I am sure I have to tweak something, but I am not sure what…

Where are you getting BillPlayer from?

From billing.lua of the linked script.

ESX             = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

function BillPlayer(source, amount)
    return true
    local xPlayer = ESX.GetPlayerFromId(source)
	xPlayer.removeBank(amount)
end

Hello ! i had the same problem ! :slight_smile: its just that this is an old code of line !

Change this: xPlayer.removeBank

To this: xPlayer.removeAccountMoney

It should be good to go :smiley:

1 Like

Hi GrumpyFox , Ive been facing this issue and trying to resolve the issue , i dont know what is the problem , if u are using mythic_hospital can u share me the file ?

1 Like

Here’s my file :slight_smile:
It works perfectly for me so try it out ! You’ll just have to re-translate some notifications to english since i translated mine to french ^_^’’ Also make sure you change the bed, registration coords if you’re not using the same hospital as me ! :slight_smile: but script wise all should be working

mythic_hospital.rar (25.6 KB)

1 Like

Oh , Thanks A Lot For Sending me the file.

Hey, It Worked Finally , Thanks A Lot :smiley:

1 Like

you’re very welcome ! :slight_smile:

Hello, I’m a little sweaty with this script.
I can’t use it, would you be able to help me?

PS: i’m french too :wink:

Allo :slight_smile:
C’est quoi le problème que tu as avec le script exactement?

Hello im using your Mythic hospital im getting treated but the money is not deducting from bank/inventory money

SOLVED*

what was your solution?

i keep getting this error

Error parsing script @mythic_hospital/server/billing.lua in resource mythic_hospital: @mythic_hospital/server/billing.lua:11: 'end' expected (to close 'function' at line 9) near 'local'

can you copy paste the section of the script that has an error for me please ? :slight_smile:

function BillPlayer(source, amount)
    return true
    local xPlayer = ESX.GetPlayerFromId(source)
	xPlayer.removeAccountMoney(amount)
end

there we are

Try it like that:

function BillPlayer(source, amount)
return true
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeAccountMoney(amount)
end
end