[Release] Event handler for VC:MP!

Started by Razor., Oct 27, 2022, 03:52 AM

Previous topic - Next topic

Razor.

Basic introduction:

The event handler allows you to attach functions to events in any part of the code, without having to put your functions in the same part of the code. This feature also provides the functions triggerServerEvent and triggerClientEvent that have the functionality to call events registered in both parts in a practical way.

Source-code and usage instructions: https://github.com/Razorn7/Event-handler-for-VC-MP/
Wiki: https://github.com/Razorn7/Event-handler-for-VC-MP/wiki

Usage example:
[spoiler]
Server-side:
addEventHandler("onPlayerJoin", function(player) {
triggerClientEvent(player, "changeLabelText", "The text goes here");
});

Client-side:
addEventHandler("Script::ScriptLoad", function() {
local MyLabel = GUILabel();

addEvent("changeLabelText");
addEventHandler("changeLabelText", function(text) {
MyLabel.Text = text;
});
});

Result:

[/spoiler]

PSL