-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathserver.lua
121 lines (114 loc) · 4.63 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
ESX = nil
QBcore = nil
local recPaid = {}
if Config.UseESX then
ESX = exports["es_extended"]:getSharedObject()
elseif Config.UseQBCore then
QBCore = exports['qb-core']:GetCoreObject()
end
AddEventHandler('onResourceStart', function(resource)
local partB = 'ngelicxs-CivilianJobs'
local name = tostring('a'..partB)
if GetCurrentResourceName() == resource and GetCurrentResourceName() ~= name then
print('Your civilian job script was brought to you by A'..'ngelicXS! However, the resource name has been changed. Thank you for using this resource and consider renaming it to help support scripts like it.')
end
end)
RegisterServerEvent('angelicxs-CivilianJobs:Server:Payment')
AddEventHandler('angelicxs-CivilianJobs:Server:Payment', function(amount)
local src = source
if recPaid[src] then
local license = 'Unknown'
for k, v in ipairs(GetPlayerIdentifiers(src)) do
if string.match(v, "license:") then
license = v
break
end
end
DropPlayer(src, Config.ErrorCodes['012'])
print("\n\n\n"..Config.ErrorCodes['012']..' '..Config.ErrorCodes['013']..' '..src..' '..license.."\n\n\n")
return
else
recPaid[src] = true
end
if Config.UseESX then
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addAccountMoney(Config.AccountMoney,amount)
elseif Config.UseQBCore then
local Player = QBCore.Functions.GetPlayer(source)
Player.Functions.AddMoney(Config.AccountMoney, amount)
end
TriggerClientEvent('angelicxs-CivilianJobs:Notify',src, Config.Lang['payment_notice_money']..amount, Config.LangType['success'])
Wait(1000)
recPaid[src] = false
end)
RegisterServerEvent('angelicxs-CivilianJobs:Server:GainItem')
AddEventHandler('angelicxs-CivilianJobs:Server:GainItem', function(name, amount)
local src = source
local exp = tostring(src..'item'..name)
if recPaid[exp] then
local license = 'Unknown'
for k, v in ipairs(GetPlayerIdentifiers(src)) do
print(k,v)
if string.match(v, "license:") then
license = v
break
end
end
DropPlayer(src, Config.ErrorCodes['012'])
print("\n\n\n"..Config.ErrorCodes['012']..' '..Config.ErrorCodes['013']..' '..src..' '..license.."\n\n\n")
return
else
recPaid[exp] = true
end
if Config.UseESX then
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.addInventoryItem(name, amount)
elseif Config.UseQBCore then
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.AddItem(name, amount)
end
TriggerClientEvent('angelicxs-CivilianJobs:Notify',src, Config.Lang['payment_notice_item']..' '..tostring(amount)..' '..tostring(name), Config.LangType['success'])
Wait(1000)
recPaid[exp] = false
end)
RegisterServerEvent('angelicxs-CivilianJobs:Server:GainItemMaterial')
AddEventHandler('angelicxs-CivilianJobs:Server:GainItemMaterial', function(name, amount)
local src = source
local exp = tostring(src..name..amount..math.random(10000,99999))
if recPaid[exp] then
local license = 'Unknown'
for k, v in ipairs(GetPlayerIdentifiers(src)) do
print(k,v)
if string.match(v, "license:") then
license = v
break
end
end
DropPlayer(src, Config.ErrorCodes['012'])
print("\n\n\n"..Config.ErrorCodes['012']..' '..Config.ErrorCodes['013']..' '..src..' '..license.."\n\n\n")
return
else
recPaid[exp] = true
end
if Config.UseESX then
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.addInventoryItem(name, amount)
elseif Config.UseQBCore then
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.AddItem(name, amount)
end
TriggerClientEvent('angelicxs-CivilianJobs:Notify',src, Config.Lang['payment_notice_item']..' '..tostring(amount)..' '..tostring(name), Config.LangType['success'])
Wait(1000)
recPaid[exp] = false
end)
if Config.UseESX then
ESX.RegisterUsableItem(Config.ScubaItemName, function(source)
local xPlayer = ESX.GetPlayerFromId(source)
TriggerClientEvent('angelicxs-CivilianJobs:ScubaJob:ScubaMode',source)
end)
elseif Config.UseQBCore then
QBCore.Functions.CreateUseableItem(Config.ScubaItemName, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
TriggerClientEvent('angelicxs-CivilianJobs:ScubaJob:ScubaMode', source)
end)
end