Hi All!
I need to hook mine was spawned on the map.
i used this hook:
how to I can find player BasePlayer from networkable ?Code:void OnEntitySpawned(BaseNetworkable networkable) { }
OnEntitySpawned BaseNetworkable
Discussion in 'Rust Development' started by not777, Mar 9, 2016.
-
Wulf Community Admin
Cast BaseNetworkable to BasePlayer, I believe that's all you need.
-
var player = networkable as BasePlayer is the correct use ?
-
Wulf Community Admin
I'm not certain, I've never tried to convert it before. I think there is more to it than that, but I'd need to dig around. -
work fine for me )) thanks!Code:
if (networkable.isClient) { var player = networkable as BasePlayer }
[DOUBLEPOST=1457524218,1457515747][/DOUBLEPOST]this.isServer hook for server entity spawns only =(Code:public virtual void Spawn(bool networked = true) { if (this.isServer) { if (this.net == null) { this.net = Net.sv.CreateNetworkable(); } this.net.owner = this; this.creationFrame = Time.frameCount; this.PreInitShared(); this.InitShared(); this.ServerInit(); this.PostInitShared(); this.UpdateNetworkGroup(); this.isSpawned = true; object[] objArray = new object[] { this }; Interface.CallHook("OnEntitySpawned", objArray); this.SendNetworkUpdateImmediate(true); } }
how to hook player entity spawns ?
[DOUBLEPOST=1457528131][/DOUBLEPOST]I finded some code from source:
if I Cast BaseNetworkable to BaseEntity I can find RPC sender info ???Code:BaseEntity.RPCMessage rPCMessage = new BaseEntity.RPCMessage(); rPCMessage.connection rPCMessage.player
OXIDE need SV_RPCMessage hook...Last edited by a moderator: Mar 9, 2016 -
Wulf Community Admin
Players are entities, but you could also use OnPlayerInit or even OnPlayerRespawned.
