Hurtworld Inventory scanning and alerts

Discussion in 'Plugin Requests' started by Sans 2, Mar 17, 2016.

  1. I was wondering if someone could create a plugin that scans players action bars and backpack upon disconnection, notifying through a custom admin message if they logged out with det caps and/or C4?

    The message would be something like "player" just logged out with their Det Caps/C4.....What a DOUCHE!!!
     
  2. Just Iterate through the Inventory of the player session with the OnPlayerDisconnected hook.
     
  3. Unfortunately I have no idea how to even start to create a plugin :(
     
  4. If you just want it to give a notification, just break the for() loop when it finds what you are looking for.
    Using the OnPlayerDisconnected hook is simple. Something like:
    Code:
        void OnPlayerDisconnected(PlayerSession session)
         {
           PlayerInventory inv = session.WorldPlayerEntity.GetComponent<PlayerInventory>();
           for (var i = 0; i < inv.Items.Length; i++)
           {
             if (inv.Items[i] != null)
             {
               if(inv.Items[i].Item.ItemId == 144 || inv.Items[i].Item.ItemId == 231)
               {
                 hurt.BroadcastChat(session.Name+" has Disconnected with C4/Detonator Caps!");
                 break;
               }
             }
           }
         }
    
    When a player disconnects it will check every non-empty slot for det caps or C4, if it finds either of them, it will say that broadcast message with their name, then stop checking any further (break).
     
  5. um......That looks wonderful and all, but how do I actually make that work on the server, I don't know how to create the plugin itself :(
     
  6. I can make it for you. You only need it to display the message?
     
  7. OMG that would be so awesome! I only need it to display the message "player" just logged out with their DetCaps/C4....What a DOUCHE!
     
  8. Since there was a C4Logger for Hurtworld | Oxide already, I edited it instead of making a new plugin for now. I sent you by PM.

    If you wish a real Inventory Scanner and Alert for any type of item, tell me.
     
  9. Just put that code I wrote into a clean plugin, or existing one. It's all there.

    Here. Save this as"DCCheck.cs" and put it in your Plugins folder.
    I'm fine with anyone using this code for any plugins.

    Code:
    // Reference: UnityEngine.UI
    using System;
    using UnityEngine;
    namespace Oxide.Plugins
    {
        [Info("DCCheck", "Noviets", "1.0.0")]   
        class DCCheck : HurtworldPlugin
        {
            void OnPlayerDisconnected(PlayerSession session)
            {
                PlayerInventory inv = session.WorldPlayerEntity.GetComponent<PlayerInventory>();
                for (var i = 0; i < inv.Items.Length; i++)
                {
                    if (inv.Items[i] != null)
                    {
                        if(inv.Items[i].Item.ItemId == 144 || inv.Items[i].Item.ItemId == 231)
                        {
                            hurt.BroadcastChat(session.Name+" just logged out with their DetCaps/C4....What a DOUCHE");
                            break;
                        }
                    }
                }
            }
        }
    }
     
  10. Wulf

    Wulf Community Admin

    Top reference isn't needed by the way. ;)