Jump to content

triggerClientEvent


Recommended Posts

  • Moderators

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 by Patrick
  • Thanks 1
Link to comment

  

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 by NoviceWithManyProblems
Link to comment
  • Moderators
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)

 

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...