Esempio n. 1
0
        public static void RequestFinish()
        {
            isRunning = false;

            timer = 1800;

            foreach (ulong player in InGamePlayers)
            {
                player.GetPlayer().GunGamePlayer().ClearItems();
                player.GetPlayer().Teleport(GunGameConfig.instance.safezone.Vector3, GunGameConfig.instance.safezone.rot);
                player.GetPlayer().Heal(100);
            }

            IEnumerable <ulong> winners = from player in InGamePlayers
                                          orderby player.GetPlayer().GunGamePlayer().currentWeapon descending
                                          select player;

            if (InGamePlayers.Count != 0)
            {
                UnturnedPlayer first = winners.ElementAt(0).GetPlayer();

                if (GunGame.IsMySqlEnabled)
                {
                    first.GunGamePlayer().data.first++;
                }

                GunGame.Say("first", Color.cyan, first.DisplayName, first.GunGamePlayer().kills, first.GunGamePlayer().deaths);
            }

            if (InGamePlayers.Count > 1)
            {
                UnturnedPlayer second = winners.ElementAt(1).GetPlayer();

                if (GunGame.IsMySqlEnabled)
                {
                    second.GunGamePlayer().data.second++;
                }

                GunGame.Say("second", Color.cyan, second.DisplayName, second.GunGamePlayer().kills, second.GunGamePlayer().deaths);
            }

            if (InGamePlayers.Count > 2)
            {
                UnturnedPlayer third = winners.ElementAt(2).GetPlayer();

                if (GunGame.IsMySqlEnabled)
                {
                    third.GunGamePlayer().data.third++;
                }

                GunGame.Say("third", Color.cyan, third.DisplayName, third.GunGamePlayer().kills, third.GunGamePlayer().deaths);
            }

            for (int i = 0; i < InGamePlayers.Count; i++)
            {
                EconomyManager.IncreaseBalance(UnturnedPlayer.FromCSteamID(new Steamworks.CSteamID(winners.ElementAt(i))), (byte)i);
            }

            InGamePlayers.Clear();
        }
Esempio n. 2
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer p = (UnturnedPlayer)caller;

            GunGameConfig.RegisterSpawnPosition(p.Position, p.Rotation);
            GunGame.Say(caller, "register_spawn", Color.green);
        }
Esempio n. 3
0
 static void OnPlayerChatted(UnturnedPlayer player, ref Color color, string message, EChatMode mode, ref bool cancel)
 {
     if (mode == EChatMode.GLOBAL && !message.StartsWith("/", StringComparison.Ordinal) && GunGameConfig.instance.mutePlayers)
     {
         GunGame.Say(player, "mute", Color.red);
         cancel = true;
     }
 }
Esempio n. 4
0
        static void OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer)
        {
            bool isGun   = cause == EDeathCause.GUN;
            bool isMelee = cause == EDeathCause.MELEE;
            bool isPunch = cause == EDeathCause.PUNCH;

            if (isGun || isMelee || isPunch)
            {
                UnturnedPlayer m = UnturnedPlayer.FromCSteamID(murderer);
                if (GunGameConfig.instance.broadcastKills)
                {
                    string itemName;

                    if (isMelee)
                    {
                        itemName = ((ItemAsset)Assets.find(EAssetType.ITEM, GunGameConfig.instance.weapons.secondary)).itemName;
                    }
                    else if (isPunch)
                    {
                        itemName = "Fists";
                    }
                    else
                    {
                        itemName = ((ItemAsset)Assets.find(EAssetType.ITEM, GunGameConfig.instance.weapons.weapons[m.GunGamePlayer().currentWeapon].id)).itemName;
                    }

                    foreach (ulong id in GameManager.InGamePlayers)
                    {
                        if (id == player.CSteamID.m_SteamID)
                        {
                            GunGame.Say(id, "kill", Color.red, m.DisplayName, itemName, player.DisplayName);
                        }
                        else if (id == murderer.m_SteamID)
                        {
                            GunGame.Say(id, "kill", Color.green, m.DisplayName, itemName, player.DisplayName);
                        }
                        else
                        {
                            GunGame.Say(id, "kill", Color.magenta, m.DisplayName, itemName, player.DisplayName);
                        }
                    }
                }
                player.GunGamePlayer().DeathCallback(isMelee || isPunch);
                m.GunGamePlayer().KillCallback(isMelee || isPunch);
            }
            else
            {
                player.GunGamePlayer().ClearItems();
            }
        }
