1. Hello, i am very new to this and i experimenting on some hooks to wrote a plugin.
    i want use this as example
    Code:
    void OnLootEntity(BasePlayer player, BaseEntity entity)
    {
        Puts("OnLootEntity works!");
    }
    
    if player start looting all good msg is come up, but if a player start looting ends it and agian start looting it will spam the server with the msg. so i want add something to avoid it for example 2-3 minutes.

    example: player start looting, the msg comes, and then it will not show the msg for 2-3minutes anymore, if the hook is calleds.

    thx in advance
     
  2. Wulf

    Wulf Community Admin

    Add a variable that stores when the hook was last ran, then check that each time the hook is called to see if it can be called again.
     
  3. i think i have found now a solution for it

    Code:
    DateTime lastLootStart = new DateTime(2009, 8, 1, 0, 0, 0);
    DateTime lastLootEnd = new DateTime(2009, 8, 1, 0, 0, 0);void OnLootEntity(BasePlayer player, BaseEntity entity)
    {
    if (lastLootEnd >= lastLootStart)
        {
                   lastLootStart = DateTime.Now;
                   lastLootStart = lastLootStart.AddSeconds(60);               Puts("OnLootEntity works!");
        }
    lastLootEnd = DateTime.Now;
    }
    or is there a better solution, i am very new to this and no know how for it :)
     
  4. Wulf

    Wulf Community Admin

    You can clean that up a bit yet, but that'd be essentially a way to do it. :)
     
  5. Something to keep in mind as I also started developing recently, this is going to affect all players.

    You may want to keep a running collection of players and their own loot times. Can implement easily with a structure like

    Code:
    public static Dictionary<ulong, DateTime> PlayerLootTimers = new Dictionary<ulong, DateTime>();
    Where ulong is the players id number

    :)!