Jump to content

Question of efficiency


Driggero

Recommended Posts

So I've created a kill script for DD, and after the kills are added to the players account serverside, I want it to trigger an event to send this account data back to the client to be displayed in a GUI. I'm stuck between 2 ways of doing this:

I could create a table with ALL the kills of every player and send that client side on the root element. Then filter through this client side for the specific local player.

Or I could loop through all the players and trigger a client event for each player sending ONLY their specific account info to them, no one elses.

I guess what I'm asking is If I trigger a client event on the root element, is that the same as triggering x amount of client events for x amount of players. In which case it would just be more efficient to send only the players specific info in something like this:

  
for i,v in ipairs(getElementsByType("player")) do 
    local account = getPlayerAccount(v) 
    local killTotal = getAccountData(account, "dd.kills") or 0 
    triggerClientEvent(v, "onPostFinishClient", root, killTotal) 
end 
  

Link to comment

That should be more efficient. Sending clients data they don't need is a waste of bandwidth. If you genuinely need to send all the clients the same data, then triggering on the root would be somewhat more optimal (the data shouldn't need to be mcodes multiple times for example).

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...