Exemplo n.º 1
0
        public static void GiveMoney(uint howMuch, NetworkUser offender = null)
        {
            if (offender == null)
            {
                return;
            }

            if (_player == null)
            {
                var logAct = new Console.Log {
                    message = "No-one to give money to!"
                };
                Console.HandleLog(logAct.message, logAct.stackTrace, logAct.logType);
                return;
            }
            var log = new Console.Log {
                message = offender != null
                    ? $"Giving {howMuch} currency to {offender.userName}!"
                    : $"Giving {howMuch} currency to anon :o "
            };

            Console.HandleLog(log.message, log.stackTrace, log.logType);

            _player.GiveMoney(howMuch);
        }
Exemplo n.º 2
0
        public static void GiveXp(uint howMuch, NetworkUser offender = null)
        {
            if (offender == null)
            {
                return;
            }
            if (_player == null)
            {
                var logAct = new Console.Log {
                    message = "No-one to give xp to!"
                };
                Console.logs.Add(logAct);
                return;
            }
            var log = new Console.Log {
                message = $"Giving {howMuch} xp to {offender.userName}!"
            };

            Console.logs.Add(log);
            _player.GiveExperience(howMuch);
        }
Exemplo n.º 3
0
 private void HandleMacroLog(Console.Log log)
 {
     _consoleOutput += log.message + "\n";
 }
Exemplo n.º 4
0
        private static void ChatOnChatChanged(Console.Log log)
        {
            string cmd = log.message;

            Debug(cmd);

            if (!GetDisplayNameFromLine(cmd, out string name))
            {
                Debug("Unable to find name from command");
                return;
            }

            Debug("Fetching local player");
            string localPlayerName = UnityUtils.GetLocalNetworkUserName();

            Debug($"Local Player: {localPlayerName}, invoker: {name}");
            if (!localPlayerName.Equals(name))
            {
                return;
            }

            if (cmd.Contains("ChatChanged"))
            {
                return;
            }

            while (cmd.Contains("<noparse>"))
            {
                cmd = cmd.Replace("<noparse>", "");
            }

            while (cmd.Contains("</noparse>"))
            {
                cmd = cmd.Replace("</noparse>", "");
            }

            if (!cmd.Contains("/"))
            {
                return;
            }

            cmd = cmd.Split('/')[1];

            while (cmd.Contains("<"))
            {
                cmd = cmd.Replace("<", "");
            }

            while (cmd.Contains(">"))
            {
                cmd = cmd.Replace(">", "");
            }

            if (cmd.Equals(_lastCmd, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            Mod.Logger.Log($"[ChatChanged] [{log.logType}] {cmd} (LastCmd: {_lastCmd}");
            Debug(cmd);

            _lastCmd = cmd;
            _timeout = .5f;

            CmdHandler.InvokeCommand(cmd);
        }