Citizen Debit Card System
A Citizen Debit Card System For ESX
Installation
- Place the resource files in your server’s resources folder!
- Add the required item ‘Debit Card’ to item database using provided .sql code!
- If Using a GUI Inventory HUD make sure to add the provided image into that script!
- Place ‘ensure OSheaDebitCard’ in server.cfg!
- Use the following code snippet to enable this to work on your in-game store/shop!
This can be added into any script that is currently using the cash system. First find the line of code handling the cash transaction: Then edit it by inserting another menu item to pop up a
debit or credit button option. Such as the one provided below: This is the Client.lua Menu add-on;
–Client Code:
ESX.UI.Menu.Open(‘default’, GetCurrentResourceName(), ‘debit_cash_payment’, {
title = ‘Select Payment Option’,
align = ‘top-left’,
elements = {
{label = ‘Debit’, value = ‘debit_card’},
{label = ‘Cash’, value = ‘cash’},
}
}, function(data4, menu4)
if data4.current.value == ‘debit_card’ then
ESX.TriggerServerCallback(‘esx_shop:payDebit’, function(bought)
if bought then
ESX.ShowNotification(“You have purchased a ITEM_NAME_HERE using debit!”)
menu4.close()
Citizen.Wait(160)
end
end)
menu4.close()
elseif data4.current.value == ‘cash’ then
ESX.TriggerServerCallback(‘esx_shop:payCash’, function(bought)
if bought then
ESX.ShowNotification(“You have purchased a ITEM_NAME_HERE using cash!”)
menu4.close()
Citizen.Wait(160)
end
end)
menu4.close()
end
menu4.close()
end, function(data4, menu4)
menu4.close()
end)
–end debit or cash
-----This is the server code for debit menu lua add on.----------
Add this code into your server to read the input from the client and give the player the item requested while checking to see if he has a debit card then removing the money from his bank account.
–Server Code
ESX.RegisterServerCallback(‘esx_shop:payDebit’, function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.getInventoryItem(“debitcard”).count > 0 then
if xPlayer.getAccount(‘bank’).money >= ITEM_PRICE then
xPlayer.removeAccountMoney(‘bank’, ITEM_PRICE)
TriggerEvent(‘esx_shop:addItem’, source, ‘ITEM_NAME’, function()
cb(true)
end)
else
TriggerClientEvent(‘esx:showNotification’, source, ‘Not Enough Money In Account’)
cb(false)
end
else
TriggerClientEvent(‘esx:showNotification’, source, ‘No Debit Card’)
end
end)
Special Script Features
- Custom made script allows players to utilize a debit card item
- Can insert this into any shop to enable players to use Debit or Cash
- Can make only certain shops accept debit (Non-Illegal or whatever you prefer!)
- ESX only, uses a Debit Card item, Image provided if using a GUI based Inventory HUD
- Minimizes player cash on hand, making it safer to walk around town or make large purchases!
- Can add blips to display on map where cards can be purchased (Coded in but commented out)
- Easy to install and use!
Script Usage
Insert into any shop you would like to have utilize a debit/cash menu.
Player buys Debit Cards from bank, bank gives them a Debit Card Item (Not personally linked).
Player can then use Debit at any store that accepts debit. (Easily Scripted In by your Devs)
This script REQUIRES that you have some basic coding knowledge I will not help with setup or install.
You can download this script from here. Click Me!