コード例 #1
0
        internal void PlayerConnecting([FromSource] Player source, string playerName, CallbackDelegate DenyWithReason)
        {
            try
            {
                Debug.WriteLine($"Connecting: '{source.Name}' (steam: {source.Identifiers.Where(i => i.Contains("steam")).FirstOrDefault().ToString()} ip: {source.Identifiers.Where(i => i.Contains("ip")).FirstOrDefault().ToString()}) | Player count {activePlayers.Count}/{maxClients}");

                if (activePlayers.Count >= maxClients)
                {
                    DenyWithReason?.Invoke($"The server is full with {playerCount}/{maxClients} players on.");
                    NativeWrappers.CancelEvent();
                }
                BaseScript.TriggerClientEvent("playerConnecting", source.Handle, playerName);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"HardCap PlayerConnecting Error: {ex.Message}");
            }
        }