Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 9th Sep 2024 at 9:56 AM
Default Show notification at specific skill level
Hi! I am currently making a few custom interactions which require a certain skill level. They only appear when the Sim reaches that skill level, which works fine.

But it would be nice if I could get a notification to show up (in the top right corner), similar to the notifications that appear when you reach a skill level. Basically, in my code, I want a line of code to get executed (the notification showing up) whenever a Sim reaches a certain skill level of a particular skill.

How could I do this? Maybe I need an event listener or something, which gets triggered when a Sim increases their skill to a specific level?

Thanks in advance
Advertisement
Trainee Moderator
staff: trainee moderator
#2 Old 13th Sep 2024 at 10:18 PM
There is an EventTracker class, from there, you can add listeners to specific events. Skill level up is one of these events.
Code:
static void OnWorldLoadFinished(object sender, EventArgs e)
{
    EventTracker.AddListener(EventTypeId.kSkillLevelUp, OnSkillLevelUp); //Keep this in this method as the listeners are cleared when a world is loaded.
}

static ListenerAction OnSkillLevelUp(Event @event)
{
    HasGuidEvent<SkillNames> skillLevelUpEvent = @event as HasGuidEvent<SkillNames>; //Check the Skill.SkillLeveledUp method. It sends an event when someone levels up in a skill.
    //Below I make some other conversions for you:
    Sim sim = skillLevelUpEvent.Actor as Sim; //@event.Actor is also valid for this one.
    Skill skill = skillLevelUpEvent.HasGuidObject as Skill;
    //The rest is up to your logic. Check the Skill class for things such as new level, skill name, etc.
    return ListenerAction.Keep; //ListenerAction.Keep to keep, ListenerAction.Remove to remove the listener.
}
Test Subject
Original Poster
#3 Old 14th Sep 2024 at 8:08 AM
Thank you this is exactly what I needed!
Back to top