Esempio n. 1
0
        /// <summary>
        /// Intitialize a new session with the given level number of players and teams.
        /// </summary>
        /// <param name="levelIndex"></param>
        /// <param name="numPlayers"></param>
        public void Initialize(int levelIndex, int numPlayers, int numTeams)
        {
            ScriptMain.DebugPrint("Initializing a new session with {0} players and {1} total teams.", numPlayers, numTeams);

            LevelManager levelMgr = ScriptThread.GetOrAddExtension <LevelManager>();

            InitTeamConstantData(numTeams);

            current = new SessionInfo(levelIndex, numPlayers);

            levelMgr.DoLoadLevel(current.LevelIndex);

            for (int i = 0; i < numPlayers; i++)
            {
                TeamData team = FindFreeTeam();

                Player player = CreatePlayer(i, team.Index, i < 1);

                player.OnDead += OnPlayerDead;

                current.AddPlayer(i, team.Index, player);

                //ScriptMain.DebugPrint("Added a new player at slot '{0}' with name \"{1}\" teamIdx: {2}", i, player.Name, team.Index);
            }

            ScriptThread.SetVar("scr_activesession", true);
        }
Esempio n. 2
0
        public SessionPlayer AddPlayer(int playerIndex, int teamIdx, Player PlayerRef)
        {
            SessionPlayer player = new SessionPlayer(teamIdx, PlayerRef);

            Players[playerIndex] = player;
            return(player);
        }
Esempio n. 3
0
        private void OnPlayerDead(Player sender, EventArgs e)
        {
            sender.RegisterDeaths(1);

            var scoreAmount = ScriptThread.GetVar <int>("scr_score_per_death");

            RegisterTeamScore(sender.Info.Sess.TeamNum, scoreAmount.Value);

            var attackerEnt = Function.Call <Entity>(CustomNative.GET_PED_SOURCE_OF_DEATH, sender.Ped.Ref);

            if (attackerEnt != null)
            {
                ScriptMain.DebugPrint("OnPlayerDead: Found attacker entity.");

                var inflictor = current.Players
                                .FirstOrDefault(x => x.PlayerRef.Ped == attackerEnt || x.PlayerRef.Vehicle == attackerEnt);

                if (inflictor.PlayerRef != null && sender.Info.Sess.TeamNum != inflictor.TeamIdx)
                {
                    ScriptMain.DebugPrint("OnPlayerDead: Found inflicting player.");

                    inflictor.PlayerRef.RegisterKills(1);

                    scoreAmount = ScriptThread.GetVar <int>("scr_score_per_kill");

                    RegisterTeamScore(inflictor.TeamIdx, scoreAmount.Value);

                    if (inflictor.PlayerRef is LocalPlayer)
                    {
                        displayMgr.ShowKillPopup(sender.Name, sender.Info.Sess.TeamNum);
                    }
                }
            }

            // award assist points to players that inflicted damage..

            for (int x = 0; x < current.NumPlayers; x++)
            {
                if (current.Players[x].TeamIdx == sender.Info.Sess.TeamNum)
                {
                    continue;
                }

                if (sender.Vehicle.Ref.HasBeenDamagedBy(current.Players[x].PlayerRef.Ped) ||
                    sender.Vehicle.Ref.HasBeenDamagedBy(current.Players[x].PlayerRef.Vehicle))
                {
                    current.Players[x].PlayerRef.RegisterKills(1);

                    scoreAmount = ScriptThread.GetVar <int>("scr_score_per_assist");

                    RegisterTeamScore(current.Players[x].TeamIdx, scoreAmount.Value);

                    if (current.Players[x].PlayerRef is LocalPlayer)
                    {
                        displayMgr.ShowKillPopup(sender.Name, sender.Info.Sess.TeamNum);
                    }
                }
            }
        }
Esempio n. 4
0
        public override void OnPlayerAttached(Player player)
        {
            bIsLocal = player is LocalPlayer;

            player.OnDead += OnPlayerDead;

            base.OnPlayerAttached(player);
        }
Esempio n. 5
0
        private void Player_OnAlive(Player sender, EventArgs e)
        {
            sequenceList.ForEach(x => x.RemoveAll());

            sequenceList.Clear();

            SetupWithVehicle(sender.Vehicle.Ref);
        }
        public override void OnPlayerAttached(Player player)
        {
            if (!extingusherPtx.IsLoaded)
            {
                extingusherPtx.Load();
            }

            base.OnPlayerAttached(player);
        }
Esempio n. 7
0
        private void DoRespawn()
        {
            var spawnPoint = levelMgr.GetSpawnPoint(Player.Info.Sess.TeamNum);

            if (bIsLocal)
            {
                Function.Call(Hash.RESURRECT_PED, Player.Ped.Ref);

                Function.Call(Hash._RESET_LOCALPLAYER_STATE);

                Utility.FadeScreenIn(FadeInDuration);
            }

            Player.Create();
        }
Esempio n. 8
0
        /// <summary>
        /// Fired when the player has died.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPlayerDead(Player sender, EventArgs e)
        {
            //ScriptMain.DebugPrint("Extensions.RespawnManager: Starting respawn...");
            if (bIsLocal)
            {
                //Utility.FadeOutScreen(FadeOutDuration);

                Function.Call(Hash.IGNORE_NEXT_RESTART, true);

                respawnTriggerTime = Game.GameTime + LocalPlayerWaitTime;
            }

            else
            {
                respawnTriggerTime = Game.GameTime + AIPlayerWaitTime;
            }

            waitActive = true;
        }
Esempio n. 9
0
 public SessionPlayer(int teamIdx, Player player)
 {
     TeamIdx   = teamIdx;
     PlayerRef = player;
 }
Esempio n. 10
0
 public RespawnManager(Player player) : base(player)
 {
     sessionMgr = ScriptThread.GetOrAddExtension <SessionManager>();
     levelMgr   = ScriptThread.GetOrAddExtension <LevelManager>();
     displayMgr = ScriptThread.GetOrAddExtension <DisplayManager>();
 }
Esempio n. 11
0
        public override void OnPlayerAttached(Player player)
        {
            player.OnAlive += Player_OnAlive;

            base.OnPlayerAttached(player);
        }
Esempio n. 12
0
 public IRFlareManager(Player player) : base(player)
 {
 }
 public EngineExtinguisher(Player player) : base(player)
 {
 }