public void OnItemRemoved(InventoryModEvent ir)
        {
            //ir.Player.Message("remove " + ir.Inventory.slotCount);

            if (IsPlayerInShop(ir.Player))
            {
                string ItemComprado = ir.ItemName;

                foreach (var line in File.ReadAllLines(PricesFile))
                {
                    if (ItemComprado == "Rock")
                    {
                        ir.Player.MessageFrom(Name, yellow + "You can´t buy a Rock");
                        ir.Cancel();
                        //ir.Player.Damage(20f);
                        DamagePlayer(ir.Player);
                        break;
                    }
                    string[] pares = line.ToString().Split(new char[] { '=' });
                    string   item  = pares[0];
                    int      price = Convert.ToInt32(pares[1]);

                    if (ItemComprado == item)
                    {
                        //tiene dinero suficiente?
                        if (ir.Player.Inventory.HasItem("Paper", price))
                        {
                            ir.Player.MessageFrom(Name, green + "You have buy " + white + ItemComprado + green + " whit " + white + price + green + " Papers");
                            ir.Player.Inventory.RemoveItem("Paper", price);
                            int freeslots = ir.FInventory.FreeSlots;
                            ir.FInventory.AddItem("Rock", freeslots);

                            file = new System.IO.StreamWriter(LogFile, true);
                            file.WriteLine("[" + DateTime.Now.ToString() + "] " + ir.Player.Name + " has bought a " + ItemComprado + " for " + price + " papers");
                            file.Close();
                            Server.GetServer().BroadcastFrom(Name, ir.Player.Name + " has bought a " + ItemComprado + " for " + price + " papers");
                            break;
                        }
                        else
                        {
                            ir.Cancel();
                            //ir.Player.Notice(" ", "You don´t have enougth Papers :(", 5);
                            ir.Player.MessageFrom(Name, orange + "You don´t have enougth Papers " + white + ItemComprado + " (" + price + " Papers)");
                            //ir.Player.Damage(20f);
                            DamagePlayer(ir.Player);
                            break;
                        }
                    }
                }
            }
        }
 private void OnItemRemoved(InventoryModEvent e)
 {
     if (e.Player != null)
     {
         if (WaitingUsers.ContainsKey(e.Player.UID))
         {
             e.Cancel();
             e.Player.MessageFrom("AuthMe", red + YouNeedToBeLoggedIn);
         }
     }
 }
Beispiel #3
0
 public void ItemRemoved(InventoryModEvent e)
 {
     try
     {
         if (e.Player != null)
         {
             Fougerite.Player player = (Fougerite.Player)e.Player;
             if (player.IsOnline)
             {
                 Vector3 location = player.Location;
                 float   d        = Vector3.Distance(e.Inventory.transform.position, location);
                 if (d > MaxlootDist)
                 {
                     if (BroadcastAdmins)
                     {
                         NotifyAdmin(player.Name + yellow + " Is Maybe using longdistance looting dist: " + (Math.Round(d)));
                     }
                     string line = DateTime.Now + " [AntiAutoLoot] " + player.Name + "-" + player.SteamID + " Tried to loot from " + (Math.Round(d)) + " max dist = " + MaxlootDist + "";
                     file = new System.IO.StreamWriter(ppath, true);
                     file.WriteLine(line);
                     file.Close();
                     string message = Broadcast.Replace("{Player}", player.Name);
                     Server.GetServer().Broadcast(message);
                     player.Message(WarningMessage);
                     Logger.LogWarning(player.Name + " Tried to loot from an unreachable container");
                     e.Cancel();
                     player.Disconnect();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogError("[AntiCrackLoot] ERROR: " + ex);
     }
 }