1. So what i'm trying to do is if you take a look at the code at the bottom, i'm trying to make a command that when said /grind weed , if you stand still for 60 seconds it will give you 1 weed in your amount variable, take a look:
    Code:
    private float WeedGrindTimer = 60;
    private float WeedAmount;[ChatCommand("grind")]
            void cmdGrind(BasePlayer player, String Command, String[] arg)
            {
                switch (arg.Length)
                {
                    case 0:
                        PrintToChat("/grind help - for commands");
                        break;
                    case 1:
                        if(arg[0] == "weed")
                        {
                          
                        }
                        break;
                }
            }
    So in the if statement how would i make the player stand still for 60 seconds to gain + 1 in their WeedAmount
     
  2. Code:
    private Dictionary<ulong, Vector3> SavedPositions = new Dictionary<ulong, Vector3>();        [ChatCommand("grind")]
            void cmdGrind(BasePlayer player, String Command, String[] arg)
            {
                switch (arg.Length)
                {
                    case 0:
                    {
                        PrintToChat("/grind help - for commands");
                        break;
                    }
                    case 1:
                    {
                        if (arg[0].ToLower() == "weed")
                        {
                            if (!SavedPositions.ContainsKey(player.userID))
                                SavedPositions.Add(player.userID, player.transform.position);
                            else
                            {
                                PrintToChat(player, "You're already grinding weed");
                                return;
                            }
                            var repeatCount = 0;
                            timer.Repeat(1f, 60, () =>
                            {
                                if (SavedPositions[player.userID] != player.transform.position)
                                {
                                    PrintToChat(player, "It looks like you've moved, you need to stand still to grind weed.");
                                    SavedPositions.Remove(player.userID);
                                    return;
                                }
                                if (repeatCount == 59)
                                {
                                    PrintToChat(player, "You've sucessfully grinded your weed");
                                    SavedPositions.Remove(player.userID);
                                    // rest of your code here
                                    return;
                                }
                                repeatCount++;
                            });
                        }
                        break;
                    }
                }
            }
    Maybe something like this
     
  3. Maybe add a distance check instead of a != to tolerate a tad bit of movement? So if they move like 0.1m to the right they don't cancel it :p
     
  4. Yea the timer also needs destroying inside of the callback
     
  5. The Vector3 on the dictionary is an error, any reason why?
     
  6. Well showing the error would help, I assume it's because you need to add a "using UnityEngine;" though.
     
  7. Yeah i got it thanks bro =)
     
  8. Vector3.Distance would be better I thing =)
     
  9. Just depends if he wants to allow a bit of movement or not