public static void SendSyncMesage(SyncContainer syncContainer, ulong userId = 0, bool sendServer = false, bool sendOthers = false) { var byteData = MyAPIGateway.Utilities.SerializeToBinary <SyncContainer>(syncContainer); if (userId != 0) { MyAPIGateway.Multiplayer.SendMessageTo(NetworkId, byteData, userId); } if (sendServer == true) { MyAPIGateway.Multiplayer.SendMessageToServer(NetworkId, byteData); } if (sendOthers == true) { MyAPIGateway.Multiplayer.SendMessageToOthers(NetworkId, byteData); } }
public static void SendParticleEffectRequest(string id, MatrixD remoteMatrix, Vector3D offset, float scale, float maxTime, Vector3D color) { var effect = new Effects(); effect.Mode = EffectSyncMode.Particle; effect.Coords = Vector3D.Transform(offset, remoteMatrix); effect.ParticleId = id; effect.ParticleScale = scale; effect.ParticleColor = color; effect.ParticleMaxTime = maxTime; effect.ParticleForwardDir = remoteMatrix.Forward; effect.ParticleUpDir = remoteMatrix.Up; var syncData = new SyncContainer(effect); foreach (var player in TargetHelper.GetPlayersWithinDistance(effect.Coords, 15000)) { SyncManager.SendSyncMesage(syncData, player.SteamUserId); } }
public static void SendChatDataOverNetwork(ChatMessage chatData, bool sendToServer) { if (string.IsNullOrWhiteSpace(chatData.ReturnMessage) == false && sendToServer == false) { MyVisualScriptLogicProvider.ShowNotification(chatData.ReturnMessage, 5000, "White", chatData.PlayerId); } var byteChatData = MyAPIGateway.Utilities.SerializeToBinary <ChatMessage>(chatData); var syncData = new SyncContainer(SyncMode.ChatCommand, byteChatData); var byteSyncData = MyAPIGateway.Utilities.SerializeToBinary <SyncContainer>(syncData); if (sendToServer == true) { MyAPIGateway.Multiplayer.SendMessageToServer(SyncManager.NetworkId, byteSyncData); } else { MyAPIGateway.Multiplayer.SendMessageTo(SyncManager.NetworkId, byteSyncData, chatData.SteamId); } }