/// <summary> /// Add new user by console or remote /// </summary> /// <param name="name"></param> /// <param name="password"></param> /// <param name="roomname"></param> /// <param name="level"></param> public static void Add(string name, string password, string roomname, ACCOUNT_LEVEL level) { Account account = Get(name); if (account != null) { Log.Message(LogTypes.Warning, $"Account '{name}' already exists."); } else { Room room = RoomManager.Get(roomname); if (room == null) { Log.Message(LogTypes.Panic, $"Room '{roomname}' not exists."); } else { account = new Account(name, password, room, level, true); if (!_accounts.TryAdd(name, account)) { Log.Message(LogTypes.Panic, $"Impossible to add account '{name}'"); } } } }
private static void SetPrivileges(User user, params string[] args) { if (args.Length < 2) { return; } Account account = AccountManager.Get(args[0]); if (account == null) { SendTo(user, "Account not exists."); } else if (user != null && account == user.Account) { SendTo(user, "Cannot change your account privileges."); } else { if (!int.TryParse(args[1], out int level) || level < 0 || level > 2) { SendTo(user, "Wrong data inserted."); } else { ACCOUNT_LEVEL acclevel = (ACCOUNT_LEVEL)level; account.AccountLevel = acclevel; SendTo(user, $"New privileges setted right: {account.Name} - {acclevel}"); } } }
public PLoginResponse(ACCOUNT_LEVEL level, string name) : base(0x1F) { WriteByte(1); WriteByte((byte)level); WriteByte((byte)name.Length); WriteASCII(name); WriteByte(Core.Protocol); }
public Account(string name, string password, Room room, ACCOUNT_LEVEL level, bool enabled) { Name = name; CryptPassword(password); Guid = GuidGenerator.GenerateNew(); AccountLevel = level; IsKicked = false; IsBanned = !enabled; Room = room; }