RAGE.Events.Add: Difference between revisions
Crossy1998 (talk | contribs) m (→Example) |
Crossy1998 (talk | contribs) |
||
| (18 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== | ==Syntax== | ||
<pre>void RAGE.Events.Add(string eventname, Method handler);</pre> | |||
=== Required Arguments === | |||
*'''args:''' object[]; | |||
==Add Custom Events== | |||
{{CSharpContainer| | {{CSharpContainer| | ||
{{Parameters}} | {{Parameters}} | ||
*'''args:''': Object Array | *'''args:''': Object Array; | ||
{{Example}} | {{Example}} | ||
| Line 10: | Line 16: | ||
public main() | public main() | ||
{ | { | ||
// | //Create the custom event | ||
RAGE.Events.Add("sendhelloworld", SendHelloWorld); | RAGE.Events.Add("sendhelloworld", SendHelloWorld); | ||
} | } | ||
//Method for the custom event | |||
private void SendHelloWorld(object[] args) | |||
{ | { | ||
Chat.Output("HELLO WORLD!"); | Chat.Output("HELLO WORLD!"); | ||
| Line 30: | Line 37: | ||
<syntaxhighlight lang="C#"> | <syntaxhighlight lang="C#"> | ||
//In jQuery file | //In jQuery file linked to your CEF. | ||
$(document).ready(function() | $(document).ready(function() | ||
{ | { | ||
$("#cbutton").click(() => | $("#cbutton").click(() => | ||
{ | { | ||
//Create a client-side event trigger | |||
mp.trigger("sendhelloworld", args); | mp.trigger("sendhelloworld", args); | ||
}); | }); | ||
}); | }); | ||
//In C# Client Side File | |||
//Constructor | //Constructor | ||
public main() | public main() | ||
Latest revision as of 03:46, 27 March 2019
Syntax
void RAGE.Events.Add(string eventname, Method handler);
Required Arguments
- args: object[];
Add Custom Events
C# Syntax
Parameters
- args:: Object Array;
Example
//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
Parameters
- args:: Object Array
Example
//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!");
}