1. Code:
            [ChatCommand("npctp_add")]
            void cmdNpcAdD(BasePlayer player, ulong args)
            {
           
            var n = npcData.NpcTP;
            double timeStamp = GrabCurrentTime();
            ulong ID2 = player.userID;
           
           
                if (!n.ContainsKey(ID2))
                    n.Add(ID2, new NPCInfo((long)timeStamp));
                    SaveNpcTpData();
                }             
    what is the correct way to change the args to ulong in ulong ID2 = args? im lost for a few hours on this.
     
  2. Wulf

    Wulf Community Admin

    You are not using valid arguments for the chat command. It is BasePlayer player, string command, and string[] args. You do not convert them in there, you convert them inside your hook as necessary using things such as (long), Convert.ToUInt64, ulong.Parse, ulong.TryParse, etc.

    The args is a string[] array, which means it contains multiple strings. If you are unfamiliar with this aspect of C#, I'd recommend taking a look at https://www.dotnetperls.com/array.
     
  3. Code:
            [ChatCommand("npctp_add")]
            void cmdNpcAdD(BasePlayer player, string command, string[] args)
            {
           
            var n = npcData.NpcTP;
            string ID2 = "";
            ID2 = Convert.ToUInt32(args);
            double timeStamp = GrabCurrentTime();
           
           
                if (!n.ContainsKey(ID2))
                    n.Add(ID2, new NPCInfo((long)timeStamp));
                    SaveNpcTpData();
                }    
    im just not reading something right i have also tried ID2 = ((ulong)args);
     
  4. Wulf

    Wulf Community Admin

    Please take a look at the link I posted on what string arrays are in C#.
     
  5. Code:
            [ChatCommand("npctp_add")]
            void cmdNpcAdD(BasePlayer player, string command, string[] args)
            {
           
            var n = npcData.NpcTP;
            string IDNPC = "";
           
            double timeStamp = GrabCurrentTime();
            IDNPC = string.Join(" ", args);
            ulong IDNPC1 = Convert.ToUInt64(IDNPC);
           
                if (!n.ContainsKey(IDNPC1))
                    n.Add(IDNPC1, new NPCInfo((long)timeStamp));
                    SaveNpcTpData();
                }            
           
    Thanks hows this look its working but is it ok how i did it?
     
  6. Wulf

    Wulf Community Admin

    Now you're trying to convert ALL the strings including spaces into a ulong, which will likely produce unwanted results. If you only want the first argument, use args[0].
     
  7. Thanks.