Example #1
0
        //Start paintball method
        public void startPaintball(IRocketPlayer caller)
        {
            if (PaintballManager.gameRunning)
            {
                UnturnedChat.Say(caller, "Paintball already has an active game running.", Color.red);
                return;
            }

            //Check if anyone hasn't respawned
            for (int x = 0; x < PaintballManager.joinedPlayers.Count(); x++)
            {
                if (PaintballManager.joinedPlayers[x].getRevived() == false)
                {
                    PaintballManager.joinedPlayers[x].getPlayer().Kick("AFK during paintball. Please rejoin.");
                }
            }

            if (PaintballManager.joinedPlayers.Count() == 1)
            {
                UnturnedChat.Say(caller, "Cannot start game, only one player is joined.", Color.red);
                PaintballManager.gameRunning = false;
                return;
            }

            for (int x = 0; x < PaintballManager.joinedPlayers.Count(); x++)
            {
                //Create the player
                UnturnedPlayer currentPlayer = PaintballManager.joinedPlayers[x].getPlayer();

                //Set dead to false
                PaintballManager.joinedPlayers[x].setDead(false);

                //Turn off god, clear, heal, and give max skills.
                currentPlayer.GodMode = false;
                PlayerManager.clearInventory(currentPlayer);;
                currentPlayer.Heal(100);
                currentPlayer.Hunger    = 0;
                currentPlayer.Thirst    = 0;
                currentPlayer.Infection = 0;
                PlayerManager.maxSkills(currentPlayer);

                //Spawn the paintball items
                currentPlayer.Inventory.tryAddItem(UnturnedItems.AssembleItem(1337, 250, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(1338, 1), new Attachment(1340, 100), EFiremode.SEMI), true);
                currentPlayer.GiveItem(1048, 1);
                currentPlayer.GiveItem(394, 4);
                currentPlayer.GiveItem(1133, 1);
                currentPlayer.GiveItem(431, 1);
                currentPlayer.GiveItem(177, 1);
                currentPlayer.GiveItem(548, 1);
                currentPlayer.GiveItem(1340, 5);

                //Locate their spawn point.
                System.Random spawnGen    = new System.Random();
                Vector3       playerSpawn = new Vector3(spawnGen.Next(PaintballManager.arenaMinX, PaintballManager.arenaMaxX), PaintballManager.arenaY, spawnGen.Next(PaintballManager.arenaMinZ, PaintballManager.arenaMaxZ));
                //Transport the player
                currentPlayer.Teleport(playerSpawn, spawnGen.Next(0, 360));
            }
            PaintballManager.gameRunning = true;
        }
Example #2
0
        public void GiveKit()
        {
            Player.GiveItem(GunGameConfig.instance.weapons.hat, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.mask, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.vest, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.pants, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.shirt, 1);

            GunGameConfig.Weapon weapon = GunGameConfig.instance.weapons.weapons[kitRequest];

            Item primary   = weapon.GetUnturnedItem();
            Item secondary = UnturnedItems.AssembleItem(GunGameConfig.instance.weapons.secondary, 1, 100, null);
            Item mag       = UnturnedItems.AssembleItem(weapon.mag, weapon.ammo, 100, null);

            Player.Inventory.items[0].tryAddItem(primary);
            Player.Inventory.items[1].tryAddItem(secondary);

            for (int i = 0; i < weapon.magAmt; i++)
            {
                Player.Inventory.items[2].tryAddItem(mag);
            }

            Invoke("Equip", GunGameConfig.instance.advSettings.equipTime);
        }
