NoviceWithManyProblems Posted July 7, 2020 Share Posted July 7, 2020 (edited) why i can trigger this? no db3 errors server: test = { {0, 0, 5}, {1234, 1234, 1234} } triggerClientEvent(resourceRoot, "trigger", resourceRoot, test) client: addEvent("trigger", true) addEventHandler("trigger", resourceRoot, function(tabletest) outputChatBox(inspect(tabletest)) end) and nothing happens Edited July 7, 2020 by NoviceWithManyProblems Link to comment
Moderators Patrick Posted July 7, 2020 Moderators Share Posted July 7, 2020 (edited) First argument of triggerClientEvent is sendTo. The player who receive the data. Now you try to send this to a resource, instead of a player. You should use root (or player's element) at first argument. (resourceRoot at 3rd place is okay) And when you change it, probably you get a "server triggered client-side event, but event is not added at client-side" error, because you try to send data before client-side loads. (because server-side always loads before client-side) Edited July 7, 2020 by Patrick 1 Link to comment
NoviceWithManyProblems Posted July 7, 2020 Author Share Posted July 7, 2020 (edited) 10 minutes ago, Patrick said: And when you change it, probably you get a "server triggered client-side event, but event is not added at client-side" error, because you try to send data before client-side loads. (because server-side always loads before client-side) yes exatcly @Patrick so then there's other way to do this? Edited July 7, 2020 by NoviceWithManyProblems Link to comment
Moderators Patrick Posted July 7, 2020 Moderators Share Posted July 7, 2020 4 minutes ago, NoviceWithManyProblems said: @Patrick so then there's other way to do this? You should try something like that, for example: -- CLIENT SIDE addEvent("trigger", true) addEventHandler("trigger", resourceRoot, function(tabletest) outputChatBox(inspect(tabletest)) end) addEventHandler("onClientResourceStart", resourceRoot, function() -- client-side loads up, request data from server triggerServerEvent("request", resourceRoot) end) -- SERVER SIDE test = { {0, 0, 5}, {1234, 1234, 1234} } addEvent("request", true) addEventHandler("request", resourceRoot, function() -- send data back to "client" (note: "client" is a hidden-variable, when you use triggerServerEvent, its the "localPlayer", who triggered the server-sided event) if client then triggerClientEvent(client, "trigger", resourceRoot, test) end end) 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now