/
NLObP
/
AAEmu
Обзор
Документация
Войти
/
NLObP
/
AAEmu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
AAEmu.Game/Scripts/Commands/Snow.cs
55 строк
2 KB
Roger Barreto
Collection expressions check + blank lines update (#1110)
11 дек 2024, 19:38
Не верифицирован
11 дек 2024, 19:38
0ce5643
Код
Авторство
О чём код?
using AAEmu.Game.Core.Managers; using AAEmu.Game.Core.Managers.World; using AAEmu.Game.Models.Game; using AAEmu.Game.Models.Game.Char; using AAEmu.Game.Core.Packets.G2C; using AAEmu.Game.Utils.Scripts; namespace AAEmu.Game.Scripts.Commands; public class Snow : ICommand { public string[] CommandNames { get; set; } = ["snow"]; public void OnLoad() { CommandManager.Instance.Register(CommandNames, this); } public string GetCommandLineHelp() { return "<true||false>"; } public string GetCommandHelpText() { return "Enables or disables snow effect across the server"; } public void Execute(Character character, string[] args, IMessageOutput messageOutput) { // If no argument is provided send usage information if (args.Length == 0) { CommandManager.SendDefaultHelpText(this, messageOutput); return; } // determine if we received true,false or something else if (bool.TryParse(args[0], out var isSnowing)) { // Set Snowing state to user input, This will // Enable Snow on all players who log into the server WorldManager.Instance.IsSnowing = isSnowing; // Turn snow on or off for all online characters, // Put this on the script level, so it only gets executed once when GM enables/disables snow WorldManager.Instance.BroadcastPacketToServer(new SCOnOffSnowPacket(isSnowing)); } else { // user input was invalid notify them CommandManager.SendErrorText(this, messageOutput, $"Error parsing boolean"); } } }