Exemple #1
0
        public override void OnPlayerSpawned(string soldierName, Inventory spawnedInventory)
        {
            base.OnPlayerSpawned(soldierName, spawnedInventory);

            foreach (Message m in messages.FindAll((m) => m.enabled))
                try
                {
                    m.OnPlayerSpawned(soldierName);
                }
                catch (Exception exc)
                {
                    ConsoleError("Exception with OnPlayerSpawned of '" + m.name + "': " + exc.Message + " " + exc.StackTrace);
                }
        }
Exemple #2
0
 public override void OnPlayerSpawned(string soldierName, Inventory spawnedInventory) {
     PlayerProfile player = getPlayerProfile(soldierName);
     if (player != null) {
         player.updateLastSpawn();
         player.state = PlayerState.alive;
     }
 }
Exemple #3
0
        private void PRoConClient_PlayerSpawned(FrostbiteClient sender, string soldierName, string strKit, List<string> lstWeapons, List<string> lstSpecializations) {
            if (PlayerSpawned != null) {
                if (Enum.IsDefined(typeof (Kits), strKit) == true) {
                    var inv = new Inventory((Kits) Enum.Parse(typeof (Kits), strKit));

                    foreach (string strWeapon in lstWeapons) {
                        if (Weapons.Contains(strWeapon) == true) {
                            inv.Weapons.Add(Weapons[strWeapon]);
                        }
                    }

                    foreach (string strSpecialization in lstSpecializations) {
                        if (Specializations.Contains(strSpecialization) == true) {
                            inv.Specializations.Add(Specializations[strSpecialization]);
                        }
                    }

                    FrostbiteConnection.RaiseEvent(PlayerSpawned.GetInvocationList(), this, soldierName, inv);
                }
                else {
                    FrostbiteConnection.RaiseEvent(PlayerSpawned.GetInvocationList(), this, soldierName, new Inventory(Kits.None));
                }
            }
        }
        public override void OnPlayerSpawned(String soldierName, Inventory spawnedInventory)
        {
            if (!fIsEnabled) return;

            DebugWrite("^9^bGot OnPlayerSpawned: ^n" + soldierName, 8);

            try {
            if (fGameState == GameState.Unknown || fGameState == GameState.Warmup) {
            bool wasUnknown = (fGameState == GameState.Unknown);
            fGameState = (this.TotalPlayerCount < 4) ? GameState.Warmup : GameState.Playing;
            if (wasUnknown || fGameState == GameState.Playing) DebugWrite("OnPlayerSpawned: ^b^3Game state = " + fGameState, 6);
            fNeedPlayerListUpdate = (fGameState == GameState.Playing);
            } else if (fGameState == GameState.RoundStarting) {
            // First spawn after Level Loaded is the official start of a round
            DebugWrite(":::::::::::::::::::::::::::::::::::: ^b^1First spawn detected^0^n ::::::::::::::::::::::::::::::::::::", 3);

            fGameState = (this.TotalPlayerCount < 4) ? GameState.Warmup : GameState.Playing;
            DebugWrite("OnPlayerSpawned: ^b^3Game state = " + fGameState, 6);

            ResetRound();
            fIsFullRound = true;
            ServerCommand("serverInfo");
            ScheduleListPlayers(2);
            fNeedPlayerListUpdate = (fGameState == GameState.Playing);
            }

            if (fPluginState == PluginState.Active) {
            ValidateMove(soldierName);
            if (fGameState != GameState.RoundEnding) {
                SpawnUpdate(soldierName);
                FireMessages(soldierName);
                CheckDelayedMove(soldierName);
                if (IsRush()) CheckServerInfoUpdate();
            }
            }
            } catch (Exception e) {
            ConsoleException(e);
            }
        }
