-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
42 lines (35 loc) · 1.17 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
ESX.RegisterServerCallback("RAGE_SpectateMenu:GetPlayers", function(source, cb)
local onlinePlayers = {}
local xPlayers = ESX.GetExtendedPlayers()
for _, xPlayer in pairs(xPlayers) do
table.insert(onlinePlayers, {
id = xPlayer.source,
name = xPlayer.getName(),
group = xPlayer.getGroup(),
job = xPlayer.job.name
})
end
cb(onlinePlayers)
end)
ESX.RegisterServerCallback("RAGE_SpectateMenu:GetPlayerCoords", function(source, cb, serverId)
local xPlayer = ESX.GetPlayerFromId(source)
if not xPlayer then
return cb(false)
end
local targetPed = GetPlayerPed(serverId)
if targetPed <= 0 or not Config.AllowedGroups[xPlayer.getGroup()] then
return cb(false)
end
cb(GetEntityCoords(targetPed))
end)
RegisterCommand(Config.SpectateMenuCommand, function(player)
local xPlayer = ESX.GetPlayerFromId(player)
if not Config.AllowedGroups[xPlayer.getGroup()] then
return xPlayer.showNotification("You are not allowed to do this")
end
TriggerClientEvent("RAGE_SpectateMenu:OpenMenu", player)
end)
RegisterNetEvent('RAGE_SpectateMenu:KickPlayer')
AddEventHandler('RAGE_SpectateMenu:KickPlayer', function(player)
DropPlayer(player, Config.KickMessage)
end)