[ESX] RP Car dealership financing

esx_finance - RP Car dealership financing

This modification will make it so any outstanding bill from society_cardealer will be paid at a % based on the original billing amount once per IRL day.

example: config is set to 10% - Billed someone for 100k as a cardealer - Person will pay $10k every IRL day for 10 days automatically

You can easily modify this script to add multiple businesses that giveout loans besides cardealers

Photos

What am i supposed to take a photo of? :upside_down_face:


Installation

  1. Clone esx_finance here
  2. Extract the zip.
  3. Change esx_finance-master to esx_finance
  4. Put esx_finance to your resource folder.
  5. Add ā€œstart esx_financeā€ in your ā€œserver.cfgā€.

Setting up esx_billing for Financing (REQUIRED)

  1. Go into esx_billing / server / main.lua
  2. find the following lines
if xTarget ~= nil then
	MySQL.Async.execute(
		'INSERT INTO billing (identifier, sender, target_type, target, label, amount) VALUES (@identifier, @sender, @target_type, @target, @label, @amount)',
		{
			['@identifier']  = xTarget.identifier,
			['@sender']      = xPlayer.identifier,
			['@target_type'] = 'society',
			['@target']      = sharedAccountName,
			['@label']       = label,
			['@amount']      = amount
		},
		function(rowsChanged)
			TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_invoice'))
		end
	)
end
  1. Replace with this (adding originial)
if xTarget ~= nil then
	MySQL.Async.execute(
		'INSERT INTO billing (identifier, sender, target_type, target, label, amount, original) VALUES (@identifier, @sender, @target_type, @target, @label, @amount, @original)',
		{
			['@identifier']  = xTarget.identifier,
			['@sender']      = xPlayer.identifier,
			['@target_type'] = 'society',
			['@target']      = sharedAccountName,
			['@label']       = label,
			['@amount']      = amount,
			['@original']	 = amount
		},
		function(rowsChanged)
			TriggerClientEvent('esx:showNotification', xTarget.source, _U('received_invoice'))
		end
	)
end
  1. Last add ā€œoriginalā€ to your billing table
ALTER TABLE `billing` ADD `original` INT(11) NOT NULL ;
  1. Profit

Required resource

  • esx_billing
  • es_extended
  • Async
  • Cron

Made by

  • CryptoGenics
  • Based off esx_property rent cron job
21 Likes

The concept sounds cool, will download and check it out for sure.

Question. If you implement this with the dealership job, will it start automatically taking money after the first day, or?? How exactly does that work?

For example, I make a payment to the dealership 3 times for 10k each, my remaining bill is 70k, Will i get automatically deducted each day i paid also, or just the days following?

Issue is, if people can finance these cars thereā€™s no incentive to save up. They have their goals achieved immediately. Definitely going to lead to people getting bored.

2 Likes

Yes if you get billed 100k and donā€™t pay it (just leaving it outstanding in f7) and config is set to 10%, Everytime the time hits the time you have set IRL it will remove 10k from you. Tomorrow your f7 will show 90k balance but will still only remove 10k today as well. Next day will show 80kā€¦ Person can pay in f7 early and will no longer be billed.

Yes this was made for my servers where financing doesnā€™t happen often. More for leases than sales.

Or large down payments

SQL file to add it to the database.
sql.sql (55 Bytes)

2 Likes

What happens if the persons account is at zero? Does it put them negative? If not how do you know if they made their payment? Iā€™m just asking because Iā€™m looking at using this but also thinking of opportunities for tow guys to do repos

1 Like

It will delete the bill from the table the next day after it was paid to 0.

So on the last day the balance will be paid not putting the bill to -. The balance will sit at 0 for 24 hours and be deleted on the next cycle that checks for balance being greater than 0 to run payments and if not delete from the table. Customer would see $0 balance in F7 they could click pay in the 24 hours to do the same thing.

Iā€™m meaning they are broke and still owe car payments.

Would they be able to make a partial payment manually to disrupt the finance script from taking money? For exampleā€¦

If player paid manually ā€œ10kā€ finance script delays until the following day

1 Like

No it will not put customers bank account in the negative. If the payment is suppose to be 10k and the player only have 9k in bank account the payment will no go though.

1 Like

No the way esx_billing is built only has pay option in F7 no partial payments

Could potentially look into how realestate does their scripts to put accounts into negatives, as it seems counter productive to not withdraw funds if the funds arent in the account. Folks just wonā€™t keep money on them.

You can easily remove the check for 0 out of the script, I wrote it not going negative on purpose. If I get some time Iā€™ll even add a config for allowing customer account to go negative.

I have added in the config ā€œConfig.Negitiveā€ where you can allow bank accounts to go negative to pay loans.

The menuā€™s?

there are no menus this just runs a payment every 24 hours.

1 Like

Okay thanks.