Announcement

Collapse
No announcement yet.

Parseing Chat in QC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parseing Chat in QC

    I would like to change my voting system so that players can type "!yes" or "!no" to vote in chat, rather than using impulses with aliases.

    I already have an idea to deal with this, but I would like to make sure if there isn't any existing variable I can use.

  • #2
    Hi SB
    I seem to recall that say !yes and say !no are already used for replying to "magic" based votes for map and setting changes on the NYC, Bigfoot, and Damage servers. So you unless you are running your own mod on a different server you may get some unexpected behaviour.
    Most basic Quake map voting systems already use yes/no so I'm just curious why do you want to add the exclamation mark (!) instead?

    Kind regards
    Monty
    Mr.Burns
    "Helping to keep this community friendly, helpful, and clean of spammers since 2006"
    WWW: Quake Terminus , QuakeVoid You Tube: QuakeVoid
    Servers: Quake.shmack.net, damage.servequake.com

    News: JCR's excellent ctsj_jcr map is being ported to OOT

    Comment


    • #3
      The exclamation point is there to specifically say that it is a command. This is standard stuff when you mess around with chatbots on anything, its just to make sure that no one accidentally votes or activates a command.

      I could leave it out, but it's just a good habit.

      Comment


      • #4
        Code:
        void(string s) SV_ParseClientCommand =
        {
            tokenize(s);
            if(argv(0) == "say" && argv(1) == "!yes")
                vote_notyes(self);
            else if(argv(0) == "say" && argv(1) == "!no")
                vote_notno(self);
            else
                clientcommand(self, s);
        };
        Some Game Thing

        Comment


        • #5
          cause we can and I am super bored. This also gave me some reason to bust out the full-size waterproof Bluetooth keyboard that can be rolled up and stuck in your pocket. It's not awesome beyond that. .

          Code:
          void(string s) SV_ParseClientCommand =
          {
              tokenize(s);
              if(argv(0) == "say")
              {
                  switch(argv(1))
                  {
                        case "!yes":
                            vote_notyes(self);
                            break;
                        case "!no":
                            vote_notno(self);
                            break;
                        default:
                            clientcommand(self, s);
                            break;
                  }
              }
          };
          Last edited by MadGypsy; 03-19-2017, 03:29 PM.
          http://www.nextgenquake.com

          Comment


          • #6
            Are the above solutions engine ubiquitous/agnostic?

            Comment


            • #7
              They are essentially identical solutions... Switch/Case can always be substituted for If/Else in languages that support it BUT to use switch/case you probably HAVE to use FTEQCC to compile. Other than that the code looks pretty vanilla to me.

              I opine that you realize the _not(yes/no) functions represent functions you need to write.

              Aside - you had me at parsing ... my favoritest thing. It's mildly funny cause I was like "ooooh stuff to parse" and then I was like ::teeth smack:: "This ain't a parse situation, man." You shattered all of my hopes and dreams... Lol
              Last edited by MadGypsy; 03-19-2017, 03:53 PM.
              http://www.nextgenquake.com

              Comment


              • #8
                Ah, okay.

                My only question is what tokenize() does, because I can't seem to find any documentation on it.

                Also, it seems that you guys haven't totally solved my problem, as I need to somehow get the players command for say. I see how its splitting the string and everything, but I still need to figure out how to actually get that input string for the function.

                So, how do look for and obtain the player's say command as a string?
                Last edited by SpecialBomb; 03-19-2017, 04:16 PM.

                Comment


                • #9
                  KRIMZON_SV_PARSECLIENTCOMMAND
                  the server calls SV_ParseClientCommand. the qc handles whatever it wants (with tokenize to parse the string), and calls clientcommand for anything it wants the engine to handle instead.
                  its quite simple in that regard.
                  obviously it IS a serverside extension, so requires a server that supports it. pretty much every engine that has qc extensions has that one at least.

                  mg's version is buggy, and would not allow you to even connect if it were not for hacks in the engine to work around such buggy mods. unfortunately this helps hide the bugs...
                  just make sure that you call clientcommand for ALL commands that you don't recognise, you can only skip it for things that you actually recognise and know are safe for the engine to ignore - like say commands (ignoring those will merely mute all the players!).
                  Some Game Thing

                  Comment


                  • #10
                    Why are switch/case statements buggy? I know your compiler accepts them. They are also a very common feature in a shit load of languages.

                    I really am trying to understand why switch/case would be any different than if/else considering they are practically equivalents of each other.
                    Last edited by MadGypsy; 03-19-2017, 08:35 PM.
                    http://www.nextgenquake.com

                    Comment


                    • #11
                      @My only question is what tokenize() does, because I can't seem to find any documentation on it.

                      tokenize splits the command into an array

                      tokenize("Hello World");
                      print(argv[0]); //Hello
                      print(argv[1]); //World

                      I'm assuming argv is a global array (available everywhere and to everything in QC) since it was just magically available to Spike's script.
                      http://www.nextgenquake.com

                      Comment


                      • #12
                        Back to the original question:

                        Far as I know, normal qc code never gets chat strings. Maybe it's possible with client-side qc, but I've never used it. However, darkplaces has "SV_ParseClientCommand" (as shown as the others here), but it's definitely not ubiquitous.

                        One route would be to edit the engine itself, which is how some euro servers handles voting (I bet).

                        Comment

                        Working...
                        X