So I need some assistance with how to make it so players have to have the money on them, in inventory, in order to take any of the driving tests. I don’t want the bank to be usable nor do I want the player to be able to go into debt. I can’t find this posted anywhere (here or in general).

Any assistance would be greatly appreciated. Thank you.

You can easily add a check in here, to check if the player has enough money

Make sure you also not start it on the client if the person doesn’t have enough money

Here an example what I did

ESX.RegisterServerCallback('esx_dmvschool:pay', function(source, cb, price)
	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)

	if xPlayer.get('money') >= price then
		xPlayer.removeMoney(price)
		TriggerClientEvent('esx:showNotification', _source, _U('you_paid', ESX.Math.GroupDigits(price)))
		cb(true)
	else
		TriggerClientEvent('esx:showNotification', _source, _U('not_enough'))
		cb(false)
	end
end)

Than trigger that callback on the client and if the callback returns false you cancel the start of the driving exam

1 Like

I understand the concept here however I’m brand new to lua coding. Any chance you can show me how to do the client side portion? And yes I fully intend to learn from what your showing me in future adaptions.

In the function StartDriveTest()

I’m trigering the callback like

ESX.TriggerServerCallback('esx_dmvschool:pay', function(enough)
    if not enough then
        -- dont continue if not enough money
        return
    end

    -- paste here the ESX.Game.SpawnVehicle( etc code

end, Config.Prices[type])

So basically after the serverside code which we made earlier returns false we don’t continue so the drivers lesson doesn’t start


I’m getting an error message because the function is not closed. I’ve tried everything I can think of.

You need to close the function from SpawnVehicle

So after taskwarppedintovehicle

end)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.