Check if you have enough money

This commit is contained in:
Djamuras
2020-05-28 21:54:46 +03:00
committed by GitHub
parent f3ca2d76e6
commit 99144215fc
+13 -8
View File
@@ -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)