Hello :raised_back_of_hand: .
As The Title Says Its My Tax System


Overview :medal_sports: :
This Script Will Add 3 Exports for other scripts to use :key:

  1. CalculateTax(money) : Calculate a Money With Current Tax Percentage ( for example if current tax percent is 10% and you use CalculateTax(100) it will return : 110

exports["cyber_Tax"]:CalculateTax(money)

  1. GetCurrentTaxPercent() : This Export Returns Current Tax Percentage

exports["cyber_Tax"]:GetCurrentTaxPercent()

  1. RemoveMoneyWithTax(money,id) : it will Remove the money From the player + tax included , and if you have esx_society it will add the tax money to the given society name in config.lua

exports["cyber_Tax"]:RemoveMoneyWithTax(money,targetID)

2 Commands For Use :arrow_double_down:

  1. ChangeTax : If player has the requirement ( for example goverment job and grade 5 configaruable ) he can change the Tax percentage with this command
  2. CurrentTax : Player can Check the current tax Percentage with this command

2 Events To Use :link: :

  • Cyber:RemoveMoneyWithTax(money) : basically Remove Money With Tax but instead of export with event ( For Usage in Client Side )
  • GetCurrentTaxPercent : Call backs Current Tax Percentage ( For usage in Client side )

Requirements :pencil2: :

  • ESX v1 final
  • ESX_Society (Optional. can be changed in config file)

How to Use :toolbox: :
Script It Self does nothing. You need to modify your scripts to use the Tax system. for example you need to change this ( taken from esx_carwash ) :arrow_double_down:

`ESX.RegisterServerCallback('esx_carwash:canAfford', function(source, cb)
	local xPlayer = ESX.GetPlayerFromId(source)

	if Config.EnablePrice then
		if xPlayer.getMoney() >= Config.Price then
			xPlayer.removeMoney(Config.Price)
			cb(true)
		else
			cb(false)
		end
	else
		cb(true)
	end
end)`

to use the Tax system Exports like this :arrow_double_down:

`ESX.RegisterServerCallback('esx_carwash:canAfford', function(source, cb)
   local xPlayer = ESX.GetPlayerFromId(source)

   if Config.EnablePrice then
   	if xPlayer.getMoney() >= exports['cyber_Tax']:CalculateTax(Config.Price) then
   		exports['cyber_Tax']:RemoveMoneyWithTax(Config.Price,source)
   		cb(true)
   	else
   		cb(false)
   	end
   else
   	cb(true)
   end
end)`

You can Change Any Scripts that you want to use the tax system.
For example:

  • Shops! :shopping_cart:
  • Vehicle Shop :oncoming_automobile:
  • Gun Shop :gun:
  • Housing Systems :house:

and …


Github Link :link: :

7 Likes

Welp this makes my life easier, don’t have to add like 30 lines for the society (To clarify: don’t need to add like 30 lines for each script that I’d need to add tax too, lol)

1 Like

Gang Reza🤫

hello sir can you make compatible backwards for esx 1.1 :slight_smile:

i don’t think there will be any problem using it with esx 1.1 | if you encountered any errors please provide me a screenshot so i can make another branch for esx 1.1

Hey,
i got this Error. What can i do? :confused:
SCRIPT ERROR: @esx_addonaccount/server/classes/addonaccount.lua:9: attempt to perform arithmetic on a nil value (local ‘m’)