void CalculateDropChance() { Data_PlayerFile_Sr zombie = RoomsManager.GetPlayerData(index); int dropID = 0; if (zombie.HPMax >= 100) { dropID = 2; if (zombie.HPMax >= 200) { dropID = Random.Range(2, 3); } if (zombie.HPMax >= 300) { dropID = Random.Range(3, 4); } float chance = zombie.HPMax * zombie.attackPower / (float)dropID / 1000; Random.seed = (int)Time.time; float var1 = Random.value; Random.seed = (int)Time.time * Random.Range(3, 7); float var2 = Random.value; if (Mathf.Abs(var1 - var2) < chance) { AccountData acc = Networking_OnConnect.GetAccountData(index); Player_Weapon_Sr weap = RoomsManager.InstantiateWeapon((weaponType_Sr)dropID, transform.position, acc.roomID); weap.DropWeapon(true); } } }
/// <summary> /// Send reliable message to all other players in room of this player /// </summary> /// <param name="msgType"></param> /// <param name="msg"></param> /// <param name="sessionID"></param> public static void SendToAllOtherPlayer(short msgType, MessageBase msg, int sessionID) { AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { Room room = GetRoom(acc.roomID); if (room) { foreach (PlayerData data in room.playersData) { if (data != null) { if (data.playerData.PlayerReady) { if (data.sessionID != sessionID) { NetworkConnection conn = GetPlayerConnection(data.sessionID); if (conn != null && conn.connectionId != -1) { conn.Send(msgType, msg); } } } } } } } }
public static bool Disconnect(int connectionID) { bool yes = false; if (connectionID != -1) { int sessionID = Networking_OnConnect.FindSessionID(connectionID); if (sessionID != -1) { AccountData data = Networking_OnConnect.GetAccountData(sessionID); if (data.indexInRoom != -1 && data.roomID != -1) { Room room = GetRoom(data.roomID); if (room) { room.DisconnectPlayer(data.indexInRoom); } } Networking_OnConnect.DisconnectPlayer(sessionID); } } return(yes); }
//Check whether it is a character of the player and turn the player on its index, and gave him the coordinates of movement static public void OnPlMove(NetworkMessage netms) { Message_Sr.PlayerGoTo_Sr Go = netms.ReadMessage <Message_Sr.PlayerGoTo_Sr>(); if (Networking_OnConnect.AccountVerefication(Go.index, Go.login, Go.password)) { try { if (Go.keySend) { Player_MovePlayer move = GetPlayerController(Go.index); if (move) { move.Newposit(Go.key, Go.down); } } else { Player_MovePlayer move = GetPlayerController(Go.index); if (move) { move.axisY = Go.axisY; } } } catch (UnityException ex) { Debug.Log(ex.Message); Debug.Log("Networking_OnPlayerMove: ERROR"); } } }
/// <summary> /// Send message to all in room of this player by channel 1 /// </summary> /// <param name="msg"></param> /// <param name="sessionID"></param> public static void SendUnreliableAtRoom(NetworkWriter msg, int sessionID) { AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { Room room = GetRoom(acc.roomID); if (room) { foreach (PlayerData data in room.playersData) { if (data != null) { if (data.playerData.PlayerReady) { NetworkConnection conn = GetPlayerConnection(data.sessionID); if (conn != null && conn.connectionId != -1) { conn.SendWriter(msg, 1); } } } } } } }
public bool DisconnectPlayer(int index) { bool yes = false; if (index >= 0 && playersData.Count > index) { AccountData acc = Networking_OnConnect.GetAccountData(playersData[index].sessionID); if (acc != null) { yes = true; //Remove rooms data at account data acc.indexInRoom = -1; acc.roomID = -1; Message_Sr.DisconnectPlayer disc = new Message_Sr.DisconnectPlayer(); disc.ID = playersData[index].sessionID; RoomsManager.SendReliableToRoom(Networking_msgType_Sr.DisconnectPlayer, disc, roomID); //Remove player weapon Player_MovePlayer controll = playersData[index].playerMoveScript; if (controll.weaponOnMe) { RoomsManager.SendIntToAllRoom(Networking_msgType_Sr.RemoveItemOnScene, controll.weaponOnMe.index, roomID); RemoveItem(controll.weaponOnMe.index); } //Remove player data Destroy(playersData[index].playerObj); playersData[index] = null; playerListNULLVALLUE.Add(index); playerNumber--; } } return(yes); }
public static void GetRoomsList(NetworkMessage netMsg) { if (Networking_OnConnect.AccountVerefication(netMsg)) { foreach (NetworkWriter wr in RoomsList) { netMsg.conn.SendWriter(wr, 0); } } }
//If a player has selected a character check his data and send him to his character data static public void HandlerJoinToRoom(NetworkMessage netmsg) { Message_Sr.PlayerJoinToRoom_Sr join = netmsg.ReadMessage <Message_Sr.PlayerJoinToRoom_Sr>(); if (Networking_OnConnect.AccountVerefication(join.sessionID, join.Login, join.Password)) { Data_PlayerFile_Sr player = SQL_PlayerVerefy.CheckLP(join.Login, join.Password, join.playerNick); if (player) { AccountData acc = Networking_OnConnect.GetAccountData(join.sessionID); if (acc != null) { if (acc.roomID == -1 && acc.indexInRoom == -1) { player.sessionID = join.sessionID; Room room = GetRoom(join.roomID); if (room) { bool connect = true; if (room.password) { if (!room.CheckPassword(join.roomPassword)) { connect = false; Message_Sr.PlayerJoinToRoom_Sr error = new Message_Sr.PlayerJoinToRoom_Sr(); error.errorMsg = "Password not correct"; netmsg.conn.Send(Networking_msgType_Sr.JoinToRoom, error); } } if (room.maxPlayerNumber == room.playerNumber) { connect = false; Message_Sr.PlayerJoinToRoom_Sr error = new Message_Sr.PlayerJoinToRoom_Sr(); error.errorMsg = "Room have maximum players number"; netmsg.conn.Send(Networking_msgType_Sr.JoinToRoom, error); } if (connect) { SendRoomInstantiate(room.roomID, join.sessionID); PlayerLoad(netmsg.conn, player, join.roomID); Networking_PlayerListSend.OnPlayerList(netmsg.conn, join.roomID); Networking_PlayerListSend.SendItems(netmsg.conn, join.sessionID); } } } } } else { Disconnect(netmsg.conn.connectionId); } } }
public static void HandleReload(NetworkMessage netMsg) { Message_Sr.PlayerAction action = netMsg.ReadMessage <Message_Sr.PlayerAction>(); if (Networking_OnConnect.AccountVerefication(action.index, action.log, action.pass)) { Player_MovePlayer pl = GetPlayerController(action.index); if (pl != null) { pl.StartReload(); } } }
public static void HandleRespawn(NetworkMessage netmsg) { Message_Sr.Respawn_Sr rs = netmsg.ReadMessage <Message_Sr.Respawn_Sr>(); if (Networking_OnConnect.AccountVerefication(rs.index, rs.log, rs.pass)) { Player_MovePlayer pl = GetPlayerController(rs.index); if (pl != null) { pl.Respawn(); } } }
public static void SendTopList(NetworkMessage netMsg) { Message_Sr.PlayerAction act = netMsg.ReadMessage <Message_Sr.PlayerAction>(); if (Networking_OnConnect.AccountVerefication(act.index, act.log, act.pass)) { NetworkConnection con = RoomsManager.GetPlayerConnection(act.index); if (con != null) { con.SendWriter(top, 1); } } }
public static void HandleDropWeapon(NetworkMessage netMsg) { Message_Sr.DropWeapon_Sr drop = netMsg.ReadMessage <Message_Sr.DropWeapon_Sr>(); if (Networking_OnConnect.AccountVerefication(drop.index, drop.log, drop.pass)) { Player_MovePlayer controll = GetPlayerController(drop.index); if (controll) { controll.DropWeapon(); } } }
public static NetworkConnection GetPlayerConnection(int sessionID) { NetworkConnection data = null; AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { data = acc.conn; } return(data); }
public static int GetPlayerConnectionID(int sessionID) { int data = -1; AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { data = acc.conn.connectionId; } return(data); }
public static void PlayerLeaveRoom(int sessionID) { AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { Room room = GetRoom(acc.roomID); if (room) { room.DisconnectPlayer(acc.indexInRoom); } } }
public static void HandlePickUpItem(NetworkMessage netMsg) { Message_Sr.PickUpWeapon_Sr pick = netMsg.ReadMessage <Message_Sr.PickUpWeapon_Sr>(); if (Networking_OnConnect.AccountVerefication(pick.index, pick.log, pick.pass)) { Player_MovePlayer controll = GetPlayerController(pick.index); if (controll) { controll.DropWeapon(); PickUpItem(pick.indexItem, controll); } } }
public static void HandlerReady(NetworkMessage netmsg) { Message_Sr.PlayerSetReady ready = netmsg.ReadMessage <Message_Sr.PlayerSetReady>(); if (Networking_OnConnect.AccountVerefication(ready.id, ready.log, ready.pass)) { Data_PlayerFile_Sr data = GetPlayerData(ready.id); if (data) { data.PlayerReady = true; data.SetHP(data.HPMax); } } }
static public void OnMouseButton(NetworkMessage netmsg) { Message_Sr.MouseButton_Sr mouse = netmsg.ReadMessage <Message_Sr.MouseButton_Sr>(); if (Networking_OnConnect.AccountVerefication(mouse.index, mouse.log, mouse.pass)) { if (mouse.down) { GetPlayerController(mouse.index).StartFire(); } else { GetPlayerController(mouse.index).StopFire(); } } }
public static void HandlerCreateRoom(NetworkMessage netmsg) { Message_Sr.PlayerCreateRoom_Sr create = netmsg.ReadMessage <Message_Sr.PlayerCreateRoom_Sr>(); if (Networking_OnConnect.AccountVerefication(create.sessionID, create.Login, create.Password)) { Data_PlayerFile_Sr player = SQL_PlayerVerefy.CheckLP(create.Login, create.Password, create.playerNick); if (player) { AccountData acc = Networking_OnConnect.GetAccountData(create.sessionID); if (acc != null) { if (acc.roomID == -1 && acc.indexInRoom == -1) { if (create.roomName.Length >= 5) { player.sessionID = create.sessionID; int roomID = -1; if (create.pass && !string.IsNullOrEmpty(create.roomPassword) && create.roomPassword.Length >= 4) { roomID = CreateRoom(create.roomName, create.mapID, create.roomPassword); } else if (!create.pass) { roomID = CreateRoom(create.roomName, create.mapID); } if (roomID != -1) { SendRoomInstantiate(roomID, create.sessionID); PlayerLoad(netmsg.conn, player, roomID); Networking_PlayerListSend.OnPlayerList(netmsg.conn, roomID); Networking_PlayerListSend.SendItems(netmsg.conn, create.sessionID); } } } } } else { Disconnect(netmsg.conn.connectionId); } } }
/// <summary> /// Disconnect and destroy all player, item and room /// </summary> public void DestroyRoom() { //Disconnect and destroy all player at room for (int index = 0; index < playersData.Count; index++) { int sessionID = playersData[index].sessionID; AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { //Remove rooms data at account data acc.indexInRoom = -1; acc.roomID = -1; Message_Sr.DisconnectPlayer disc = new Message_Sr.DisconnectPlayer(); disc.ID = sessionID; RoomsManager.SendToThisPlayer(Networking_msgType_Sr.DisconnectPlayer, disc, sessionID); //Remove player weapon Player_MovePlayer controll = playersData[index].playerMoveScript; if (controll.weaponOnMe) { RoomsManager.SendIntToAllRoom(Networking_msgType_Sr.RemoveItemOnScene, controll.weaponOnMe.index, roomID); RemoveItem(controll.weaponOnMe.index); } //Remove player data Destroy(playersData[index].playerObj); } } playersData.Clear(); playerListNULLVALLUE.Clear(); //Destroy all item in room for (int index = 0; index < ItemsList.Count; index++) { Player_Item_Sr item = ItemsList[index]; if (item) { Destroy(item.gameObject); } } ItemsList.Clear(); nullItem.Clear(); Destroy(gameObject); }
public static void HandlerPlayerDisconnectAtRoom(NetworkMessage netmsg) { int sessionID = -1; if (Networking_OnConnect.AccountVerefication(netmsg, out sessionID)) { AccountData data = Networking_OnConnect.GetAccountData(sessionID); if (data != null && data.roomID != -1) { Room room = GetRoom(data.roomID); if (room) { room.DisconnectPlayer(data.indexInRoom); } } } }
public static Player_MovePlayer GetPlayerController(int sessionID) { Player_MovePlayer data = null; AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { if (acc.roomID != -1 && acc.indexInRoom != -1) { Room room = GetRoom(acc.roomID); if (room) { data = room.GetPlayerControll(acc.indexInRoom); } } } return(data); }
public static Data_PlayerFile_Sr GetPlayerData(int sessionID) { Data_PlayerFile_Sr data = null; AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { if (acc.roomID != -1 && acc.indexInRoom != -1) { Room room = GetRoom(acc.roomID); if (room) { data = room.GetPlayerData(acc.indexInRoom); } } } return(data); }
static void PickUpItem(int itemIndex, Player_MovePlayer controll) { AccountData acc = Networking_OnConnect.GetAccountData(controll.index); Room room = GetRoom(acc.roomID); if (room) { Player_Item_Sr item = room.GetItem(itemIndex); if (item) { switch (item.ItemType) { case ItemType_Sr.weapon: PickUpWeapon(item, controll); break; } } } }
public void WritePlayer(int sessionID, Data_PlayerFile_Sr player, GameObject obj) { AccountData acc = Networking_OnConnect.GetAccountData(sessionID); if (acc != null) { PlayerData data = new PlayerData(); data.playerData = player; data.playerObj = obj; data.playerMoveScript = obj.GetComponent <Player_MovePlayer>(); data.sessionID = sessionID; int indexInRoom = -1; if (playerListNULLVALLUE.Count > 0) { indexInRoom = playerListNULLVALLUE[0]; playerListNULLVALLUE.RemoveAt(0); player.sessionID = sessionID; data.playerMoveScript.index = sessionID; playersData[indexInRoom] = data; acc.indexInRoom = indexInRoom; acc.roomID = roomID; } else { indexInRoom = playersData.Count; player.sessionID = sessionID; data.playerMoveScript.index = sessionID; playersData.Add(data); acc.indexInRoom = indexInRoom; acc.roomID = roomID; } playerNumber++; } }
public static bool CheckLP(string login, string password, out List <Data_PlayerFile_Sr> list, out int accID) { bool check = true; accID = -1; charList.Clear(); Linq.CommandText = string.Format("SELECT id FROM accountlist WHERE AccountName='{0}' AND PasswordAc='{1}'", login, password); MySqlDataReader Reader = Linq.ExecuteReader(); try { Reader.Read(); string AccId = Reader.GetString(0); Reader.Close(); accID = int.Parse(AccId); if (!Networking_OnConnect.CheckOnlineAccount(accID)) { charList = CharDataGet(AccId); } else { check = false; Networking_OnConnect.AccountUsed(); } } catch (MySqlException ex) { Reader.Close(); Debug.Log(ex.ErrorCode + ex.Message); check = false; Networking_OnConnect.NoAccount(); } Reader.Close(); list = charList; return(check); }
//Add new char on account public static void CreateChar(NetworkMessage netmsg) { Message_Sr.CreateChar character = netmsg.ReadMessage <Message_Sr.CreateChar> (); if (Networking_OnConnect.AccountVerefication(character.sessionID, character.log, character.pass)) { if (character.nick.Length < NickSymbolMin) { Message_Sr.CreateChar create = new Message_Sr.CreateChar(); create.msg = minNickSymbol; netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create); } else { Linq.CommandText = "SELECT id FROM accountlist WHERE AccountName='" + character.log + "' AND PasswordAc = '" + character.pass + "'"; MySqlDataReader read = Linq.ExecuteReader(); if (read.Read()) { int ID = int.Parse(read.GetString(0)); read.Close(); Linq.CommandText = "SELECT COUNT(*) FROM charecter WHERE PlayerName = '" + character.nick + "'"; read = Linq.ExecuteReader(); if (read.Read()) { if (int.Parse(read.GetString(0)) == 1) { read.Close(); Message_Sr.CreateChar create = new Message_Sr.CreateChar(); create.msg = busyNick; netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create); } else { read.Close(); Linq.CommandText = "SELECT COUNT(*) FROM charecter WHERE account_id = '" + ID.ToString() + "'"; read = Linq.ExecuteReader(); if (read.Read()) { int numberChars = int.Parse(read.GetString(0)); read.Close(); if (numberChars < maxCharInAccount) { Linq.CommandText = "INSERT INTO charecter (account_id, PlayerName, MaxHP, PlayerScores, scene_ID, x, y, z) VALUES (" + ID.ToString() + ", '" + character.nick + "', 100, 0, 0, '5', '120', '5')"; int row = Linq.ExecuteNonQuery(); Debug.Log("Succsess create new character '" + character.nick + "' " + row + "."); Message_Sr.CreateChar create = new Message_Sr.CreateChar(); create.msg = characterCreated; netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create); List <Data_PlayerFile_Sr> list = SQL_FindLogPass.CharDataGet(ID.ToString()); Message_Sr.CharData data = new Message_Sr.CharData(); data.index = character.sessionID; data.players = list; netmsg.conn.Send(Networking_msgType_Sr.PlayerDataGet, data.Serialize()); } else { Message_Sr.CreateChar create = new Message_Sr.CreateChar(); create.msg = maxChars; netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create); } } else { Message_Sr.CreateChar create = new Message_Sr.CreateChar(); create.msg = notValidAcc; netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create); } } } } } } }
public void SpawnMob() { spawnPosition = new Vector3(5, transform.position.y, 5); GameObject obj = (GameObject)Resources.Load("Zombie"); Vector3 vect = Vector3.zero; float Hight = Random.Range(0.1f, 0.15f); float Midle = Random.Range(0.15f, 0.25f); float Low = 1 - (Hight + Midle); //check zombie number, if more than maximum players in room if (zombieNumber >= maxPlayerNumber) { zombieNumber = maxPlayerNumber - 2; } if (zombieNumber >= 3) { int zombieLow = Mathf.FloorToInt((float)zombieNumber * Low); int zombieMidle = Mathf.FloorToInt((float)zombieNumber * Midle); int zombieHight = Mathf.FloorToInt((float)zombieNumber * Hight); int sessionID = -1; for (int i = 0; i < zombieLow; i++) { do { vect = new Vector3(Random.Range(0, 100), transform.position.y, Random.Range(0, 100)); }while (vect.x < 20f || vect.z < 20f); GameObject Zombie = (GameObject)Instantiate(obj, vect, Quaternion.AngleAxis(Random.Range(0, 360), Vector3.up)); Data_PlayerFile_Sr data = ScriptableObject.CreateInstance <Data_PlayerFile_Sr>(); data.HPMax = Random.Range(60, 110); data.SetHP(data.HPMax); switch (Random.Range(1, 3)) { case 1: data.nick = "zombie"; break; case 2: data.nick = "sickzombie"; break; case 3: data.nick = "policezombie"; break; } data.PlayerReady = true; data.attackPower = Random.Range(10, 17); Zombie.GetComponent <Player_MovePlayer>().zombie = true; sessionID = Networking_OnConnect.BotAdd(roomID, playersData.Count); WritePlayer(sessionID, data, Zombie); } for (int i = 0; i < zombieMidle; i++) { do { vect = new Vector3(Random.Range(0, 100), transform.position.y, Random.Range(0, 100)); }while (vect.x < 20f || vect.z < 20f); GameObject Zombie = (GameObject)Instantiate(obj, vect, Quaternion.AngleAxis(Random.Range(0, 360), Vector3.up)); Data_PlayerFile_Sr data = ScriptableObject.CreateInstance <Data_PlayerFile_Sr>(); data.HPMax = Random.Range(180, 250); data.SetHP(data.HPMax); data.nick = "mutantzombie"; data.PlayerReady = true; data.attackPower = Random.Range(20, 30); Zombie.GetComponent <Player_MovePlayer>().zombie = true; sessionID = Networking_OnConnect.BotAdd(roomID, playersData.Count); WritePlayer(sessionID, data, Zombie); } for (int i = 0; i < zombieHight; i++) { do { vect = new Vector3(Random.Range(0, 100), transform.position.y, Random.Range(0, 100)); }while (vect.x < 20f || vect.z < 20f); GameObject Zombie = (GameObject)Instantiate(obj, vect, Quaternion.AngleAxis(Random.Range(0, 360), Vector3.up)); Data_PlayerFile_Sr data = ScriptableObject.CreateInstance <Data_PlayerFile_Sr>(); data.HPMax = Random.Range(300, 400); data.SetHP(data.HPMax); data.nick = "strongzombie"; data.PlayerReady = true; data.attackPower = Random.Range(36, 48); Zombie.GetComponent <Player_MovePlayer>().zombie = true; sessionID = Networking_OnConnect.BotAdd(roomID, playersData.Count); WritePlayer(sessionID, data, Zombie); } } }
public static void SendItems(NetworkConnection con, int sessionID) { AccountData acc = Networking_OnConnect.GetAccountData(sessionID); Room room = GetRoom(acc.roomID); if (room) { itemsSend = packetItem; itemsSends = 0; if (room.itemListCount > 0) { while (!allItems) { if (itemsSends != room.itemListCount) { lastItems = room.itemListCount - itemsSends; NetworkWriter writer = new NetworkWriter(); writer.StartMessage(Networking_msgType_Sr.ItemList); if (lastItems < itemsSend) { allItems = true; itemsSend = lastItems; writer.Write(itemsSend); writer.Write(true); } else { writer.Write(itemsSend); writer.Write(false); } for (int k = 0; k < itemsSend; k++) { Player_Item_Sr data = room.GetItem(itemsSends); if (data != null) { writer.Write(true); writer.Write(data.index); writer.Write((int)data.ItemType); switch (data.ItemType) { case ItemType_Sr.weapon: writer.Write((int)data.WeaponType); Player_Weapon_Sr weap = data.gameObject.GetComponent <Player_Weapon_Sr>(); writer.Write(weap.Dropped); if (weap.Dropped) { writer.Write(data.transform.position); writer.Write(data.transform.rotation); } else { writer.Write(weap.ShoterIndex); if (weap.ShoterIndex == sessionID) { writer.Write(true); writer.Write(weap.maxAmmo); } else { writer.Write(false); } } break; } } else { writer.Write(false); } itemsSends++; } writer.FinishMessage(); con.SendWriter(writer, 0); } else { allItems = true; } } } else { NetworkWriter writer = new NetworkWriter(); writer.StartMessage(Networking_msgType_Sr.ItemList); writer.Write(0); writer.Write(true); writer.FinishMessage(); con.SendWriter(writer, 0); } allItems = false; } }
public static void ChatHandler(NetworkMessage netmsg) { Message_Sr.Chat_Sr chatR = netmsg.ReadMessage <Message_Sr.Chat_Sr> (); if (Networking_OnConnect.AccountVerefication(chatR.index, chatR.log, chatR.pass)) { AccountData acc = Networking_OnConnect.GetAccountData(chatR.index); Room room = GetRoom(acc.roomID); if (room) { switch (chatR.msgType) { case (int)ChatMessage.chat: Message_Sr.Chat_Sr chatW = new Message_Sr.Chat_Sr(); chatW.msgTypeW = (int)ChatMessage.chat; chatW.nickW = GetPlayerData(chatR.index).nick; chatW.id = chatR.index; chatW.msgW = chatR.msg; SendReliableAtRoom(Networking_msgType_Sr.Chat, chatW, chatR.index); break; case (int)ChatMessage.privat: if (chatR.indexPriv == -1) { for (int i = 0; i < room.playersData.Count; i++) { if (room.playersData[i].playerData.nick == chatR.nick) { chatR.indexPriv = room.playersData[i].sessionID; break; } } } if (chatR.indexPriv == -1) { NetworkWriter wr = new NetworkWriter(); wr.StartMessage(Networking_msgType_Sr.Chat); wr.Write((int)ChatMessage.system); wr.Write("System"); wr.Write(-1); wr.Write("This player is offline."); wr.FinishMessage(); netmsg.conn.SendWriter(wr, 0); } else { NetworkWriter wr = new NetworkWriter(); wr.StartMessage(Networking_msgType_Sr.Chat); wr.Write((int)ChatMessage.privat); wr.Write(GetPlayerData(chatR.indexPriv).nick); wr.Write(chatR.index); wr.Write(chatR.msg); wr.FinishMessage(); SendToThisPlayer(wr, chatR.index); wr = new NetworkWriter(); wr.StartMessage(Networking_msgType_Sr.Chat); wr.Write((int)ChatMessage.privat); wr.Write(GetPlayerData(chatR.index).nick); wr.Write(chatR.index); wr.Write(chatR.msg); wr.FinishMessage(); SendToThisPlayer(wr, chatR.indexPriv); } break; } } } }