As the title says, how do I trigger a lua event from js?
I’ve tried by using the documentation
emitNet(“eventName”, eventParam1, eventParam2);
But doesn’t clearly understand how to define that to use a lua event
It doesn’t matter if it’s an Lua, C# or JS event you can trigger them from every language
1 Like
d0p3t
4
emitNet is used for triggering an event across the network - equivalent of TriggerClientEvent or TriggerServerEvent)
Example
Lua Server-side
RegisterNetEvent("myEvent")
AddEventHandler("myEvent", function (message)
print(message)
end)
Javascript client-side
emitNet("myEvent", "This is my message that will be printed in the server console");
2 Likes
Hello !
But In my case, debug say emitNet is not defined… 4 days I’m on it lol
What did I don’t understood ?
d0p3t
6
Call it from a script, not NUI
1 Like
Thanks for the reply, but if I want to call clientside LUA script from UI, what sould I do ? Use the $.post thing ?
d0p3t
8
Read documentation please. For example NUI callbacks
1 Like