I called it events cuz i mean things like Blessing, OfflineTG, Expball, Dayly Quests and many others....
well it's very simple and easy to understand. First create this class at any place of the current source you're using (i'm using a custom one self maked so i can`t give any example... sorry)
Code:
public class Event_State
{
public string Event_Name;
public uint Event_Count;
public Event_Type Type;
public DateTime End;
}
Code:
public enum Event_Type : byte
{
ExpBall = 1,
PowerExpBall = 2,
Exterminator = 3,
Blessing = 4,
UnknownMan = 5,
OfflineTG = 6,
Enlight = 7,
Enlight_Points = 8,
}
Code:
public class Events
{
uint __Owner = 0;
Character Owner { get { return Server.Pool[__Owner]; } }
public Dictionary<string, Event_State> Values;
public Dictionary<string, Event_State> LoadValues;
public Events(uint _Owner)
{
Values = new Dictionary<string, Event_State>();
LoadValues = new Dictionary<string, Event_State>();
__Owner = _Owner;
}
public void AppendEvent(Event_State Event)
{
if (!Values.ContainsKey(Event.Event_Name))
Values.Add(Event.Event_Name, Event);
else
{
Values[Event.Event_Name] = Event;
Database.DeleteEvent(__Owner, Event.Event_Name);
}
switch (Event.Type)
{
case Event_Type.Blessing:
Owner.AddFlag(Struct.StatusEffect.Blessed);
Owner.Update_Type2(Struct.StatusTypes.BlessTimer, (uint)(Event.End - DateTime.Now).TotalSeconds);
Owner.Update_Type2(Struct.StatusTypes.OnlineTraining, 0);
Database.CreateEvent(Event, __Owner);
break;
case Event_Type.ExpBall:
case Event_Type.Enlight:
case Event_Type.OfflineTG:
case Event_Type.UnknownMan:
Database.CreateEvent(Event, __Owner);
break;
}
}
public void AppendRemoveEvent(Event_State Event)
{
if (Values.ContainsKey(Event.Event_Name))
Values.Remove(Event.Event_Name);
switch (Event.Type)
{
case Event_Type.Blessing:
Owner.RemoveFlag(Struct.StatusEffect.Blessed);
Owner.Update_Type2(Struct.StatusTypes.BlessTimer, (uint)(Event.End - DateTime.Now).TotalSeconds);
Owner.Update_Type2(Struct.StatusTypes.OnlineTraining, 0);
Database.DeleteEvent(__Owner, Event.Event_Name);
break;
case Event_Type.Enlight:
case Event_Type.OfflineTG:
case Event_Type.ExpBall:
case Event_Type.UnknownMan:
Database.DeleteEvent(__Owner, Event.Event_Name);
break;
}
}
public void AppendLoad()
{
foreach (Event_State Event in LoadValues.Values)
{
if (!Values.ContainsKey(Event.Event_Name))
Values.Add(Event.Event_Name, Event);
switch (Event.Type)
{
case Event_Type.Blessing:
Owner.Update_Type2(Struct.StatusTypes.BlessTimer, (uint)(Event.End - DateTime.Now).TotalSeconds);
Owner.Update_Type2(Struct.StatusTypes.OnlineTraining, 0);
break;
case Event_Type.Enlight:
case Event_Type.ExpBall:
case Event_Type.UnknownMan:
if (DateTime.Now.Ticks > Event.End.Ticks)
AppendRemoveEvent(Event);
break;
case Event_Type.OfflineTG://do nothing
break;
}
}
LoadValues.Clear();
LoadValues = null;
}
}
I let some of the codes used by me inside... so you could use as an example...
let me explain a simple way to use it. first you name the event like do you want... Blessing, Expball or whatever....
then use a type for something you want (i'm not using it yet so far... but it is there for future uses)
the eventcount is for example, the expballs use today, for blessing the event duration in seconds or minutes (i'm using in seconds this case)...
The Event End you can use or for mark when the event begin or when you want it to end...
for expballs i use this way:
End = DateTime.Now.AddHours(24 - DateTime.Now.Hour);// that way you can use it at the next day right before 1 AM...
well... its not a big release but should help some ppl >D
Cya... any question just post here :P
Obs.: For who think its unusefull... rembember when u create for blessing, luckytime and others a field at db and a variable? that way you can use a class and just add new events
Sorry for the english... and good luck!






