Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Razor. on Oct 27, 2022, 03:52 AM

Title: [Release] Event handler for VC:MP!
Post by: Razor. on Oct 27, 2022, 03:52 AM
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 (https://github.com/Razorn7/Event-handler-for-VC-MP/wiki/triggerServerEvent) and triggerClientEvent (https://github.com/Razorn7/Event-handler-for-VC-MP/wiki/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:
(https://i.imgur.com/FuuQ6At.png)
[/spoiler]
Title: Re: [Release] Event handler for VC:MP!
Post by: PSL on Dec 23, 2023, 04:14 AM
Bro, this interface has 404.