Ejemplo n.º 1
0
        internal static void OnJoin(VerifiedEventArgs ev)
        {
            if (ev.Player?.UserId == null || ev.Player.IsHost || !ev.Player.IsVerified || ev.Player.IPAddress == "127.0.0.WAN" || ev.Player.IPAddress == "127.0.0.1")
            {
                return;
            }

            if (firstJoin)
            {
                firstJoin = false;
                Verification.UpdateID();
            }

            Timing.CallDelayed(.2f, () =>
            {
                StatHandler.SendRequest(RequestType.UserData, Helper.HandleId(ev.Player));
            });

            if (!Round.IsStarted && Players.Contains(ev.Player.RawUserId) || ev.Player.DoNotTrack)
            {
                return;
            }

            StatHandler.SendRequest(RequestType.Join, "{\"playerid\": \"" + Helper.HandleId(ev.Player) + "\"}");

            Players.Add(ev.Player.RawUserId);
        }
Ejemplo n.º 2
0
        internal static void OnLeave(DestroyingEventArgs ev)
        {
            if (ev.Player?.UserId == null || ev.Player.IsHost || !ev.Player.IsVerified || ev.Player.IPAddress == "127.0.0.WAN" || ev.Player.IPAddress == "127.0.0.1")
            {
                return;
            }

            if (ev.Player.GameObject.TryGetComponent <HatPlayerComponent>(out var playerComponent) && playerComponent.item != null)
            {
                Object.Destroy(playerComponent.item.gameObject);
                playerComponent.item = null;
            }

            if (Restarting || ev.Player.DoNotTrack)
            {
                return;
            }

            StatHandler.SendRequest(RequestType.Leave, "{\"playerid\": \"" + Helper.HandleId(ev.Player) + "\"}");

            if (Players.Contains(ev.Player.RawUserId))
            {
                Players.Remove(ev.Player.RawUserId);
            }
        }
Ejemplo n.º 3
0
        internal static void OnRoleChanged(ChangingRoleEventArgs ev)
        {
            if (ev.Player?.UserId == null || ev.Player.IsHost || !ev.Player.IsVerified || ev.Player.IPAddress == "127.0.0.WAN" || ev.Player.IPAddress == "127.0.0.1")
            {
                return;
            }

            if (ev.NewRole != RoleType.None && ev.NewRole != RoleType.Spectator)
            {
                Timing.CallDelayed(.5f, () => ev.Player.SpawnCurrentHat());
            }

            if (PauseRound || Round.ElapsedTime.Seconds < 5 || !RoundSummary.RoundInProgress() || !Helper.IsPlayerValid(ev.Player, true, false))
            {
                return;
            }

            if (ev.IsEscaped)
            {
                StatHandler.SendRequest(RequestType.Escape, "{\"playerid\": \"" + Helper.HandleId(ev.Player) + "\", \"role\": \"" + ((int)ev.Player.Role).ToString() + "\"}");
            }

            if (ev.NewRole == RoleType.None || ev.NewRole == RoleType.Spectator)
            {
                return;
            }

            StatHandler.SendRequest(RequestType.Spawn, "{\"playerid\": \"" + Helper.HandleId(ev.Player) + "\", \"spawnrole\": \"" + ((int)ev.NewRole).ToString() + "\"}");
        }
Ejemplo n.º 4
0
        internal static void OnKill(DyingEventArgs ev)
        {
            if (ev.Target?.UserId == null || ev.Target.IsHost || !ev.Target.IsVerified || PauseRound || !ev.IsAllowed || !Helper.IsPlayerValid(ev.Target, false) || !RoundSummary.RoundInProgress())
            {
                return;
            }

            if (!ev.Target.DoNotTrack && ev.Target.IPAddress != "127.0.0.WAN" && ev.Target.IPAddress != "127.0.0.1")
            {
                StatHandler.SendRequest(RequestType.Death, "{\"playerid\": \"" + Helper.HandleId(ev.Target) + "\", \"killerrole\": \"" + (ev.Killer == null ? ((int)ev.Target.Role).ToString() : ((int)ev.Killer.Role).ToString()) + "\", \"playerrole\": \"" + ((int)ev.Target.Role).ToString() + "\", \"damagetype\": \"" + DamageTypes.ToIndex(ev.HitInformation.GetDamageType()).ToString() + "\"}");
            }

            if (ev.HitInformation.GetDamageType() == DamageTypes.Pocket && PocketPlayers.TryGetValue(Helper.HandleId(ev.Target), out var killer))
            {
                StatHandler.SendRequest(RequestType.Kill, "{\"playerid\": \"" + killer + "\", \"targetrole\": \"" + ((int)ev.Target.Role).ToString() + "\", \"playerrole\": \"" + ((int)RoleType.Scp106).ToString() + "\", \"damagetype\": \"" + DamageTypes.ToIndex(ev.HitInformation.GetDamageType()).ToString() + "\"}");
                return;
            }

            if (ev.Killer?.UserId == null || ev.Killer.IsHost || !ev.Killer.IsVerified || ev.Killer.IPAddress == "127.0.0.WAN" || ev.Killer.IPAddress == "127.0.0.1" || ev.Killer.RawUserId == ev.Target.RawUserId || ev.Killer.DoNotTrack || !Helper.IsPlayerValid(ev.Killer, false))
            {
                return;
            }

            StatHandler.SendRequest(RequestType.Kill, "{\"playerid\": \"" + Helper.HandleId(ev.Killer) + "\", \"targetrole\": \"" + ((int)ev.Target.Role).ToString() + "\", \"playerrole\": \"" + ((int)ev.Killer.Role).ToString() + "\", \"damagetype\": \"" + DamageTypes.ToIndex(ev.HitInformation.GetDamageType()).ToString() + "\"}");
        }
