mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
initial
This commit is contained in:
2
resources/[system]/hardcap/__resource.lua
Normal file
2
resources/[system]/hardcap/__resource.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
11
resources/[system]/hardcap/client.lua
Normal file
11
resources/[system]/hardcap/client.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
if NetworkIsSessionStarted() then
|
||||
TriggerServerEvent('hardcap:playerActivated')
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
29
resources/[system]/hardcap/server.lua
Normal file
29
resources/[system]/hardcap/server.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
local playerCount = 0
|
||||
local list = {}
|
||||
|
||||
RegisterServerEvent('hardcap:playerActivated')
|
||||
|
||||
AddEventHandler('hardcap:playerActivated', function()
|
||||
if not list[source] then
|
||||
playerCount = playerCount + 1
|
||||
list[source] = true
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
if list[source] then
|
||||
playerCount = playerCount - 1
|
||||
list[source] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerConnecting', function(name, setReason)
|
||||
print('Connecting: ' .. name)
|
||||
|
||||
if playerCount >= 24 then
|
||||
print('Full. :(')
|
||||
|
||||
setReason('This server is full (past 24 players).')
|
||||
CancelEvent()
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user