public List <LuaPlayer> PlayersByNames(Table tableOfNames) { List <LuaPlayer> luaPlayerList = new List <LuaPlayer>(); foreach (PhotonPlayer pp in PhotonNetwork.playerList) { LuaPlayer lp = Task.GetOrMakeLuaPlayer(pp); foreach (DynValue nameDyn in tableOfNames.Values) { if (nameDyn.Type == DataType.String) { string name = nameDyn.String; if (lp.name == name) { luaPlayerList.Add(lp); } } else { throw new ScriptRuntimeException("list contained non-string object"); } } } return(luaPlayerList); }
public void AttachToPlayer(LuaPlayer _lp, LuaWTBObject _lwtbo, string bone = "Head", Vector3?offset = null) { if (offset == null) { offset = Vector3.zero; } Transform boneTransform = null; foreach (Renderer child in _lp.playerObject.GetComponentsInChildren <SkinnedMeshRenderer>()) { if (child.transform.name == bone) { boneTransform = child.transform; } } if (boneTransform != null) { if (_lwtbo.WTBObject.GetComponent <Rigidbody>()) { Destroy(_lwtbo.WTBObject.GetComponent <Rigidbody>()); } _lwtbo.WTBObject.GameObject.transform.position = boneTransform.position + (Vector3)offset; _lwtbo.WTBObject.GameObject.transform.SetParent(boneTransform); _lwtbo.WTBObject.gameObject.layer = LayerMask.NameToLayer("Player"); } else { throw new ScriptRuntimeException("No bone found"); } }
public void CreateTalkMessageFor(LuaPlayer player, string message) { if (!PhotonNetwork.isMasterClient) { return; } if (player.playerConnection == PhotonNetwork.player) // if we're the player targeted { TalkController.instance.RecieveTalkMessage(message, TalkController.MessageType.Developer); } }
public void NetworkSendToPlayer(string messageName, Table data, LuaPlayer playerToSendTo) { if (!PhotonNetwork.isMasterClient) { return; } if (playerToSendTo.playerObject != null && playerToSendTo.playerObject.GetComponent <PhotonView>() != null) { string _messageSerialized = MoonSharp.Interpreter.Serialization.Json.JsonTableConverter.TableToJson(data); Task.handler.photonView.RPC("RPCReceiveLuaNetMessageTable", playerToSendTo.playerObject.GetComponent <PhotonView>().owner, messageName, _messageSerialized); } }