Ejemplo n.º 5
0
        private static IEnumerator <float> SendStart()
        {
            yield return(Timing.WaitForSeconds(.2f));

            foreach (var player in Player.List)
            {
                if (player?.UserId == null || !player.IsVerified || player.IsHost || player.IPAddress == "127.0.0.WAN" || player.IPAddress == "127.0.0.1")
                {
                    continue;
                }

                StatHandler.SendRequest(RequestType.UserData, Helper.HandleId(player));

                yield return(Timing.WaitForSeconds(.05f));

                if (!player.DoNotTrack && player.Role != RoleType.None && player.Role != RoleType.Spectator)
                {
                    StatHandler.SendRequest(RequestType.Spawn, "{\"playerid\": \"" + Helper.HandleId(player) + "\", \"spawnrole\": \"" + ((int)player.Role).ToString() + "\"}");
                }
                else
                {
                    continue;
                }

                yield return(Timing.WaitForSeconds(.05f));
            }
        }
Ejemplo n.º 6
0
        internal static void OnThrow(ThrowingGrenadeEventArgs ev)
        {
            if (ev.Player?.UserId == null || ev.Player.IsHost || !ev.Player.IsVerified || ev.Player.IPAddress == "127.0.0.WAN" || ev.Player.IPAddress == "127.0.0.1" || PauseRound || !Helper.IsPlayerValid(ev.Player) || !RoundSummary.RoundInProgress() || !ev.IsAllowed)
            {
                return;
            }

            StatHandler.SendRequest(RequestType.Use, "{\"playerid\": \"" + Helper.HandleId(ev.Player) + "\", \"itemid\": \"" + ((int)ev.GrenadeManager.availableGrenades[(int)ev.Type].inventoryID).ToString() + "\"}");
        }
Ejemplo n.º 7
0
        internal static void OnUse(UsedMedicalItemEventArgs ev)
        {
            if (ev.Player?.UserId == null || ev.Player.IsHost || !ev.Player.IsVerified || ev.Player.IPAddress == "127.0.0.WAN" || ev.Player.IPAddress == "127.0.0.1" || PauseRound || !Helper.IsPlayerValid(ev.Player) || !RoundSummary.RoundInProgress())
            {
                return;
            }

            StatHandler.SendRequest(RequestType.Use, "{\"playerid\": \"" + Helper.HandleId(ev.Player) + "\", \"itemid\": \"" + ((int)ev.Item).ToString() + "\"}");
        }
Ejemplo n.º 8
0
        private static IEnumerator <float> RAReloaded()
        {
            yield return(Timing.WaitForSeconds(1.5f));

            var ids = (from player in Player.List where player?.UserId != null && player.IsVerified && !player.IsHost && player.IPAddress != "127.0.0.WAN" && player.IPAddress != "127.0.0.1" select Helper.HandleId(player)).ToList();

            foreach (var id in ids)
            {
                StatHandler.SendRequest(RequestType.UserData, id);

                yield return(Timing.WaitForSeconds(.1f));
            }
        }
Ejemplo n.º 9
0
        internal static void OnRoundStart()
        {
            Restarting  = false;
            DidRoundEnd = false;

            if (IsGamemodeRunning())
            {
                PauseRound = true;
            }

            StatHandler.SendRequest(RequestType.RoundStart);

            Timing.RunCoroutine(SendStart());
        }
Ejemplo n.º 10
0
        internal static void OnRoundRestart()
        {
            Restarting = true;
            HatCommand.HatPlayers.Clear();
            if (DidRoundEnd)
            {
                return;
            }

            StatHandler.SendRequest(RequestType.RoundEnd);

            Timing.KillCoroutines(coroutines.ToArray());
            coroutines.Clear();

            SpawnsDone.Clear();
        }
Ejemplo n.º 11
0
        private static IEnumerator <float> ClearPlayers()
        {
            yield return(Timing.WaitForSeconds(30f));

            for (var i = 0; i < Players.Count; i++)
            {
                var player = Players[i];
                if (Player.List.Any(p => p != null && !p.IsHost && p.RawUserId == player))
                {
                    continue;
                }

                StatHandler.SendRequest(RequestType.Leave, "{\"playerid\": \"" + Helper.HandleId(player) + "\"}");

                Players.Remove(player);
            }
        }
Ejemplo n.º 12
0
        internal static void OnRoundEnding(EndingRoundEventArgs ev)
        {
            if (!ev.IsAllowed || !ev.IsRoundEnded)
            {
                return;
            }

            DidRoundEnd = true;

            HatCommand.HatPlayers.Clear();

            StatHandler.SendRequest(RequestType.RoundEnd);

            Timing.KillCoroutines(coroutines.ToArray());
            coroutines.Clear();

            SpawnsDone.Clear();
        }
Ejemplo n.º 13
0
        internal static void OnPickup(PickingUpItemEventArgs ev)
        {
            if (!ev.Pickup || !ev.Pickup.gameObject)
            {
                return;
            }

            if (ev.Pickup.gameObject.TryGetComponent <HatItemComponent>(out _))
            {
                ev.IsAllowed = false;
                return;
            }

            if (ev.Player?.UserId == null || ev.Player.IsHost || !ev.Player.IsVerified || ev.Player.IPAddress == "127.0.0.WAN" || ev.Player.IPAddress == "127.0.0.1" || PauseRound || !Helper.IsPlayerValid(ev.Player) || !RoundSummary.RoundInProgress() || !ev.IsAllowed)
            {
                return;
            }

            StatHandler.SendRequest(RequestType.Pickup, "{\"playerid\": \"" + Helper.HandleId(ev.Player) + "\", \"itemid\": \"" + ((int)ev.Pickup.itemId).ToString() + "\"}");
        }