0.0.1
This commit is contained in:
11
resources/[cfx-default]/[system]/hardcap/client.lua
Normal file
11
resources/[cfx-default]/[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)
|
||||
14
resources/[cfx-default]/[system]/hardcap/fxmanifest.lua
Normal file
14
resources/[cfx-default]/[system]/hardcap/fxmanifest.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Limits the number of players to the amount set by sv_maxclients in your server.cfg.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
games { 'gta5', 'rdr3' }
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
31
resources/[cfx-default]/[system]/hardcap/server.lua
Normal file
31
resources/[cfx-default]/[system]/hardcap/server.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user