Exemple #5
0
        //**********************************************************************************************
        //**********************************************************************************************
        //   PROCESS VARIOUS PROCON 'EVENT' PROCEDURES - e.g. OnPlayerSpawned(), OnPlayerKilled()
        //**********************************************************************************************
        //**********************************************************************************************
        //********************************************************************************************
        // this procedure gets called when every player SPAWNS
        // so at that point we will scan the rules and decide whether to apply any actions
        //********************************************************************************************
        public override void OnPlayerSpawned(string player_name, Inventory inv)
        {
            // EVENT EXCEPTION BLOCK:
            try
            {
                // debug stuff
                string blocks = "";
                if (player_blocks.ContainsKey(player_name))
                    blocks = String.Join("/", player_blocks[player_name].ToArray());
                WriteDebugInfo("********************OnPlayerSpawned***************************" +
                    player_name);
                WriteDebugInfo(String.Format("ProconRulz: OnPlayerSpawned [{0}] with blocks [{1}]",
                    player_name, blocks));
                //end debug

                // create structure to hold substitution keywords and values
                Dictionary<SubstEnum, string> keywords = new Dictionary<SubstEnum, string>();

                // remove this player from the spawn item lists for now
                spawn_counts.zero_player(player_name);
                remove_blocks(player_name);       // remove any player_blocks entries

                // BF bug workaround -
                // check to see if player can do damage Shotgun before saving spec sp-shotgun_s
                bool has_damage_shotgun = false;

                string player_team_id = players.team_id(player_name);

                WriteDebugInfo(String.Format("ProconRulz: OnPlayerSpawned [{0}] team_id {1}",
                    player_name, player_team_id));

                // add player to kit spawned list, if kit is 'watched'
                spawn_counts.add(item_key(inv.Kit), player_team_id, player_name);

                player_kit[player_name] = item_key(inv.Kit); // record kit that this player spawned with
                WriteDebugInfo(String.Format("ProconRulz: OnPlayerSpawned [{0}] kit {1}",
                    player_name, player_kit[player_name]));

                List<string> damages = new List<string>();
                List<string> weapon_keys = new List<string>();
                List<string> weapon_names = new List<string>();
                foreach (Weapon w in inv.Weapons)
                {
                    // add playername to watch list for weapon, if it's being watched
                    spawn_counts.add(item_key(w), player_team_id, player_name);

                    // add playername to watch list for weapon damage, if it's being watched
                    spawn_counts.add(item_key(w.Damage), player_team_id, player_name);
                    // BF bug workaround - remember if player can do damage shotgun
                    if (item_key(w.Damage).ToLower() == "shotgun") has_damage_shotgun = true;

                    // build 'weapons' and damages string lists for debug printout and subst variables
                    weapon_keys.Add(w.Name);
                    weapon_names.Add(weapon_desc(w.Name));
                    damages.Add(item_key(w.Damage));
                } // end looping through weapons in inventory
                // store %wk% subst var (weapon keys)
                if (weapon_keys.Count > 0)
                    keywords.Add(SubstEnum.WeaponKey, string.Join(", ", weapon_keys.ToArray()));
                else
                    keywords.Add(SubstEnum.WeaponKey, "No weapon key");
                // store %w% subst var (weapon names)
                if (weapon_names.Count > 0)
                    keywords.Add(SubstEnum.Weapon, string.Join(", ", weapon_names.ToArray()));
                else
                    keywords.Add(SubstEnum.Weapon, "No weapon");
                // store %d% subst var (damages)
                if (damages.Count > 0)
                    keywords.Add(SubstEnum.Damage, string.Join(", ", damages.ToArray()));
                else
                    keywords.Add(SubstEnum.Damage, "No damage");

                WriteDebugInfo(String.Format("ProconRulz: OnPlayerSpawned [{0}] weapons [{1}]",
                    player_name, keywords[SubstEnum.Weapon]));

                List<string> spec_keys = new List<string>();
                List<string> spec_names = new List<string>();
                foreach (Specialization s in inv.Specializations)
                {
                    // condition is a BF bug workaround
                    // Add this Spec IF player has a weapon that does damage Shotgun,
                    // OR if the spec is not 12-Gauge Sabot Rounds
                    if (has_damage_shotgun || (!(item_key(s).ToLower() == "sp_shotgun_s")))
                        spawn_counts.add(item_key(s), player_team_id, player_name);

                    spec_keys.Add(item_key(s));
                    spec_names.Add(spec_desc(s));
                } // end looping through specs in inventory
                // store %speck% subst var (spec keys)
                if (spec_keys.Count > 0)
                    keywords.Add(SubstEnum.SpecKey, string.Join(", ", spec_keys.ToArray()));
                else
                    keywords.Add(SubstEnum.SpecKey, "No spec key");
                // store %spec% subst var (specializations)
                if (spec_names.Count > 0)
                    keywords.Add(SubstEnum.Spec, string.Join(", ", spec_names.ToArray()));
                else
                    keywords.Add(SubstEnum.Spec, "No spec");

                WriteDebugInfo(
                    String.Format("^bProconRulz: [{0}] {1} spawned. Kit {2}. Weapons [{3}]. Specs [{4}]. Damages [{5}]",
                                        team_name(player_team_id),
                                        player_name,
                                        item_key(inv.Kit),
                                        keywords[SubstEnum.Weapon],
                                        keywords[SubstEnum.Spec],
                                        keywords[SubstEnum.Damage]
                                        ));

                // debug stuff
                if (trace_rules == enumBoolYesNo.Yes) prdebug("counts");

                //Check if the player carries any of the things we're looking for
                scan_rules(TriggerEnum.Spawn, player_name, keywords, inv, null, null);
            }
            catch (Exception ex)
            {
                WriteConsole("ProconRulz: recoverable exception in OnPlayerSpawn");
                PrintException(ex);
            }
        }