Example #3
0
        //       [RocketCommand("event", "Main command to start and manage events.", "<what to do>", AllowedCaller.Player)]
        public void Execute(IRocketPlayer caller, string[] parameters)
        {
            //           Logger.Log("Inside Execute command.");
            string[]       command = new string[1];
            UnturnedPlayer pCaller = (UnturnedPlayer)caller;

            var tempCharacterInfoDuplicate      = joinedPlayers.FirstOrDefault(item => item.getSteamID() == pCaller.CSteamID.ToString());
            var tempCharacterInfoGroupDuplicate = joinedPlayers.FirstOrDefault(item => item.getGroupID() == pCaller.SteamGroupID.ToString());

            if (parameters.Count() == 1)
            {
                command[0] = parameters[0].ToLower();
            }
            else
            {
                UnturnedChat.Say(caller, Events.Instance.Translate("events_invalid_parameter"), Events.Instance.Configuration.Instance.ErrorColor);
            }

            //Claim Reward
            if (command[0] == "reward")
            {
                if (!started && !eventActive)
                {
                    int playerWins = getWins(pCaller);
                    //      Logger.Log("Wins: " + playerWins);

                    if (playerWins == 0)
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_no_reward"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                    else
                    {
                        if (playerWins >= 1)
                        {
                            pCaller.GiveItem(253, 1);
                        }
                        if (playerWins >= 2)
                        {
                            pCaller.GiveItem(307, 1);
                            pCaller.GiveItem(308, 1);
                            pCaller.GiveItem(309, 1);
                            pCaller.GiveItem(310, 1);
                        }
                        if (playerWins >= 3)
                        {
                            pCaller.Inventory.tryAddItem(UnturnedItems.AssembleItem(1337, 250, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(1338, 1), new Attachment(1340, 100), EFiremode.AUTO), true);
                        }
                        if (playerWins >= 4)
                        {
                            pCaller.GiveItem(363, 1);
                            pCaller.GiveItem(6, 1);
                        }
                        if (playerWins >= 5)
                        {
                            pCaller.GiveItem(116, 1);
                            pCaller.GiveItem(6, 1);
                        }
                        if (playerWins >= 6)
                        {
                            pCaller.GiveItem(18, 1);
                            pCaller.GiveItem(20, 1);
                        }
                        if (playerWins >= 7)
                        {
                            pCaller.GiveItem(132, 1);
                            pCaller.GiveItem(133, 1);
                        }
                        if (playerWins >= 8)
                        {
                            pCaller.GiveItem(519, 1);
                            pCaller.GiveItem(520, 1);
                        }

                        UnturnedChat.Say(caller, Events.Instance.Translate("events_reward_given"), Events.Instance.Configuration.Instance.SuccessColor);
                    }
                    //Go through players and count wins and give prize based on that.
                    //Remove name from list once claimed.
                    //     pCaller.Inventory.tryAddItem(UnturnedItems.AssembleItem(363, 30, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(7, 100), new Attachment(6, 100), EFiremode.AUTO), true);
                    //   pCaller.GiveItem(394, 100);
                    return;
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_error_not_finished_reward"), Events.Instance.Configuration.Instance.ErrorColor);
                    return;
                }
            }

            #region on
            //Begin commands
            //On event command
            if (command[0] == "on")
            {
                if (caller.IsAdmin)
                {
                    if (!started)
                    {
                        joinedPlayers = new List <PlayerData>()
                        {
                        };
                        usedStorage    = new List <string>();
                        Events.winners = "";
                        started        = true;
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_on"), Events.Instance.Configuration.Instance.SuccessColor);
                        //                 UnturnedChat.Say(Events.Instance.Translate("events_join_announcement", gameMode), Events.Instance.Configuration.Instance.AnnouncementColor);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_already_active"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                }
                return;
            }
            #endregion

            #region off
            //Off event command
            if (command[0] == "off")
            {
                if (caller.IsAdmin)
                {
                    if (started)
                    {
                        started     = false;
                        eventActive = false;

                        Logger.Log("Total PLayer Count on Off: " + joinedPlayers.Count);
                        int playerCountBeforeDump = joinedPlayers.Count;
                        for (int x = 0; x < playerCountBeforeDump; x++)
                        {
                            UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(joinedPlayers[0].getSteamID())));
                            Logger.Log("Inside Off Loop" + x);
                            //          player.GodMode = false;
                            //              Logger.Log("Ran list");
                            leaveEvent(player);
                        }
                        //                    leaveEvent(pCaller);

                        UnturnedChat.Say(caller, Events.Instance.Translate("events_off"), Events.Instance.Configuration.Instance.SuccessColor);
                        UnturnedChat.Say(Events.Instance.Translate("events_ended_announcement"), Events.Instance.Configuration.Instance.AnnouncementColor);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_already_notactive"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                }
                return;
            }
            #endregion

            //Permission Reload command
            if (command[0] == "permreload")
            {
                if (caller.IsAdmin)
                {
                    foreach (SteamPlayer plr in Provider.Players)
                    {
                        //So let's convert each SteamPlayer into an UnturnedPlayer
                        UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);

                        unturnedPlayer.GodMode = false;

                        //Reset permissions
                        Rocket.Core.R.Permissions.RemovePlayerFromGroup("EventGroup", unturnedPlayer);
                        Rocket.Core.R.Permissions.AddPlayerToGroup("Guest", unturnedPlayer);
                    }
                    UnturnedChat.Say(caller, "Done.", Events.Instance.Configuration.Instance.SuccessColor);
                    return;
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                    return;
                }
            }



            if (started)
            {
                //Give lockers to store.
                if (command[0] == "storage")
                {
                    var tempCharacterInfoDuplicateLockers = usedStorage.FirstOrDefault(item => item == pCaller.CSteamID.ToString());

                    if (tempCharacterInfoDuplicateLockers == null)
                    {
                        pCaller.GiveItem(328, 4);
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_storage_given"), Events.Instance.Configuration.Instance.SuccessColor);
                        usedStorage.Add(pCaller.CSteamID.ToString());
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_storage_used"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }

                #region join
                //Join Event
                if (command[0] == "join")
                {
                    //         Logger.Log("Join Command");

                    //                joinedPlayers += pCaller.CSteamID;
                    //If player is not already added, add them
                    if (tempCharacterInfoDuplicate == null)
                    {
                        //               Logger.Log("Group: ." + pCaller.SteamGroupID + ".");
                        if (tempCharacterInfoGroupDuplicate == null || pCaller.SteamGroupID.ToString() == "0")
                        {
                            PlayerData     thisPlayer = new PlayerData(pCaller.CharacterName, pCaller.CSteamID.ToString(), pCaller.SteamGroupID.ToString(), pCaller.Position);
                            UnturnedPlayer player     = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(thisPlayer.getSteamID())));

                            joinedPlayers.Add(thisPlayer);
                            Rocket.Core.R.Permissions.RemovePlayerFromGroup("Guest", player);
                            Rocket.Core.R.Permissions.AddPlayerToGroup("EventGroup", player);

                            //During active event, send to position2.
                            if (eventActive)
                            {
                                //          pCaller.Suicide();
                                player.Teleport(position2, 0);
                                clearInventory(player);
                                player.GodMode = true;
                                thisPlayer.setDead(true);
                            }
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_joined_game"), Events.Instance.Configuration.Instance.SuccessColor);
                            return;
                        }
                        else
                        {
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_group_error"), Events.Instance.Configuration.Instance.ErrorColor);
                            return;
                        }
                    }
                    else if (tempCharacterInfoDuplicate != null)
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_already_joined_game", tempCharacterInfoDuplicate.getName()), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_error"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                #endregion

                #region leave
                //Leave Event
                if (command[0] == "leave")
                {
                    //             Logger.Log("Leave Command");
                    leaveEvent(pCaller);
                    return;
                    //                joinedPlayers += pCaller.CSteamID;
                    //                PlayerData thisPlayer = new PlayerData(pCaller.CharacterName, pCaller.CSteamID, pCaller.Position);
                    //               joinedPlayers.Add(thisPlayer);
                    //                UnturnedChat.Say(caller, Translate("events_joined_game"));
                }
                #endregion

                #region list
                //List All Joined Players
                if (command[0] == "list")
                {
                    //                 Logger.Log("List Command");

                    if (caller.IsAdmin)
                    {
                        //                   Logger.Log("List Command - admin");
                        string allJoinedPlayers = "";
                        for (int x = 0; x < joinedPlayers.Count; x++)
                        {
                            //                         Logger.Log("Ran list");
                            allJoinedPlayers += joinedPlayers[x].getName() + " ";
                        }
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_player_list", joinedPlayers.Count, allJoinedPlayers));
                        //                    Logger.Log(string.Join(Environment.NewLine, joinedPlayers.getName()));

                        //                   Logger.Log(allJoinedPlayers);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                #endregion

                //Paintball Game Mode
                if (gameMode == "paintball")
                {
                    if (caller.IsAdmin)
                    {
                        if (command[0] == "position1")
                        {
                            position1 = pCaller.Position;
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_position_set", "position1", position1), Events.Instance.Configuration.Instance.SuccessColor);
                        }

                        if (command[0] == "position2")
                        {
                            position2 = pCaller.Position;
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_position_set", "position2", position2), Events.Instance.Configuration.Instance.SuccessColor);
                        }

                        //Command start event
                        if (command[0] == "start")
                        {
                            if (!eventActive)
                            {
                                if (joinedPlayers.Count > 1)
                                {
                                    //                            Logger.Log("Event Start");
                                    eventActive   = true;
                                    activePlayers = joinedPlayers.Count;


                                    for (int x = 0; x < joinedPlayers.Count; x++)
                                    {
                                        UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(joinedPlayers[x].getSteamID())));

                                        player.GodMode = false;

                                        if (!joinedPlayers[x].getRevived())
                                        {
                                            leaveEvent(player);
                                        }
                                        else if (joinedPlayers[x].getRevived())
                                        {
                                            //                                  player.GodMode = false;
                                            joinedPlayers[x].setDead(false);
                                            //                                  Logger.Log("Event Start 2");

                                            clearInventory(player);
                                            healPlayer(player);
                                            maxSkills(player);

                                            //                                  Logger.Log("Event Start 3");
                                            //Paintball gun, 3 hoppers, 5 bandages,
                                            player.Inventory.tryAddItem(UnturnedItems.AssembleItem(1337, 250, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(1338, 1), new Attachment(1340, 100), EFiremode.SEMI), true);
                                            player.GiveItem(1048, 1);
                                            player.GiveItem(394, 4);
                                            player.GiveItem(1133, 1);
                                            player.GiveItem(431, 1);
                                            player.GiveItem(177, 1);
                                            player.GiveItem(548, 1);
                                            player.GiveItem(1340, 5);

                                            player.GodMode = false;
                                            player.Teleport(position1, 0);

                                            UnturnedChat.Say(player, Events.Instance.Translate("events_started", "position1", position1), Events.Instance.Configuration.Instance.SuccessColor);
                                        }
                                        else
                                        {
                                            UnturnedChat.Say(player, "Error. #3 Tell an admin the error code.", Events.Instance.Configuration.Instance.ErrorColor);
                                        }
                                    }
                                    //Winning method here
                                    Events myEvent = new Events();
                                    myEvent.dealWithWinEvent();
                                }
                                else
                                {
                                    UnturnedChat.Say(caller, Events.Instance.Translate("events_start_only_one"), Events.Instance.Configuration.Instance.ErrorColor);
                                }
                            }
                            else
                            {
                                UnturnedChat.Say(caller, Events.Instance.Translate("events_started_already"), Events.Instance.Configuration.Instance.ErrorColor);
                            }
                        }

                        //Command stop event
                        //Removes people and sends them to position2.
                        if (command[0] == "stop")
                        {
                            if (eventActive)
                            {
                                //                            Logger.Log("Event Stop");
                                eventActive = false;
                                for (int x = 0; x < joinedPlayers.Count; x++)
                                {
                                    UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(joinedPlayers[x].getSteamID())));
                                    player.GodMode = true;
                                    joinedPlayers[x].setDead(true);
                                    //                                Logger.Log("Event Start 2");

                                    clearInventory(player);
                                    healPlayer(player);


                                    //                                Logger.Log("Event Start 3");
                                    //                         player.GodMode = true;
                                    clearInventory(player);
                                    player.Teleport(position2, 0);

                                    UnturnedChat.Say(player, Events.Instance.Translate("events_stopped"), Events.Instance.Configuration.Instance.SuccessColor);
                                }
                            }
                            else
                            {
                                UnturnedChat.Say(caller, Events.Instance.Translate("events_stopped_already"), Events.Instance.Configuration.Instance.ErrorColor);
                            }
                        }

                        //                  Logger.Log("Command Start Finished");
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
            }
            else
            {
                UnturnedChat.Say(caller, Events.Instance.Translate("events_not_active"), Events.Instance.Configuration.Instance.ErrorColor);
                return;
            }
        }