1. Hello all, im creating a timer that works using the every 1 second timer and giving of a non-existing item. My code is below: the error is that it doesent take into account multiple people using this. IF anyone has any ideas i beg of you to post them! Thanks in advanced ;)

    every second it increments the timer by one BTW

    Code:
    #region GiveTimer
            Oxide.Plugins.Timer GiveTimer;
            private void GivePlayerTime(BasePlayer player)
            {
            float time = 0;
            GiveTimer = timer.Repeat(1f, 0, () =>
            {
              if (currentPlayers.ContainsKey(player.UserIDString))
              {
                time++;
                player.SendConsoleCommand("note.inv", -1565095136, time, "Time");
                }
            });
            }
     #endregion
    
    Code:
    GivePlayerTime(player);
    GiveTimer.Destroy();
    
     
  2. Wulf

    Wulf Community Admin

    If you want to have a timer per player that is later destroyed, you’d need to add each timer usage to a dictionary by something unique to that player.
     
  3. Could you possibly give an example on what that would look like
     
  4. Basically something like this

    Code:
            [OnlinePlayers]
            private readonly Hash<BasePlayer, OnlinePlayer> _onlinePlayers = new Hash<BasePlayer, OnlinePlayer>();
            // You can find the current online player using `var curPlayer = _onlinePlayers[basePlayer]`        private class OnlinePlayer{
                    // -- All custom elements of a player --
                    // Add timer in here, a new instance of a timer will be created for each player
            }
    
     
  5. Not that kind of example to give someone being totally new to this, as of the fact that the BasePlayer object as Key is the most worst you could choose there; What you would know when you would'nt have simply copied some random code from anywhere.
    The userid, either as string or ulong, is much more consistent.
     
    Last edited by a moderator: Feb 5, 2018
  6. I don't think anyone will learn by blatantly giving them the answer (Unless the premise of stack overflow is wrong). What I gave was a step toward a right direction, not the right direction. Also, no, it's not the worst decision one could make. The list is there already, use it.

    If you're still interested in how a person gets a hint and does research off of it, please PM me, I'm open to discuss.
     
  7. Soty for offtopic but when will be new plugin approvals?