-
Notifications
You must be signed in to change notification settings - Fork 9
/
server.lua
56 lines (49 loc) · 1.8 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local ESX = nil
if Config.Framework == "esx" then
ESX = exports["es_extended"]:getSharedObject()
end
local QBCore = nil
if Config.Framework == "qbcore" then
QBCore = exports['qb-core']:GetCoreObject()
end
local NDCore = nil
if Config.Framework == "ndcore" then
NDCore = exports["ND_Core"]:GetCoreObject()
end
RegisterServerEvent('hookers:moneyCheck')
AddEventHandler('hookers:moneyCheck', function(service)
local cost = Config.Prices[service]
local src = source
if Config.Framework == "esx" then
local xPlayer = ESX.GetPlayerFromId(src)
local cash = xPlayer.getMoney()
if cash >= cost then
xPlayer.removeMoney(cost)
TriggerClientEvent('hookser:paymentReturn', src, true)
else
TriggerClientEvent('hookser:paymentReturn', src, false)
end
elseif Config.Framework == "qbcore" then
local Player = QBCore.Functions.GetPlayer(src)
local cash = Player.Functions.GetMoney('cash')
if cash >= cost then
Player.Functions.RemoveMoney('cash', cost, "Hooker")
TriggerClientEvent('hookser:paymentReturn', src, true)
else
TriggerClientEvent('hookser:paymentReturn', src, false)
end
elseif Config.Framework == "ndcore" then
local character = NDCore.Functions.GetPlayer(src)
if character.cash >= cost then
NDCore.Functions.DeductMoney(cost, src, "cash", "Hooker")
TriggerClientEvent('hookser:paymentReturn', src, true)
else
TriggerClientEvent('hookser:paymentReturn', src, false)
end
elseif Config.Framework == "standalone" then
-- Your code here
TriggerClientEvent('hookser:paymentReturn', src, true)
else
TriggerClientEvent('hookser:paymentReturn', src, true)
end
end)