Esempio n. 5
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            if (args.Length != 1 || !byte.TryParse(args[0], out byte kit) || kit >= GunGameConfig.instance.weapons.weapons.Length)
            {
                throw new GunGameException(EExceptionType.INVALID_ARGS);
            }

            GunGamePlayerComponent p = ((UnturnedPlayer)caller).GunGamePlayer();

            p.ClearItems();
            p.GiveKit(kit);
            p.currentWeapon = kit;
            GunGame.Say(caller, "kit", Color.green, kit);
        }
Esempio n. 6
0
 public void Execute(IRocketPlayer caller, string[] command)
 {
     if (GameManager.isRunning)
     {
         GunGame.Say(caller, "inprogress", Color.green, GameManager.GetTime());
     }
     else if (GameManager.isStopped)
     {
         GunGame.Say(caller, "stopped", Color.green);
     }
     else if (Provider.clients.Count < GunGameConfig.instance.minPlayers)
     {
         GunGame.Say(caller, "notenoughplayers", Color.green, GunGameConfig.instance.minPlayers - Provider.clients.Count);
     }
     else
     {
         GunGame.Say(caller, "next", Color.green, GameManager.GetTime());
     }
 }
Esempio n. 7
0
 public static void Update()
 {
     if (isRunning)
     {
         if (timer <= 0)
         {
             RequestFinish();
         }
         else
         {
             timer--;
         }
     }
     else if (!isStopped)
     {
         if (Provider.clients.Count >= GunGameConfig.instance.minPlayers)
         {
             if (timer > 0)
             {
                 if (timer == 300)
                 {
                     GunGame.Say("next", Color.green, "5");
                 }
                 else if (timer == 1800)
                 {
                     GunGame.Say("next", Color.green, "30");
                 }
                 timer--;
             }
             else
             {
                 RequestBegin();
             }
         }
         else
         {
             timer = 1800;
         }
     }
 }
Esempio n. 8
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            if (args.Length != 1)
            {
                throw new GunGameException(EExceptionType.INVALID_ARGS);
            }

            if (CommandManager.TryGetCommand(args[0], out IGunGameCommand cmd))
            {
                if (caller.HasGGPermissionFor(cmd))
                {
                    GunGame.Say(caller, "help", Color.green, args[0], cmd.Help);
                }
                else
                {
                    GunGame.Say(caller, "invalid_perms_help", Color.red);
                }
            }
            else
            {
                GunGame.Say(caller, "invalid_cmd_help", Color.red);
            }
        }
Esempio n. 9
0
        public static void IncreaseBalance(IRocketPlayer p, byte place)
        {
            if (Enabled)
            {
                GunGameConfig.Reward          reward   = new GunGameConfig.Reward();
                GunGameConfig.EconomySettings settings = GunGameConfig.instance.econSettings;

                for (int i = 0; i < settings.rewards.Length; i++)
                {
                    if (settings.rewards[i].place == place)
                    {
                        reward = settings.rewards[place];
                        break;
                    }
                }

                if (reward.place != 0)
                {
                    ActiveHook.IncreaseBalance(p, reward.reward);
                    GunGame.Say(p, "reward", Color.green, reward.reward.ToString(), place.ToString() + reward.ordinal);
                }
            }
        }
Esempio n. 10
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            if (args.Length == 0)
            {
                throw new GunGameException(EExceptionType.INVALID_ARGS);
            }

            switch (args[0].ToLowerInvariant())
            {
            case "start":
                if (!GameManager.isStopped)
                {
                    GunGame.Say(caller, "invalid_start", Color.red);
                }
                else
                {
                    GameManager.isStopped = false;
                    GunGame.Say(caller, "start", Color.green);
                }
                break;

            case "stop":
                if (GameManager.isStopped)
                {
                    GunGame.Say(caller, "invalid_stop", Color.red);
                }
                else
                {
                    GameManager.isStopped = true;
                    GunGame.Say(caller, "stop", Color.green);
                }
                break;

            default: throw new GunGameException(EExceptionType.INVALID_ARGS);
            }
        }
Esempio n. 11
0
 public void Execute(IRocketPlayer caller, string[] args)
 {
     GameManager.isStopped = true;
     GameManager.RequestFinish();
     GunGame.Say(caller, "forcestop", Color.green);
 }
Esempio n. 12
0
 public void Execute(IRocketPlayer caller, string[] args)
 {
     GameManager.isStopped = false;
     GameManager.RequestBegin();
     GunGame.Say(caller, "forcestart", Color.green);
 }