Skip to content

SuperPyroManiac/ExampleEvents

Repository files navigation

SuperEvents API Guide

By SuperPyroManiac

This will help you understand and use the API to easily create your own events! Keep in mind, you may not re-distrubute SuperEvents. People must download the main plugin from my LSPDFR page. https://www.lcpdfr.com/downloads/gta5mods/scripts/24437-superevents/


Requirements

  • Basic C# experience.
  • A .NET Framework project that is using the LSPDFR API.
  • References to RageNativeUI, SuperEvents, and LSPDFR.
  • Experience making callouts for LSPDFR will make this very easy to use as well.

Creating the Event class.

Your class will inherit from the AmbientEvent class. Similar to how callouts inherit from the Callout class in LSPDFR.

public class EventExample : AmbientEvent


Main Overriding methods

You will override a few methods to create the events. At minimum of 3. There are 6 methods in total you can override.
OnStartEvent(), OnProcess(), OnCleanup(), Interactions(UIMenu, UIMenuItem, int), Conversations(UIMenu, UIMenuItem, int)
Example of all overrides

OnStartEvent()

This is the first method that is executed. This is where you should setup the event. There are a couple of requirements here to ensure the event works correctly.

These are required!

  • Vector3 EventLocation: Must be set, this is the spawn location of the event! This value is where SuperEvents will check distances, and add the blip if it's enabled in the SuperEvents.ini file.

These are optional!

  • Int OnSceneDistance: Optional value for the OnScene trigger. Defaults to 20.
  • EntityList EntitiesToClear: All vehicles, peds, and other entities related to the event must be added to this list via EntitiesToClear.Add(entity). It's critical that this is done as this is how SuperEvents will clean up entities when the event ends. It also helps SuperEvents clean up if the event crashes.
  • BlipList BlipsToClear: This is where all blips you create should be added, similar to the other list. It's unlikely you will need this as SuperEvents will create a blip automatically if it's enabled in the config. Regardless this list exists just incase you need other blips.

Example Usage

Process()

This is executed after the OnStartEvent() method. This runs in a loop! This will run until the event is ended.
Example

OnCleanup()

This is executed from End(bool). It is automatically done if SuperEvents detects an error, or if the player is too far from the event. Other then that, the event will not end unless they player ends it via keybind or SE menu, or if you add an End(bool) in your code. The bool is for deciding on how to cleanup the scene.

  • End(false) Standard way of ending an event. This will dismiss all entities in the EntitiesToClear list, and delete all blips in the list.
  • End(true) Non-standard way of ending an event. This will forcefully delete all items related to the event and try to move on. This should only be used in the case of errors.

    The End(bool) method doesn't need to be overridden in almost all cases, as adding your items to the correct lists will handle everything behind the scenes. Even the RageNativeUI related items are handled in the base class. And ideal event does not override this method. If you use End() without an argumnt, it will default to false.

Example



These three methods alone can handle all simple events. There are two other methods which can be used for RageNativeUI objects for dialogue or actions, and a third override for OnScene(). There is a good example of them being used in the Fight.cs class in the Events directory.

Registering Events

You will need to register all events in your main.cs class at runtime. It's very simple to do, just use the EventManager.RegisterEvent(typeof(EventClass)) by default the priority on events in normal. There are 3 priorities you can choose from, Low, Normal, High. To assign a priority, when you register the event you can add a second arg. Example: API.RegisterEvent(typeof(Fight), API.Priority.High) Example



Other Override Methods

OnScene()

This method is called once during the OnProcess() loop when the player is < OnSceneDistance. This exists just to save the hassle of having an onScene bool in the Proccess method.>
Example

RageNativeUI Overrides

These two methods are the events for the menus. Interactions is the main SuperEvents Y menu, ConvoMenu is the conversation menu when you hit "Speak with subjects." These are both optional and not required, they are only there if you want to add your own RageNativeUI buttons for your events. Example

About

An example of the SuperEvents API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages