forked from westre/Foundation
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient_whitelist.lua
More file actions
39 lines (33 loc) · 906 Bytes
/
client_whitelist.lua
File metadata and controls
39 lines (33 loc) · 906 Bytes
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
local isWhitelisted = false;
AddEventHandler('onPlayerJoining', function(playerId, name)
TriggerServerEvent('foundation:onPlayerConnect')
end)
RegisterNetEvent('foundation:playerWhitelisted')
AddEventHandler('foundation:playerWhitelisted', function(whitelisted)
isWhitelisted = whitelisted
if not isWhitelisted then
SendNUIMessage({
command = 'blockPlayer'
})
else
sendMessage('You are whitelisted, welcome!')
end
end)
function sendMessage(message)
TriggerEvent('chatMessage', '', { 0, 0, 0 }, message)
end
Citizen.CreateThread(function()
while true do
Wait(50)
if NetworkIsPlayerActive(PlayerId()) then
if not isWhitelisted then
local ped = GetPlayerPed(PlayerId())
if IsEntityVisible(ped) then
SetEntityVisible(ped, false)
end
SetPlayerInvincible(PlayerId(), true)
SetPlayerControl(PlayerId(), false, false)
end
end
end
end)