public async Task UseChangeNameItem(GameSession session, ItemUseChangeNickReqMessage message) { var plr = session.Player; var item = plr.Inventory[message.ItemId]; var ascii = Config.Instance.Game.NickRestrictions.AsciiOnly; if (!await AuthService.IsNickAvailableAsync(message.Nickname)) { await plr.Session.SendAsync(new ServerResultAckMessage(ServerResult.NicknameUnavailable)); } if (!Namecheck.IsNameValid(message.Nickname, true) || ascii && message.Nickname.Any(c => c > 127) || !ascii && message.Nickname.Any(c => c > 255)) { await session.SendAsync(new NickCheckAckMessage(true)); return; } var nickname = new NicknameHistoryDto { AccountId = (int)plr.Account.Id, OldName = plr.Account.Nickname, NewNickname = message.Nickname }; switch (item.ItemNumber) { case 4000001: //Perm Change nickname.ExpireDate = -1; if (await ChangeNickname(session.Player, nickname, false)) { plr.Inventory.RemoveOrDecrease(item); } break; default: await session.SendAsync(new ServerResultAckMessage(ServerResult.FailedToRequestTask)); return; } }
public async Task ChangeNickHandler(GameSession session, ItemUseChangeNickReqMessage message) { session.SendAsync(new ItemUseChangeNickAckMessage { Result = 1, Unk2 = 0, Unk3 = session.Player.Account.Nickname }); }