コード例 #1
0
 //Chat hook system
 public override bool ChatMessage(ClientInfo _cInfo, EnumGameMessages _type, string _message, string _playerName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     if (_message.ToLower().Equals("nightmare"))
     {
         Nightmare.SpawnNightmareOnPlayer(_cInfo);
         return(false);
     }
     return(true);
 }
コード例 #2
0
ファイル: API.cs プロジェクト: 7DaysToMod/src_7dtmlib
        public override bool ChatMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
        {
            if (API.Events.hasChatHandlers || _chatCommands.Count > 0)
            {
                if (_type == EnumGameMessages.Chat)
                {
                    if (_msg.Substring(0, 1) == "!")
                    {
                        string[]      cmdParts    = SplitArguments(_msg);
                        string        cmd         = cmdParts [0].Replace("!", "");
                        string        paramString = "";
                        List <string> cmdParams   = new List <string> ();

                        if (cmdParts.Length > 1)
                        {
                            for (int i = 1; i < cmdParts.Length; i++)
                            {
                                cmdParams.Add(cmdParts [i]);
                                paramString += cmdParts [i];
                                if (i <= cmdParts.Length - 1)
                                {
                                    paramString += " ";
                                }
                            }
                        }

                        if (_chatCommands.ContainsKey(cmd))
                        {
                            _chatCommands [cmd].Execute(cmdParams, _cInfo);
                        }
                        API.Events.NotifyChatCommandHandlers(_cInfo, cmd, paramString);
                        return(false);
                    }
                }
            }

            if (API.Events.hasPlayerKilledHandlers)
            {
                if (_type == EnumGameMessages.EntityWasKilled)
                {
                    EntityPlayer killedPlayer = PlayerUtils.GetEntityPlayer(_mainName);
                    EntityPlayer killerPlayer = PlayerUtils.GetEntityPlayer(_secondaryName);

                    if (killerPlayer == null)
                    {
                        OnPlayerDied(killedPlayer);
                    }
                    else
                    {
                        OnPlayerKilledPlayer(killedPlayer, killerPlayer);
                    }
                }
            }

            return(true);
        }
コード例 #3
0
        /**
         * Executed when a game event occurs
         */
        private bool GameMessage(
            ClientInfo clientInfo,
            EnumGameMessages enumGameMessages,
            string message,
            string mainName,
            bool localizeMain,
            string secondaryName,
            bool localizeSecondary
            )
        {
            _eventHooks.HookPlayer(clientInfo, enumGameMessages, message, mainName, localizeMain, secondaryName, localizeSecondary);

            return(true);
        }
