Jump to content

Recommended Posts

Posted

Okay, so I noticed when doing

 

Quote

mp.players.local.shared = {};

Idk if its because its an object, it doesn't get synced. But doing

Quote

mp.players.local.variable = true;

Gets synced between players fine.

Thus, if I want to do

Quote

mp.players.local.shared = {};

mp.players.local.shared.isTyping = true;

This won't work when looping through players for example, 

Quote

mp.events.add({
    'render' : (nametags) => {
        nametags.forEach( (nametag) => {
            let [player, x, y, distance] = nametag;
            
            if(player.shared.isTyping) {
                //
            }
        }
    }
});

Will throw an error on the if statement line.

 

Can we have variable objects and it's entries (keys & values) synced between players? Or is this too much of a bottleneck?

Posted

Are you sure "mp.players.local.variable = true;" actually gets synced (automatically)? If you want to get it synced, you should use shared data (get/setVariable).

Posted (edited)

It appeared to work, when I print another players' object, I can see extra variables that I added client side. Maybe its unintended situation...

So let's say for example, I want to p2p sync when a player is typing... I have to send that data to the server and then ragemp syncs that everytime? I just see that getting effy with many players... but I guess I'll take that path.
 

Edited by Kar
  • 2 weeks later...
Posted

No thats the way. Nothing else would the rage server do. It would send it from the client you were changing the variable to the server and the server would share the change of the client with all connected players.

Just make an event on the server you call from a client changing a value like

mp.events.add("changeData", function(thisPlayer, thisData, thisValue) {
  thisPlayer.setVariable(thisData, thisValue);
});

and the client which starts typing will do something like:

mp.events.callRemote("changeData", "isTyping", true);

when he starts typing.

Posted

I understand, I know how to do the stuff, I already do it which is why I am suggesting or asking about this. Also using that for something like typing is too slow (client - server - clients). Try the stuff pls and understand why I am complaining.

 

Variables seem to sync between clients anyway, intendedly or unintendedly. You can literally just do `mp.players.local.isTyping` and then check that whereever against other players.

Posted
5 hours ago, Kar said:

You can literally just do `mp.players.local.isTyping` and then check that whereever against other players.

It's just a random match, the client really won't do that.

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