コード例 #1
0
        override public void CreateEvents()
        {
            AddTimeEvent(0, new Action(() =>
            {
                Tick += runnerHintHandler;
                if (GamemodeConfig.huntNextMapIndex > 0)
                {
                    currentmapid = GamemodeConfig.huntNextMapIndex;
                }
                else
                {
                    //pick random playarea
                    currentmapid = rand.Next(0, Shared.sthvMaps.Maps.Length);
                }
                Server.currentMap = Shared.sthvMaps.Maps[currentmapid];
                map = Shared.sthvMaps.Maps[currentmapid];
                TriggerClientEvent("sthv:sendChosenMap", currentmapid);
                log("current map index: " + currentmapid);

                //Assigning teams.
                //Framework assures all dead players are ready for next hunt. Non-ready players could be loading, not authenticated, etc.
                var readyPlayers = sthvLobbyManager.GetPlayersOfState(playerState.ready);
                log(readyPlayers.Count + " ready players in this game.");

                //picking and assigning runner
                int runnerindex = rand.Next(0, readyPlayers.Count - 1);
                runner          = readyPlayers[runnerindex];
                log("RUNNER SET TO " + runner.player.Handle + " and has teamname: " + runner.teamname);

                //assigning everyone else hunter team
                foreach (var p in readyPlayers)
                {
                    if (p.teamname != TRunner)
                    {
                        p.teamname = THunter;
                    }
                }

                //announce teams to clients
                log($"^2runner handle is now: {runner.player.Handle}^7");
                TriggerClientEvent("sth:updateRunnerHandle", int.Parse(runner.player.Handle));
                Server.SendChatMessage("^2HUNT", $"Runner is:{runner.Name}", 255, 255, 255);
                Server.SendToastNotif($"InverseTag starting with runner: {runner.Name}", 3000);

                //spawn runner
                runner.Spawn(map.RunnerSpawn, true, playerState.alive);

                runner.player.TriggerEvent("sthv:spectate", false);
                Server.refreshscoreboard();
            }));

            AddTimeEvent(5, new Action(async() =>
            {
                log("spawning hunters after 5 seconds.");
                var hunters = sthvLobbyManager.GetPlayersInTeam(THunter);
                foreach (var h in hunters)
                {
                    h.Spawn(map.HunterSpawn, false, playerState.alive);
                }
                await Delay(1000);
                if (hunters.Count > 0)
                {
                    hunters[0].player.TriggerEvent("sthv:spawnhuntercars", currentmapid);
                }
                TriggerClientEvent("sth:new_runner", runner.player.Handle);
                log("setting runner to: " + runner.player.Handle);
            }));

            AddFinalizerEvent(new Action(() =>
            {
                TriggerClientEvent("sth:updateRunnerHandle", -1);
                TriggerClientEvent("removeveh");
            }));
        }
コード例 #2
0
        public override void CreateEvents()
        {
            AddTimeEvent(0, new Action(async() =>
            {
                Tick       += runnerHintHandler;
                Random rand = new Random();
                if (GamemodeConfig.huntNextMapIndex > 0)
                {
                    currentmapid = GamemodeConfig.huntNextMapIndex;
                }
                else
                {
                    //pick random playarea
                    currentmapid = rand.Next(0, Shared.sthvMaps.Maps.Length);
                }
                Server.currentMap = Shared.sthvMaps.Maps[currentmapid];
                map = Shared.sthvMaps.Maps[currentmapid];
                TriggerClientEvent("sthv:sendChosenMap", currentmapid);
                log("current map index: " + currentmapid);

                //Assigning teams.
                //Framework assures all dead players are ready for next hunt. Non-ready players could be loading, not authenticated, etc.
                var readyPlayers = sthvLobbyManager.GetPlayersOfState(playerState.ready);
                log(readyPlayers.Count + " ready players in this hunt.");

                //picking and assigning runner
                int runnerindex = rand.Next(0, readyPlayers.Count);
                log("picked runner index: " + runnerindex);

                readyPlayers[runnerindex].teamname = TRunner;
                //assigning everyone else hunter team
                foreach (var p in readyPlayers)
                {
                    if (p.teamname != TRunner)
                    {
                        p.teamname = THunter;
                    }
                }

                runner = sthvLobbyManager.GetPlayersInTeam(TRunner)[0];

                if (sthvLobbyManager.GetPlayersInTeam("runner").Count != 1)
                {
                    throw new Exception("Unexpected number of runners were assigned in ClassicHunt");
                }
                runnerServerId = runner.player.Handle;

                log($"^2runner handle is now: {runnerServerId}^7");
                TriggerClientEvent("sth:updateRunnerHandle", int.Parse(runnerServerId));
                Server.SendChatMessage("^2HUNT", $"Runner is:{runner.Name}", 255, 255, 255);
                Server.SendToastNotif($"Hunt starting with runner: {runner.Name}", 3000);

                await Delay(100);
#if DEBUG
                runner.Spawn(map.HunterSpawn, true, playerState.alive);
#else
                runner.Spawn(map.RunnerSpawn, true, playerState.alive);
#endif

                //offer hunters to opt into runner ?
                TriggerClientEvent("removeveh");
                await Delay(3000);

                runner.player.TriggerEvent("sthv:spectate", false);
                Server.refreshscoreboard();
            }));
            AddTimeEvent(5, new Action(async() =>
            {
                log("spawning hunters after 5 seconds.");
                var hunters = sthvLobbyManager.GetPlayersInTeam(THunter);
                foreach (var h in hunters)
                {
                    h.Spawn(map.HunterSpawn, false, playerState.alive);
                }
                await Delay(1000);
                if (hunters.Count > 0)
                {
                    hunters[0].player.TriggerEvent("sthv:spawnhuntercars", currentmapid);
                }
            }));
            AddTimeEvent(30, new Action(() =>
            {
                log("Giving weapons after 30 seconds");

                runner.player.TriggerEvent("sth:updateRunnerHandle", runnerServerId); //incase runner has wrong clothes

                TriggerClientEvent("sth:setguns", true);
                TriggerClientEvent("sth:setcops", GamemodeConfig.isPoliceEnabled);

                Server.SendChatMessage("^5HUNT", "You now have guns");
                Server.SendToastNotif("You now have weapons!");
            }));

            AddFinalizerEvent(new Action(() =>
            {
                TriggerClientEvent("sth:updateRunnerHandle", -1);
                foreach (var p in sthvLobbyManager.GetPlayersOfState(playerState.alive, playerState.ready))
                {
                    p.Spawn(map.HunterSpawn, false, playerState.ready);
                }

                TriggerClientEvent("removeveh");
            }));
        }