コード例 #4
0
ファイル: Api.cs プロジェクト: pharrisee/7dtd-ServerTools
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_cInfo != null && _type == EnumGameMessages.EntityWasKilled)
         {
             EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
             if (player != null)
             {
                 if (KillNotice.IsEnabled && (KillNotice.Zombie_Kills || KillNotice.Animal_Kills) && string.IsNullOrEmpty(_secondaryName))
                 {
                     if (KillNotice.Damage.ContainsKey(player.entityId))
                     {
                         KillNotice.Damage.TryGetValue(player.entityId, out int[] damage);
                         EntityZombie zombie = PersistentOperations.GetZombie(damage[0]);
                         if (zombie != null)
                         {
                             KillNotice.ZombieKilledPlayer(zombie, player, _cInfo, damage[1]);
                         }
                         else
                         {
                             EntityAnimal animal = PersistentOperations.GetAnimal(damage[0]);
                             if (animal != null)
                             {
                                 KillNotice.AnimalKilledPlayer(animal, player, _cInfo, damage[1]);
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}", e.Message));
     }
     return(true);
 }
コード例 #5
0
ファイル: Api.cs プロジェクト: kingfahad777/7DTD-ScriptingMod
        /// <summary>
        /// Called for every chat message, including messages about Joins, Leaves, Died, Killed, etc.
        /// </summary>
        /// <returns>true if chat message can be processed further, false if it should be suppressed</returns>
        public override bool ChatMessage(ClientInfo clientInfo, EnumGameMessages messageType, string message, string mainName, bool localizeMain, string secondaryName, bool localizeSecondary)
        {
            try
            {
                Log.Debug("Api.ChatMessage called.");
                var args = new ChatMessageEventArgs()
                {
                    messageType = messageType.ToString(),
                    from        = mainName,
                    message     = message,
                    clientInfo  = clientInfo,
                };

                CommandTools.InvokeScriptEvents(ScriptEvent.chatMessage, () => args);

                return(!args.isPropagationStopped);
            }
            catch (Exception ex)
            {
                CommandTools.HandleEventException(ex);
                return(false);
            }
        }
コード例 #6
0
 public void HookPlayer(
     ClientInfo clientInfo,
     EnumGameMessages enumGameMessages,
     string message,
     string mainName,
     bool localizeMain,
     string secondaryName,
     bool localizeSecondary
     )
 {
     _httpTool.Post(new NameValueCollection()
     {
         ClientInfoAsNameValueCollection(clientInfo),
         HookTypeNameValueCollection(EnumHookType.Player),
         { "MessageType", enumGameMessages.ToString() },
         { "Message", message ?? string.Empty },
         { "MainName", mainName ?? string.Empty },
         { "LocalizeMain", localizeMain.ToString() },
         { "SecondaryName", secondaryName ?? string.Empty },
         { "LocalizeSecondary", localizeSecondary.ToString() },
     }
                    );
 }
コード例 #7
0
ファイル: API.cs プロジェクト: dcsobral/ModBase
 public override bool ChatMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     //return true to pass the message on to the next mod, or if no other mods then it will output to chat.
     //return false to prevent the message from being passed on or output to chat
     return(true);
 }
コード例 #8
0
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null)
         {
             EntityPlayer _player1 = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player1 != null)
             {
                 bool _notice = false;
                 if (!string.IsNullOrEmpty(_secondaryName) && _mainName != _secondaryName)
                 {
                     ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName);
                     if (_cInfo2 != null)
                     {
                         EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                         if (_player2 != null)
                         {
                             if (KillNotice.IsEnabled && _player2.IsAlive())
                             {
                                 string _holdingItem = _player2.inventory.holdingItem.Name;
                                 if (!string.IsNullOrEmpty(_holdingItem))
                                 {
                                     ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true);
                                     if (_itemValue.type != ItemValue.None.type)
                                     {
                                         _holdingItem = _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName();
                                         KillNotice.Notice(_cInfo, _cInfo2, _holdingItem);
                                         _notice = true;
                                     }
                                 }
                             }
                             if (Zones.IsEnabled)
                             {
                                 Zones.Check(_cInfo, _cInfo2);
                             }
                             if (Bounties.IsEnabled)
                             {
                                 Bounties.PlayerKilled(_player1, _player2, _cInfo, _cInfo2);
                             }
                             if (Wallet.IsEnabled)
                             {
                                 if (Wallet.PVP && Wallet.Player_Kills > 0)
                                 {
                                     Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                                 else if (Wallet.Player_Kills > 0)
                                 {
                                     Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                             }
                         }
                     }
                 }
                 if (DeathSpot.IsEnabled)
                 {
                     DeathSpot.PlayerKilled(_player1);
                 }
                 if (Event.Open && Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                 {
                     string _sql = string.Format("UPDATE Players SET eventReturn = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql, "Players");
                 }
                 if (_notice)
                 {
                     return(false);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}.", e.Message));
     }
     return(true);
 }
コード例 #9
0
ファイル: Api.cs プロジェクト: usnail/7dtd-ServerTools
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 if (DeathSpot.IsEnabled)
                 {
                     DeathSpot.PlayerKilled(_player);
                 }
                 if (!string.IsNullOrEmpty(_secondaryName) && !string.IsNullOrEmpty(_mainName) && _mainName != _secondaryName)
                 {
                     ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName);
                     if (_cInfo2 != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo2.entityId))
                     {
                         EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                         if (_player2 != null)
                         {
                             if (Bounties.IsEnabled)
                             {
                                 Bounties.PlayerKilled(_player, _player2, _cInfo, _cInfo2);
                             }
                             if (Wallet.IsEnabled)
                             {
                                 if (Wallet.PVP && Wallet.Player_Kills > 0)
                                 {
                                     Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                                 else if (Wallet.Player_Kills > 0)
                                 {
                                     Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                             }
                             if (KillNotice.IsEnabled && _player2.IsAlive())
                             {
                                 string _holdingItem = _player2.inventory.holdingItem.Name;
                                 if (!string.IsNullOrEmpty(_holdingItem))
                                 {
                                     ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true);
                                     if (_itemValue.type != ItemValue.None.type)
                                     {
                                         _holdingItem = _itemValue.ItemClass.GetItemName();
                                         KillNotice.Exec(_cInfo, _player, _cInfo2, _player2, _holdingItem);
                                         return(false);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}", e.Message));
     }
     return(true);
 }
コード例 #10
0
 public override bool ChatMessage(ClientInfo _cInfo, EnumGameMessages _type, string _message, string _playerName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     return(ChatHook.Hook(_cInfo, _message, _playerName, _secondaryName, _localizeSecondary));
 }
コード例 #11
0
ファイル: Api.cs プロジェクト: Tsaukpaetra/7dtd-ServerTools
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 if (PlayerChecks.FlyEnabled && PlayerChecks.Movement.ContainsKey(_cInfo.entityId))
                 {
                     PlayerChecks.Movement.Remove(_cInfo.entityId);
                 }
                 if (Died.IsEnabled)
                 {
                     Died.PlayerKilled(_player);
                 }
                 if (KillNotice.IsEnabled)
                 {
                     if (KillNotice.Zombie_Kills && string.IsNullOrEmpty(_secondaryName))
                     {
                         List <Entity> Entities = GameManager.Instance.World.Entities.list;
                         for (int i = 0; i < Entities.Count; i++)
                         {
                             EntityAlive _entityAlive = Entities[i] as EntityAlive;
                             if (_entityAlive != null && _entityAlive.GetAttackTarget() == _player && _entityAlive.entityId != _player.entityId)
                             {
                                 if (KillNotice.Show_Level)
                                 {
                                     Phrases.Dict.TryGetValue(545, out string _phrase545);
                                     _phrase545 = _phrase545.Replace("{PlayerName}", _cInfo.playerName);
                                     _phrase545 = _phrase545.Replace("{Level}", _player.Progression.Level.ToString());
                                     _phrase545 = _phrase545.Replace("{ZombieName}", _entityAlive.EntityName);
                                     ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase545 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                                 }
                                 else
                                 {
                                     Phrases.Dict.TryGetValue(546, out string _phrase546);
                                     _phrase546 = _phrase546.Replace("{PlayerName}", _cInfo.playerName);
                                     _phrase546 = _phrase546.Replace("{ZombieName}", _entityAlive.EntityName);
                                     ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase546 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                                 }
                             }
                         }
                     }
                     else if (KillNotice.PvP && !string.IsNullOrEmpty(_secondaryName) && _mainName != _secondaryName)
                     {
                         ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName);
                         if (_cInfo2 != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo2.entityId))
                         {
                             EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                             if (_player2 != null)
                             {
                                 if (KillNotice.IsEnabled && _player2.IsAlive())
                                 {
                                     string _holdingItem = _player2.inventory.holdingItem.GetItemName();
                                     if (!string.IsNullOrEmpty(_holdingItem))
                                     {
                                         ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true);
                                         if (_itemValue.type != ItemValue.None.type)
                                         {
                                             KillNotice.Exec(_cInfo, _player, _cInfo2, _player2, _holdingItem);
                                             return(false);
                                         }
                                     }
                                 }
                                 if (Wallet.IsEnabled)
                                 {
                                     if (Wallet.PVP && Wallet.Player_Kills > 0)
                                     {
                                         Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                     }
                                     else if (Wallet.Player_Kills > 0)
                                     {
                                         Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                     }
                                 }
                                 if (Bounties.IsEnabled)
                                 {
                                     Bounties.PlayerKilled(_player, _player2, _cInfo, _cInfo2);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}", e.Message));
     }
     return(true);
 }
コード例 #12
0
ファイル: Api.cs プロジェクト: dmustanger/7dtd-ServerTools
 public override bool ChatMessage(ClientInfo _cInfo, EnumGameMessages _type, string _message, string _playerName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     return ChatHook.Hook(_cInfo, _message, _playerName, _secondaryName, _localizeSecondary);
 }
コード例 #13
0
        public static bool Hook(ClientInfo _cInfo, EnumGameMessages _type, string _message, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
        {
            if (!string.IsNullOrEmpty(_message))
            {
                // player message
                if (_message.EndsWith(BBFILTER + BBFILTER))
                {
                    _message = _message.Remove(_message.Length - 2 * BBFILTER.Length);
                }

                // server message
                if (_message.EndsWith(BBFILTER))
                {
                    _message = _message.Remove(_message.Length - BBFILTER.Length);
                }

                if (_message.ToLower() == "/day7")
                {
                    int currentDay    = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
                    int currentHour   = GameUtils.WorldTimeToHours(GameManager.Instance.World.worldTime);
                    int currentMinute = GameUtils.WorldTimeToMinutes(GameManager.Instance.World.worldTime);

                    int dayLength = GameStats.GetInt(EnumGameStats.DayLightLength);

                    // determine if we are within the horde period for day 7
                    Boolean IsInDay7 = false;
                    if (currentDay >= 7)
                    {
                        if (currentDay % 7 == 0 && currentHour >= 22)
                        {
                            IsInDay7 = true;
                        }
                        // day 8 before 4 AM (assuming default day length of 18)
                        else if (currentDay % 8 == 0 && currentHour < 24 - dayLength - 2)
                        {
                            IsInDay7 = true;
                        }
                    }

                    // not in day 7 horde period
                    if (!IsInDay7)
                    {
                        // find the next day 7, duh.
                        int daysUntilHorde = 0;

                        if (currentDay % 7 != 0)
                        {
                            daysUntilHorde = 7 - (currentDay % 7);
                        }

                        // when the next horde spawns
                        ulong nextHordeTime = GameUtils.DayTimeToWorldTime(currentDay + daysUntilHorde, 22, 0);

                        ulong timeUntilHorde = nextHordeTime - GameManager.Instance.World.worldTime;

                        int hourUntilHorde    = GameUtils.WorldTimeToHours(timeUntilHorde);
                        int minutesUntilHorde = GameUtils.WorldTimeToMinutes(timeUntilHorde);

                        // green
                        String color = "00ba67";
                        if (daysUntilHorde < 3)
                        {
                            // red
                            color = "ff0000";
                        }
                        else if (daysUntilHorde < 5)
                        {
                            // yellow
                            color = "fafc57";
                        }

                        String response = String.Format("[{0}]Next horde in {1} days, {2} hours, {3} minutes. Prepare![-]", color, daysUntilHorde, hourUntilHorde, minutesUntilHorde);
                        if (_cInfo != null)
                        {
                            _cInfo.SendPackage(new NetPackageGameMessage(_type, response, _mainName, _localizeMain, _secondaryName, _localizeSecondary));
                        }
                        else
                        {
                            Log.Out(response);
                        }
                    }
                    else
                    {
                        String response = String.Format("[ff0000]Day 7 Horde is now![-]");
                        if (_cInfo != null)
                        {
                            _cInfo.SendPackage(new NetPackageGameMessage(_type, response, _mainName, _localizeMain, _secondaryName, _localizeSecondary));
                        }
                        else
                        {
                            Log.Out(response);
                        }
                    }
                }
            }

            return(true);
        }