Why would u have to add the Messages as Method to the init? Because it's not loaded separately.
Code:
public void Initialize(MapInstance currentMapInstance)
{
MapInstance = currentMapInstance; <---
Initialize(); <---
Messages(); // ??
}
oh and actually. Your Method won't work as it's supposed to do.
Code:
private void Messages()
{
Observable.Interval(TimeSpan.FromSeconds(5)).Subscribe(onNext: s =>
{
if (MapNpcId == 20003)
{
MapInstance.Broadcast($"say 2 {MapNpcId} 0 ");
//This won't be spammed every 5 seconds. It will be spammed the whole time so the packet won't stop.
}
});
}
Well, your code isn't bad. Well not that bad. But still it's no method to prefer. U should also don't check with if on MapNpcId == . Just add a simple if to ask for db-content. Example method is to add a second method on sending the packet, and give the MapNpc.cs only the task to send the message.
1. Task > SendPacket + Delay
2. Task > LoadByDb
just 2 rows in the MapNpc DB [NpcSay NpcSayDelay]