-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.lua
40 lines (34 loc) · 1.03 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
QBCore = nil
local QBCore = exports['qb-core']:GetCoreObject()
QBCore.Functions.CreateCallback('knb:mechOnline', function(source, cb)
local src = source
local Ply = QBCore.Functions.GetPlayer(src)
local xPlayers = QBCore.Functions.GetPlayers()
local mechanic = 0
local canpay = false
if Ply.PlayerData.money["cash"] >= Config.Price then
canpay = true
else
if Ply.PlayerData.money["bank"] >= Config.Price then
canpay = true
end
end
for i=1, #xPlayers, 1 do
local xPlayer = QBCore.Functions.GetPlayer(xPlayers[i])
if xPlayer.PlayerData.job.name == 'mechanic' then
mechanic = mechanic + 1
end
end
cb(mechanic, canpay)
end)
RegisterServerEvent('knb:charge')
AddEventHandler('knb:charge', function()
local src = source
local xPlayer = QBCore.Functions.GetPlayer(src)
if xPlayer.PlayerData.money["cash"] >= Config.Price then
xPlayer.Functions.RemoveMoney("cash", Config.Price)
else
xPlayer.Functions.RemoveMoney("bank", Config.Price)
end
TriggerEvent("qb-bossmenu:server:addAccountMoney", 'mechanic', Config.Price)
end)