For sure I'm missing something..
Imagine I control the visibility of a in-game entity using CanNetworkTo so it is invisible to all players by returning false from the hook.
But now for some reason I'd like to make it visible again.. I don't know how to force the connected player's client to re-evaluate the CanNetworkTo without reloading the plugin. Any idea on how this could be accomplished ? Thanks.
Make an entity visible again in CanNetworkTo?
Have you tried forcing a network update?
CanNetworkTo is a hook that the game calls when an entity is attempting to be networked with others; not something you call or re-evaluate manually. To make them visible again, you'd need to do the reverse of what you did to make them invisible. You can see examples of this in plugins such as Vanish.
Nono, I wasn’t literally saying call that hook. Entities have a method like SendNetworkUpdate, or similar. I took a wild guess and thought maybe that would trigger that hook.
Wulf
CanNetworkTo is a hook that the game calls when an entity is attempting to be networked with others; not something you call or re-evaluate manually. To make them visible again, you'd need to do the reverse of what you did to make them invisible. You can see examples of this in plugins such as Vanish.
if (!player.IsConnected)
{
var connections = Net.sv.connections.Where(con => con.connected && con.isAuthenticated && con.player is BasePlayer && con.player != player).ToList();
player.OnNetworkSubscribersLeave(connections);
player.DisablePlayerCollider(); // Exclude this line
player.syncPosition = false;
player.limitNetworking = true;
}
Hi Wulf. This is a example from Vanish. As far as I learned, code above makes items only visible or invisible without disabling collider.So instance of item still occurs there . I was wondering can I disable collider of baseentity conditionally, only for specific players?
xoetoartif (!player.IsConnected) { var connections = Net.sv.connections.Where(con => con.connected && con.isAuthenticated && con.player is BasePlayer && con.player != player).ToList(); player.OnNetworkSubscribersLeave(connections); player.DisablePlayerCollider(); // Exclude this line player.syncPosition = false; player.limitNetworking = true; }
Hi Wulf. This is a example from Vanish. As far as I learned, code above makes items only visible or invisible without disabling collider.So instance of item still occurs there . I was wondering can I disable collider of baseentity conditionally, only for specific players?
You'd have to look in the game's code to see what the DisablePlayerCollider method does.
Wulf
You'd have to look in the game's code to see what the DisablePlayerCollider method does.
public void DisablePlayerCollider()
{
if (!this.playerCollider.enabled)
{
return;
}
base.RemoveFromTriggers();
this.playerCollider.enabled = false;
}
Yeah I also looked into that method but I couldnt find what I am looking for. DisablePlayerCollider just sets the "playerCollider.enabled" to false. Basically I am making a room&lobby system. I managed rooms to have different network groups. Nobody can see other players in other rooms right now but their colliders still stays there for every room. Is there any possibility for making colliders available for only specific groups?Merged post
Or is there any other way for making players totally invisible by networking?