RAGE.Events.Add

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

Syntax

void RAGE.Events.Add(string eventname, Method handler);

Required Arguments

  • args: object[];

Add Custom Events

C# Syntax
C.png

Parameters

  • args:: Object Array;

Example

mp.events.add("consoleCommand", (command) => { mp.console.logInfo('Hello World'); });

//Constructor
public main()
{
   //Create the custom event
   RAGE.Events.Add("sendhelloworld", SendHelloWorld);
}

//Method for the custom event
private void SendHelloWorld(object[] args)
{
    Chat.Output("HELLO WORLD!");
}


CEF Example

C# Syntax
C.png

Parameters

  • args:: Object Array

Example

mp.events.add("consoleCommand", (command) => { mp.console.logInfo('Hello World'); });

//In jQuery file linked to your CEF.
$(document).ready(function()
{
    $("#cbutton").click(() =>
    {
        //Create a client-side event trigger
        mp.trigger("sendhelloworld", args);
    });
});

//In C# Client Side File
//Constructor
public main()
{
   //Once this custom event has been added you can also call it from CEF(Chromium Embedded Framework)
   RAGE.Events.Add("sendhelloworld", SendHelloWorld);
}

public void SendHelloWorld(object[] args)
{
    Chat.Output("HELLO WORLD!");
}