Exemple #6
0
        public override void OnPlayerSpawned(String soldierName, Inventory spawnedInventory) {
            DebugWrite("Entering OnPlayerSpawned", 7);
            try
            {
                AdKatsPlayer aPlayer = null;
                if (_pluginEnabled && _threadsReady) {
                    if (_currentRoundState == RoundState.Loaded) {
                        _currentRoundState = RoundState.Playing;
                    }
                    if (_CommandNameDictionary.Count > 0) {
                        //Handle TeamSwap notifications
                        String command = _CommandKeyDictionary["self_teamswap"].command_text;
                        if (_PlayerDictionary.TryGetValue(soldierName, out aPlayer)) {
                            aPlayer.lastSpawn = DateTime.UtcNow;
                            aPlayer.lastAction = DateTime.UtcNow;
                            if (aPlayer.player_aa && !aPlayer.player_aa_told) {
                                String adminAssistantMessage = "You are now considered an Admin Assistant. ";
                                if (!_UseAAReportAutoHandler && !_EnableAdminAssistantPerk) {
                                    adminAssistantMessage += "Thank you for your consistent reporting.";
                                }
                                else {
                                    adminAssistantMessage += "Perks: ";
                                    if (_UseAAReportAutoHandler) {
                                        adminAssistantMessage += "AutoAdmin can handle some of your reports. ";
                                    }
                                    if (_EnableAdminAssistantPerk) {
                                        adminAssistantMessage += "You can use the @" + command + " command.";
                                    }
                                }
                                PlayerSayMessage(soldierName, adminAssistantMessage, 1);
                                aPlayer.player_aa_told = true;
                            }
                        }
                    }

                    //Handle Dev Notifications
                    if (soldierName == "ColColonCleaner" && (!_isTestingAuthorized || !_toldCol)) {
                        PlayerTellMessage("ColColonCleaner", "CONGRATS! This server is running AdKats " + PluginVersion + "!", 1);
                        _toldCol = true;
                    }

                    if (aPlayer != null && !aPlayer.player_firstSpawned) {
                        aPlayer.player_firstSpawned = true;
                        if(_UseFirstSpawnMessage) {
                            //Wait 3 seconds
                            Thread.Sleep(2000);
                            PlayerTellMessage(aPlayer.player_name, _FirstSpawnMessage, 1);
                        }
                    }

                    if (_ActOnSpawnDictionary.Count > 0) {
                        if (_isTestingAuthorized)
                            PushThreadDebug(DateTime.Now.Ticks, (String.IsNullOrEmpty(Thread.CurrentThread.Name) ? ("mainthread") : (Thread.CurrentThread.Name)), Thread.CurrentThread.ManagedThreadId, new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileLineNumber(), "");
                        lock (_ActOnSpawnDictionary) {
                            AdKatsRecord record;
                            if (_ActOnSpawnDictionary.TryGetValue(soldierName, out record)) {
                                //Remove it from the dic
                                _ActOnSpawnDictionary.Remove(soldierName);
                                //Wait 1.5 seconds to take action (no "killed by admin" message in BF3 without this wait)
                                Thread.Sleep(1500);
                                //Queue the action
                                QueueRecordForActionHandling(record);
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                HandleException(new AdKatsException("Error while handling player spawn.", e));
            }
            DebugWrite("Exiting OnPlayerSpawned", 7);
        }
 public override void OnPlayerSpawned(String soldierName, Inventory spawnedInventory)
 {
 }
Exemple #8
0
        // test a rule (we have already confirmed Spawn or Kill trigger is true)
        // will return 'true' if the rule is applied
        private bool process_rule(TriggerEnum trigger, ParsedRule rule, string player_name, 
            ref Dictionary<SubstEnum, string> keywords,
            Inventory inv, Kill k, string item)
        {
            WriteDebugInfo(String.Format("ProconRulz:   process_rule[{0}] with event {1}",
                                player_name,
                                Enum.GetName(typeof(TriggerEnum), trigger)));

            // CATCH EXCEPTIONS
            try
            {
                List<PartClass> parts = new List<PartClass>(rule.parts);

                if (trigger == TriggerEnum.Say) keywords[SubstEnum.Text] = item;
                // Populate the Counts AS IF THIS RULE SUCCEEDED so conditions can use them
                keywords[SubstEnum.ServerCount] = count_server_rule(rule.id).ToString() + 1;
                keywords[SubstEnum.Count] = count_rule(player_name, rule.id).ToString() + 1;
                keywords[SubstEnum.TeamCount] = count_team_rule(players.team_id(player_name), rule.id).ToString() + 1;

                // populate the 'keywords' dictionary
                assign_keywords(trigger, rule, player_name, ref keywords, inv, k, item);

                if (!process_parts(rule, parts, player_name, ref keywords, k, item))
                {
                    WriteDebugInfo(String.Format("ProconRulz:   process_rule[{0}] in rule [{1}] tests NEGATIVE",
                        player_name, rule.unparsed_rule));
                    return false;
                }

                WriteDebugInfo(String.Format("ProconRulz:   process_rule[{0}] in rule [{1}] all conditions OK",
                    player_name, rule.unparsed_rule));

                // return 'true' to quit rulz checks after this rule
                // if rule contains End, Kill, Kick, TempBan, Ban unless it contains Continue.
                return end_rulz(parts);
            }
            catch (Exception ex)
            {
                WriteConsole("ProconRulz: recoverable exception in test_rule_and_exec(" +
                    rule.unparsed_rule + ")");
                PrintException(ex);
                return false;
            }
        }
 public override void OnPlayerSpawned(String soldierName, Inventory spawnedInventory)
 {
     if (fListenForSpawn) {
     DebugWrite("OnPlayerSpawned first spawn, count of team switches = " + fNumSwitches, 4);
     fListenForSpawn = false;
     fNumSwitches = -1;
     }
 }
        public override void OnPlayerSpawned(string soldierName, Inventory spawnedInventory)
        {
            if (ZombieModeEnabled == false)
            {
                SetState(GState.Idle);
                return;
            }

            RemoveJoinQueue(soldierName);

            // Kick any over max players
            bool KickIt = false;
            lock (PlayerKickQueue)
            {
                KickIt = PlayerKickQueue.Contains(soldierName);
            }

            if (KickIt)
            {
                DebugWrite("OnPlayerSpawned: Over max with " + soldierName, 4);
                ScheduleKick(soldierName, "Zombie Mode max players of " + MaxPlayers + " exceeded, try later"); // $$$ - custom message
                return;
            }

            String WhichTeam = (GetState() == GState.Playing) ? "UNKNOWN" : GetState().ToString();

            bool NeedUpdate = true;

            lock (TeamHuman)
            {
                if (TeamZombie.Contains(soldierName))
                {
                    WhichTeam = "ZOMBIE";
                    NeedUpdate = false;
                }
                else if (TeamHuman.Contains(soldierName))
                {
                    WhichTeam = "HUMAN";
                    NeedUpdate = false;
                }
            }
            DebugWrite("OnPlayerSpawned: " + soldierName + "(" + WhichTeam + ")", 4);

            PlayerState.UpdateSpawnTime(soldierName);
            PlayerState.SetSpawned(soldierName, true);

            if (NeedUpdate)
            {
                int ToTeam = (NewPlayersJoinHumans) ? 1 : 2;

                DebugWrite("OnPlayerSpawned: ^1^bforcing move to team " + ToTeam, 3);

                TellPlayer(soldierName + ": Sorry, need to force you to respawn ...", soldierName, false);

                UpdateTeams(soldierName, ToTeam);

                if (ToTeam == 1)
                {
                    ForceMove(soldierName, HUMAN_TEAM, 0);
                }
                else
                {
                    ForceMove(soldierName, ZOMBIE_TEAM, 0);
                }

                return;
            }

            // Check if we have enough players spawned
            int Need = MinimumHumans + MinimumZombies;
            if (CountAllTeams() < Need)
            {
                if (GetState() == GState.Playing)
                {
                    TellAll("Not enough players left to finish match ... MATCH HALTED!");
                    DebugWrite("***** HALT: not enough players!", 1);
                    HaltMatch(); // Sets GameState to Waiting
                }
                else
                {
                    TellAll("Welcome to Zombie Mode! Need " + (Need-CountAllTeams()) + " more players to join AND spawn to start the match ..."); // $$$ - custom message
                }
                SetState(GState.Waiting);
                return; // Don't count this spawn
            }
            else if (CountAllTeams() >= Need && (GetState() == GState.Waiting || GetState() == GState.Idle))
            {
                TellAll("New match starting ... counting down ..."); // $$$ - custom message
                CountdownNextRound(ZOMBIE_TEAM); // Sets GameState to CountingDown or NeedSpawn
                return;
            }

            // Sanity check
            if (GetState() == GState.BetweenRounds)
            {
                int cz = 0;

                lock (TeamHuman)
                {
                    cz = TeamZombie.Count;
                }

                if (PatientZero == null || cz == 0)
                {
                    // We failed to pick a zombie, so use this spawner
                    DebugWrite("OnPlayerSpawned: BetweenRounds sanity check failed, forcing zombie " + soldierName, 5);

                    SetState(GState.RoundStarting);
                    ServerSwitchedCount = 0;

                    PatientZero = soldierName;
                    PatientZeroes.Add(PatientZero);

                    DebugWrite("OnPlayerSpawned: making " + PatientZero + " the first zombie!", 2);

                    MakeZombie(soldierName);

                    UpdateTeams(soldierName, 2);
                }
            }

            // Check if this is the first spawn of the round/match
            if (GetState() == GState.BetweenRounds || GetState() == GState.NeedSpawn || GetState() == GState.RoundStarting)
            {
                SetState(GState.Playing);
                if (RematchEnabled)
                {
                    ++MatchesCount;
                    DebugWrite("Match " + MatchesCount + " of " + MatchesBeforeNextMap, 2);
                }
                DebugWrite("--- Version " + GetPluginVersion() + " ---", 1);
                DebugWrite("^b^2****** MATCH STARTING WITH " + CountAllTeams() + " players!^0^n", 1);
                DebugWrite("OnPlayerSpawned: announcing first zombie is " + PatientZero, 5);
                TellAll(PatientZero + " is the first zombie!"); // $$$ - custom message
            }
            else if (GetState() == GState.Moving)
            {
                DebugWrite("OnPlayerSpawned: early spawner while still moving " + soldierName, 3);
                TellPlayer("The match hasn't started yet, you might have to respawn ...", soldierName);
                return;
            }

            // Otherwise, GameState is Playing

            int n = PlayerState.GetSpawnCount(soldierName);

            // Tell zombies they can only use hand to hand weapons
            if (FreshZombie.Contains(soldierName))
            {
                DebugWrite("OnPlayerSpawned " + soldierName + " is fresh zombie!", 5);
                FreshZombie.Remove(soldierName);
                TellPlayer("You are now a zombie! Use a knife/defib/repair tool only!", soldierName); // $$$ - custom message
            }
            else if (PlayerState.GetWelcomeCount(soldierName) == 0)
            {
                String Separator = " ";
                if (CommandPrefix.Length == 1) Separator = "";
                TellPlayer("Welcome to Zombie Mode! Type '" + CommandPrefix + Separator + "rules' for instructions on how to play", soldierName); // $$$ - custom message
                PlayerState.SetWelcomeCount(soldierName, 1);
            }
            else if (n == 0)
            {
                lock (TeamHuman)
                {
                    if (!TeamHuman.Contains(soldierName))
                    {
                        ConsoleError("OnPlayerSpawned: " + soldierName + " should be human, but not present in TeamHuman list!");

                        if (GetState() == GState.Playing)
                        {
                            DebugWrite("ZOMBIE MODE STOPPED - teams are not right!", 1);
                            TellAll("ZOMBIE MODE STOPPED - teams are not right!");
                            TellAll("Respawn or run next map round/level to fix it", false);
                            Reset();
                            RequestPlayersList(); // Should fix up teams
                            return;
                        }
                    }
                }
                TellPlayer("You are a human! Shoot zombies, don't use explosives, don't let zombies get near you!", soldierName); // $$$ - custom message
            }

            PlayerState.SetSpawnCount(soldierName, n+1);

            AdaptDamage();
        }
        public void OnPlayerSpawned(string soldierName, Inventory spawnedInventory) {

        }
 public override void OnPlayerSpawned(String name, Inventory inventory)
 {
 }
Exemple #13
0
 /// <summary>Is called when a player spawns.</summary>
 public void OnPlayerSpawned(String strSoldierName, Inventory spawnedInventory)
 {
     if (mEnabled && !mTsReconnecting)
         addToActionQueue(Commands.PlayerSpawned, strSoldierName);
 }
Exemple #14
0
 private void m_prcClient_PlayerSpawned(PRoConClient sender, string soldierName, Inventory spawnedInventory) {
     InvokeOnAllEnabled("OnPlayerSpawned", new object[] {soldierName, spawnedInventory});
 }
 public virtual void OnPlayerSpawned(string soldierName, Inventory spawnedInventory) { 
  
     if (this.boolLevelStart == false && this.boolLevelLoaded){
         this.boolmessagesent = false;
         this.boolfirstscrambler = false;
         this.boolLevelLoaded = false;
         this.boolLevelStart = true;
         this.DebugInfo("First Spawner: ^bRound started!");
         this.DebugInfoGuard("First Spawner: ^bRound started!");
         this.DTLevelStart = DateTime.Now;
     }
     
     if (this.dicPlayerCache.ContainsKey(soldierName)) {
         this.dicPlayerCache[soldierName].tobebalanced = false;
     }
     //string msg = soldierName + " spawned.";
     //this.ExecuteCommand("procon.protected.pluginconsole.write", msg);
 }
Exemple #16
0
        private void assign_keywords(TriggerEnum trigger, ParsedRule rulex, string player_name,
            ref Dictionary<SubstEnum, string> keywords,
            Inventory inv, Kill k, string item)
        {
            // HERE's WHERE WE UPDATE THE SUBST KEYWORDS (and conditions can as well,
            // e.g. TargetPlayer)
            // this would be more efficient if I only updated the keywords that are
            // actually used in the rulz

            // update player count etc for this rule (for use of %c% parameter
            // or subsequent Count condition)

            if (trigger == TriggerEnum.Spawn)
            {
                keywords[SubstEnum.Kit] = kit_desc(item_key(inv.Kit));
                keywords[SubstEnum.KitKey] = item_key(inv.Kit);
                // keywords[Weaponkey, Weapon, Damage, SpecKey, Spec] all set in OnPlaeyrSpawned
            }
            else if (trigger == TriggerEnum.Kill ||
                trigger == TriggerEnum.TeamKill ||
                trigger == TriggerEnum.Suicide ||
                trigger == TriggerEnum.PlayerBlock
                )
            {
                try
                {
                    // we're in a 'kill' type event here
                    // as far as I can tell, 'k.DamageType' usually contains
                    // weapon key, but sometimes can be null

                    // with BF3, k.Killer.SoldierName can be empty (null or ""?)
                    if (k == null) return;

                    string victim_name = (k.Victim == null) ? "No victim" : k.Victim.SoldierName;
                    keywords[SubstEnum.Victim] = victim_name;

                    string weapon_key = k.DamageType;

                    Weapon weapon_used;
                    try
                    {
                        if (weapon_key == null) weapon_used = null;
                        else weapon_used = weaponDefines[weapon_key];
                    }
                    catch { weapon_used = null; }

                    string weapon_descr = weapon_desc(weapon_key);

                    string damage;
                    try
                    {
                        damage = (weapon_used == null) ? "No damage key" : item_key(weapon_used.Damage);
                    }
                    catch { damage = "No damage key"; }

                    keywords[SubstEnum.Weapon] = weapon_descr;
                    keywords[SubstEnum.WeaponKey] = weapon_key;

                    keywords[SubstEnum.KitKey] = spawned_kit(player_name);
                    keywords[SubstEnum.Kit] = kit_desc(spawned_kit(player_name));

                    keywords[SubstEnum.VictimKit] = kit_desc(spawned_kit(victim_name));
                    keywords[SubstEnum.VictimTeamKey] = players.team_id(victim_name);
                    keywords[SubstEnum.VictimTeam] = team_name(players.team_id(victim_name));

                    keywords[SubstEnum.VictimCountry] = players.cname(victim_name);
                    keywords[SubstEnum.VictimCountryKey] = players.ckey(victim_name);

                    keywords[SubstEnum.Damage] = damage;

                    keywords[SubstEnum.Range] = k.Distance.ToString("0.0");
                    keywords[SubstEnum.Headshot] = k.Headshot ? "Headshot" : "";
                }
                catch (Exception ex)
                {
                    WriteConsole("ProconRulz: recoverable exception in assign_keywords #2");
                    PrintException(ex);
                    return;
                }
            }

            if (trigger == TriggerEnum.PlayerBlock)
            {
                keywords.Add(SubstEnum.BlockedItem, item);
                WriteDebugInfo(String.Format("ProconRulz: test_rule[{0}] is PlayerBlock event for [{1}] OK",
                                    player_name, item));
            }
        }
Exemple #17
0
        public override void OnPlayerSpawned(String soldierName, Inventory spawnedInventory)
        {
            this.DebugWrite("Entering OnPlayerSpawned", 7);
            try {
                if (this._IsEnabled) {
                    if (this._CommandNameDictionary.Count > 0) {
                        //Handle TeamSwap notifications
                        String command = this._CommandKeyDictionary["self_teamswap"].command_text;
                        AdKatsPlayer aPlayer = null;
                        if (this._PlayerDictionary.TryGetValue(soldierName, out aPlayer)) {
                            if (aPlayer.player_aa && !aPlayer.player_aa_told) {
                                this.ExecuteCommand("procon.protected.send", "admin.yell", "For your consistent player reporting you can now use @" + command + ". Type @" + command + " to move yourself between teams.", "10", "player", soldierName);
                                aPlayer.player_aa_told = true;
                            }
                            else {
                                Boolean informed = true;
                                if (this._TeamswapRoundWhitelist.Count > 0 && this._TeamswapRoundWhitelist.TryGetValue(soldierName, out informed)) {
                                    if (informed == false) {
                                        this.ExecuteCommand("procon.protected.send", "admin.yell", "By random selection you can use @" + command + " for this round. Type @" + command + " to move yourself between teams.", "10", "player", soldierName);
                                        this._TeamswapRoundWhitelist[soldierName] = true;
                                    }
                                }
                            }
                        }
                    }

                    //Handle Dev Notifications
                    if (soldierName == "ColColonCleaner" && !_ToldCol) {
                        this.ExecuteCommand("procon.protected.send", "admin.yell", "CONGRATS! This server is running version " + PluginVersion + " of AdKats!", "20", "player", "ColColonCleaner");
                        this._ToldCol = true;
                    }

                    //Update player spawn information
                    if (this._PlayerDictionary.ContainsKey(soldierName)) {
                        lock (this._PlayersMutex) {
                            this._PlayerDictionary[soldierName].lastSpawn = DateTime.UtcNow;
                        }
                    }

                    if (this._ActOnSpawnDictionary.Count > 0) {
                        lock (this._ActOnSpawnDictionary) {
                            AdKatsRecord record = null;
                            if (this._ActOnSpawnDictionary.TryGetValue(soldierName, out record)) {
                                //Remove it from the dic
                                this._ActOnSpawnDictionary.Remove(soldierName);
                                //Wait 1.5 seconds to kill them again
                                Thread.Sleep(1500);
                                //Queue the action
                                this.QueueRecordForActionHandling(record);
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                this.HandleException(new AdKatsException("Error while handling player spawn.", e));
            }
            this.DebugWrite("Exiting OnPlayerSpawned", 7);
        }
Exemple #18
0
        //**********************************************************************************************
        //**********************************************************************************************
        //   CHECK THE RULES to see if we should kill, kick, say
        //**********************************************************************************************
        //**********************************************************************************************
        // here is where we scan the rules after a player has joined, spawned or a kill has occurred
        private void scan_rules(TriggerEnum trigger, string name, 
            Dictionary<SubstEnum, string> keywords,
            Inventory inv, Kill k, string item)
        {
            WriteDebugInfo(String.Format("ProconRulz: Scan_rules[{0}] with Event {1}",
                                name,
                                Enum.GetName(typeof(TriggerEnum), trigger)));

            // don't do anything if rulz_enable has been set to false
            if (!rulz_enable) return;

            // CATCH EXCEPTIONS
            try
            {
                // initial population of the 'keywords' dictionary
                assign_initial_keywords(name, ref keywords);

                // loop through the rules
                foreach (ParsedRule rule in parsed_rules)
                {
                    // skip comments
                    if (rule.comment) continue;

                    if (rule.trigger == trigger)
                    {
                        WriteDebugInfo(String.Format("ProconRulz: scan_rules[{0}] [{1}]",
                            name, rule.unparsed_rule));
                        if (process_rule(trigger, rule, name, ref keywords, inv, k, item))
                        {
                            WriteDebugInfo(String.Format("ProconRulz: scan_rules[{0}] [{1}] FIRED",
                                name, rule.unparsed_rule));
                            break; // break if any rule fires
                        }
                    }
                    // else WriteDebugInfo(String.Format("ProconRulz: scan_rules[{0}] skipped", name));
                } // end looping through the rules
            }
            catch (Exception ex)
            {
                WriteConsole("ProconRulz: recoverable exception in scan_rules");
                PrintException(ex);
            }
        }
        /*
        public void OnPlayerJoin(string strSoldierName) {

        }

        public void OnPlayerLeave(string strSoldierName) {


        }
         * 
        */

        private void m_prcClient_PlayerSpawned(PRoConClient sender, string soldierName, Inventory spawnedInventory) {
            this.InvokeIfRequired(() => {
                this.PropogatingIndexChange = true;

                if (this.Players.ContainsKey(soldierName) == true) {
                    AdditionalPlayerInfo sapiAdditional;

                    if (this.Players[soldierName].Tag != null) {
                        sapiAdditional = (AdditionalPlayerInfo)this.Players[soldierName].Tag;

                        sapiAdditional.SpawnedInventory = spawnedInventory;

                        if (this.Players.ContainsKey(soldierName) == true) {
                            this.Players[soldierName].SubItems["kit"].Text = this.Language.GetLocalized(String.Format("global.Kits.{0}", spawnedInventory.Kit.ToString()));
                        }

                        if (sapiAdditional.Punkbuster != null) {
                            if (this.Main.iglFlags.Images.ContainsKey(sapiAdditional.Punkbuster.PlayerCountryCode + ".png") == true) {
                                this.Players[sapiAdditional.Punkbuster.SoldierName].ImageIndex = this.Main.iglFlags.Images.IndexOfKey(sapiAdditional.Punkbuster.PlayerCountryCode + ".png");
                            }
                        }

                        this.Players[soldierName].Tag = sapiAdditional;
                    }

                    this.RefreshSelectedPlayer();
                }

                //this.ArrangePlayers();

                this.PropogatingIndexChange = false;
            });
        }
Exemple #20
0
        public override void OnPlayerSpawned(String soldierName, Inventory spawnedInventory)
        {
            if (this.isEnabled)
            {
                //Handle teamswap notifications
                Boolean informed = true;
                string command = this.m_strTeamswapCommand;
                if (this.enableAdminAssistants && this.adminAssistantCache.TryGetValue(soldierName, out informed))
                {
                    if (informed == false)
                    {
                        this.ExecuteCommand("procon.protected.send", "admin.yell", "For your consistent player reporting you can now use TeamSwap. Type @" + command + " to move yourself between teams.", "10", "player", soldierName);
                        this.adminAssistantCache[soldierName] = true;
                    }
                }
                else if (this.teamswapRoundWhitelist.Count > 0 && this.teamswapRoundWhitelist.TryGetValue(soldierName, out informed))
                {
                    if (informed == false)
                    {
                        this.ExecuteCommand("procon.protected.send", "admin.yell", "You can use TeamSwap for this round. Type @" + command + " to move yourself between teams.", "10", "player", soldierName);
                        this.teamswapRoundWhitelist[soldierName] = true;
                    }
                }

                //Handle Dev Notifications
                if (soldierName == "ColColonCleaner" && !toldCol)
                {
                    this.ExecuteCommand("procon.protected.send", "admin.yell", "CONGRATS! This server has version " + this.plugin_version + " of AdKats installed!", "20", "player", "ColColonCleaner");
                    this.toldCol = true;
                }

                //Update player spawn information
                if (this.playerDictionary.ContainsKey(soldierName))
                {
                    lock (this.playersMutex)
                    {
                        this.playerDictionary[soldierName].lastSpawn = DateTime.Now;
                    }
                }

                if (this.actOnSpawnDictionary.Count > 0)
                {
                    lock (this.actOnSpawnDictionary)
                    {
                        AdKat_Record record = null;
                        if (this.actOnSpawnDictionary.TryGetValue(soldierName, out record))
                        {
                            //Remove it from the dic
                            this.actOnSpawnDictionary.Remove(soldierName);
                            //Wait two seconds to kill them again
                            Thread.Sleep(1500);
                            //Queue the action
                            this.queueRecordForActionHandling(record);
                        }
                    }
                }
            }
        }
        public override void OnPlayerSpawned(string soldierName, Inventory spawnedInventory)
        {
            // if (serverMode == "private" && !isInWhitelist(soldierName)) kickPlayer(soldierName, msg_pmKick);  // Kick player if not in Whitelist when PRIVATE MODE IS ACTIVE

            players.Add(soldierName);
            WritePluginConsole("Player spawn detected. Playername = " + soldierName, "DEBUG",8);

            if (!spawnedPlayer.Contains(soldierName))
            {
            spawnedPlayer.Add(soldierName);
            if (rules_firstjoin == enumBoolYesNo.Yes) ShowRules(soldierName, true); // Show firstspan server rules

            }
        }