IEnumerator RespawnTraders() { Action ac = () => { foreach (int playerId in traders.Keys) { List <SerializableObjects.Trader> traders = NetworkManager.traders[playerId]; for (int i = 0; i < traders.Count; i++) { SerializableObjects.Trader trader = traders[i]; //if ((DateTime.Now - trader.respawned).TotalMinutes > trader.item_respawn_time) //{ trader = mysql.ReadTrader(trader.id); trader.respawned = DateTime.Now; traders[i] = trader; //} } } }; Task task = null; while (true) { if (task == null || task.Status != TaskStatus.Running) { task = new Task(ac); task.Start(); } yield return(new WaitForSeconds(respawnTradersTick)); } }
public static void TraderInventory(int to, SerializableObjects.Trader trader) { using (Packet _packet = new Packet((int)ServerPackets.traderInventory)) { _packet.Write(trader); SendTCPData(to, _packet); } }
public static SerializableObjects.TraderItem FindTraderItem(int from, int traderId, int item_id) { SerializableObjects.Trader trader = FindTrader(from, traderId); foreach (SerializableObjects.TraderItem item in trader.inventory) { if (item.item_id == item_id) { return(item); } } return(null); }
public void Write(SerializableObjects.Trader _value) { byte[] data = ObjectToByteArray(_value); Write(data.Length); // Add the length of the string to the packet buffer.AddRange(data); // Add the string itself }