Help CancelEvent() don't work?

Sample from “hardcap”

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)

  if playerCount >= cv then
    print('Full. :(')

    setReason('This server is full (past ' .. tostring(cv) .. ' players).')
    CancelEvent()
  end
end)

when CancelEvent() is call it stop work then photo

Sorry for bad englist. if u don’t understan tell me.

i get this to but only when i join my local server

If join server through the internet is not a problem. I understand right?

edit: i will test this. it true. this have problem for local server only thx.

Calling CancelEvent() won’t just stop the event dead in it’s tracks, it will just say to the following items that the event was canceled, you would need to call in an if statement

if (WasEventCanceled()) then
  -- Do things in here
end

Reference

1 Like