This repository has been archived on 2025-12-11. You can view files and clone it, but cannot push or open issues or pull requests.

32 lines
681 B
Lua
Raw Normal View History

2025-02-02 10:40:42 +01:00
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)
local cv = GetConvarInt('sv_maxclients', 32)
print('Connecting: ' .. name .. '^7')
if playerCount >= cv then
print('Full. :(')
setReason('This server is full (past ' .. tostring(cv) .. ' players).')
CancelEvent()
end
end)