forked from DaveYo1/k9
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
60 lines (56 loc) · 2.02 KB
/
server.lua
File metadata and controls
60 lines (56 loc) · 2.02 KB
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
RegisterServerEvent("K9:SendLanguage")
AddEventHandler("K9:SendLanguage", function()
local s = source
TriggerClientEvent("K9:UpdateLanguage", s, K9Config.Languages[K9Config.LanguageChoice])
end)
RegisterServerEvent("K9:RequestOpenMenu")
AddEventHandler("K9:RequestOpenMenu", function()
local src = source
if K9Config.OpenMenuIdentifierRestriction then
local foundIdentifier = false
for a = 1, #K9Config.LicenseIdentifiers do
if not foundIdentifier then
if GetPlayerId('license', src) == K9Config.LicenseIdentifiers[a] then
foundIdentifier = true
end
end
end
for b = 1, #K9Config.SteamIdentifiers do
if not foundIdentifier then
if GetPlayerId('steam', src) == K9Config.SteamIdentifiers[b] then
foundIdentifier = true
end
end
end
if foundIdentifier then
TriggerClientEvent("K9:OpenMenu", src, K9Config.OpenMenuPedRestriction, K9Config.PedsList)
return
else
TriggerClientEvent("K9:IdentifierRestricted", src)
end
else
TriggerClientEvent("K9:OpenMenu", src, K9Config.OpenMenuPedRestriction, K9Config.PedsList)
end
end)
RegisterServerEvent("K9:RequestVehicleToggle")
AddEventHandler("K9:RequestVehicleToggle", function()
local src = source
print("Requested Vehicle Toggle")
TriggerClientEvent("K9:ToggleVehicle", src, K9Config.VehicleRestriction, K9Config.VehiclesList)
end)
RegisterServerEvent("K9:RequestItems")
AddEventHandler("K9:RequestItems", function()
print("Requested Items")
local src = source
TriggerClientEvent("K9:SearchVehicle", src, K9Config.Items, K9Config.OpenDoorsOnSearch)
end)
--[[ Functions ]]--
function GetPlayerId(type, id)
local identifiers = GetPlayerIdentifiers(id)
for i = 1, #identifiers do
if string.find(identifiers[i], type, 1) ~= nil then
return identifiers[i]
end
end
return false
end