feat: Converts OnLogin to a coded generated event (#2070)
This commit is contained in:
parent
3b698de556
commit
66a257ece2
25 changed files with 127 additions and 122 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Accounting.Security;
|
||||
using Server.Misc;
|
||||
|
|
@ -768,31 +769,24 @@ public partial class Account : IAccount, IComparable<Account>
|
|||
acc.TotalGameTime += Core.Now - pm.SessionStart;
|
||||
}
|
||||
|
||||
public static void OnLogin(Mobile m)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
|
||||
public static void OnLogin(PlayerMobile pm)
|
||||
{
|
||||
if (m is not PlayerMobile pm)
|
||||
if (pm.Account is not Account acc || !pm.Young || !acc.Young)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.Account is not Account acc)
|
||||
var ts = YoungDuration - acc.TotalGameTime;
|
||||
var hours = Math.Max((int)ts.TotalHours, 0);
|
||||
|
||||
if (hours == 1)
|
||||
{
|
||||
return;
|
||||
pm.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hour.");
|
||||
}
|
||||
|
||||
if (pm.Young && acc.Young)
|
||||
else
|
||||
{
|
||||
var ts = YoungDuration - acc.TotalGameTime;
|
||||
var hours = Math.Max((int)ts.TotalHours, 0);
|
||||
|
||||
if (hours == 1)
|
||||
{
|
||||
m.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hour.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hours.");
|
||||
}
|
||||
pm.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hours.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue