mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 23:01:48 +00:00
Check if you have enough money
This commit is contained in:
+13
-8
@@ -2,6 +2,19 @@ ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_dmvschool:canYouPay', function(source, cb, type)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if xPlayer.getMoney() >= Config.Prices[type] then
|
||||
xPlayer.removeMoney(Config.Prices[type])
|
||||
TriggerClientEvent('esx:showNotification', source, _U('you_paid', Config.Prices[type]))
|
||||
cb(true)
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
AddEventHandler('esx:playerLoaded', function(source)
|
||||
TriggerEvent('esx_license:getLicenses', source, function(licenses)
|
||||
TriggerClientEvent('esx_dmvschool:loadLicenses', source, licenses)
|
||||
@@ -19,11 +32,3 @@ AddEventHandler('esx_dmvschool:addLicense', function(type)
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_dmvschool:pay')
|
||||
AddEventHandler('esx_dmvschool:pay', function(price)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
|
||||
xPlayer.removeMoney(price)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_paid', ESX.Math.GroupDigits(price)))
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user