Want to improve the docs? Take a look at scripting-api-data!
Found a bug? jc3mp/bugs is a good place to let us know.
The EventSystem is used to communicate between client packages and to the server.
This class does not have any properties.
Adds an event handler
returns: EventInstance
Name | Type | Description |
---|---|---|
name | string | the event name |
handler | function | the function to execute when the event is called |
jcmp.events.Add('MyEvent', () => {
console.log('hello world!');
});
Calls an Event.
This function always returns an array with all return values from all event handlers for that name.
returns: Array
Name | Type | Description |
---|---|---|
name | string | event name |
...args | any | optional event arguments |
jcmp.events.Add('MyEvent', (x = 1) => {
console.log(`the value of x is ${x}`);
return x;
});
jcmp.events.Call('MyEvent'); // the value of x is 1
jcmp.events.Call('MyEvent', 5); // the value of x is 5
var ret = jcmp.events.Call('MyEvent');
// ret = [1]
Name | Type | Description |
---|---|---|
p1 | EventInstance |
Name | Type | Description |
---|---|---|
p1 | string |
Adds an event that can be called from the server.
Name | Type | Description |
---|---|---|
name | string | the event name |
handler | function | the function to execute when the event is called |
jcmp.events.AddRemoteCallable('MyEvent', () => {
print(`the server called MyEvent!`);
});
Calls an Event on the server scripts. Other than the normal
Call
function, this function does not return anything.
Name | Type | Description |
---|---|---|
name | string | event name |
...args | any | optional event arguments |
// see the serverside documentation of EventSystem#AddRemoteCallable
jcmp.events.CallRemote('MyEvent');
By becoming the newest member of our growing forums, we and hundreds of other players will always keep you up to date on everything JC3:MP related.