Announcement

Collapse
No announcement yet.

Possible to have a coop server auto restart when 'end' has been won?

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

  • #76
    I will help out some more tomorrow when I get some time. I need sleep and have some work I need to finish on my end with some QC. I hope i've been helpful and I know we'll get this thing working! You have a lot of dedication! Good night! Thanks for sticking with my less than technical explanations and lack luster code examples. LOL!

    Comment


    • #77
      Looking that warp code you uploaded, I don't see how a map is actually voted for. There seems to be impulses for yes and no votes, but that's all I'm finding.

      -r0t.uk- cOOp - Mapvote - r0t.uk:26001
      -r0t.uk- DM - Mapvote - r0t.uk:26000

      Comment


      • #78
        Well I fixed it. I came across this little wonder:

        KRIMZON SV PARSECLIENTCOMMAND - Quake Wiki

        I'm not sure if will compile on anything but DP, but none DP'ers can always use impulse.

        My vote.qc now:
        Code:
        string vote_map[10];
        entity vote_timer;
        
        void() init_mapvote;
        void() init_aliases;
        void() init_maps;
        void(string s1, string s2, string s3, string s4, string s5, string s6) xprint;
        float map_to_index(string maps);
        void() vote_start;
        void() end_vote;
        void(string s) SV_ParseClientCommand;
        void() countdwn_10;
        float NumberPlayers();
        
        float() NumberPlayers =
        {
            local entity bob;
            local float num;
        
            // Player counter
            bob = find (world, classname, "player");
        
            while (bob != world)
            {
                if (bob.classname == "player")
                    num += 1;
        
                bob = find (bob, classname, "player");
            }
        
            return num;
        };
        
        void() init_mapvote =
        {
            init_aliases();
            init_maps();
            vote_timer = spawn();
        }
        
        // Eventually this will go in maplist.qc
        void() init_aliases =
        {
            local float i;
        
            for (i=0; i<10 && vote_map[i] != ""; i+=1)
            {
                stuffcmd(self, "alias ");
                stuffcmd(self, vote_map[i]);
                stuffcmd(self, " cmd \"votemap ");
                stuffcmd(self, vote_map[i]);
                stuffcmd(self, "\"\n");
            }
        };
        
        void() init_maps =
        {
            vote_map[0] = "start";
            vote_map[1] = "end";
        };
        
        void(string s1, string s2, string s3, string s4, string s5, string s6) xprint =
        {
            bprint(s1);
            bprint(s2);
            bprint(s3);
            bprint(s4);
            bprint(s5);
            bprint(s6);
            bprint("\n");
        };
        
        float(string map) map_to_index =
        {
            local float i;
        
            for (i=0; i<10; i+=1)
            {
                if (vote_map[i] == map)
                    return i;
            }
        
            return -1;
        };
        
        void() vote_start =
        {
            bprint("^2A map vote has been started\n");
            bprint("^2Type 'maplist' to list the choices\n");
            bprint("^2Type a map name to vote\n");
            votestarted += 1;
            
            // 60 secs total voting time + a notice at 10 secs left
            vote_timer.nextthink = time + 50;
            vote_timer.think = countdwn_10;
        };
        
        void() countdwn_10 =
        {
            bprint("^210 seconds left to vote...\n");
            vote_timer.nextthink = time + 10;
            vote_timer.think = end_vote;
        };
        
        void() end_vote =
        {
            local entity bob;
            local float mvotes[10];
            local float i;
            local float winner;
            local string winmap;
        
            bprint("^2The vote is now over\n");
        
            // Vote counter
            bob = find (world, classname, "player");
        
            while (bob != world)
            {
                if (bob.votemap != "")
                {
                    for (i=0; i<10; i+=1)
                    {
                        if (vote_map[i] == bob.votemap)
                            mvotes[i] += 1;
        
                    }
        
                    for (i=0; i<10; i+=1)
                    {
                        if (mvotes[i] > 0)
                        {
                            if (mvotes[i] > winner)
                            {
                                winner = mvotes[i];
                                winmap = vote_map[i];
                            }
                        }
                    }
        
                }
        
                bob = find (bob, classname, "player");
            }
        
            if (winmap != "")
            {
                xprint("^3",winmap,"^7 wins","","","");
                changelevel(winmap);
            }
        
            else
            {
                // go to next map I guess
                bprint("^2No clear result, so going to next map in list");
            }
        };
        
        void(string s) SV_ParseClientCommand =
        {
            local float args;
            local string c;
            local string d;
            local float m;
            local float i;
            local entity bob;
            local float mvotes[10];
            local float voters;
        
            args = tokenize(s);
            c = argv(0);
            d = argv(1);
        
            if (c == "votemap")
            {
                if (d != "")
                {
                    m = map_to_index(d);
        
                    if (m >= 0)
                    {
                        self.votemap = vote_map[m];
        
        
                        xprint("^2", self.netname, "^7 voted for ^3", self.votemap,"","");
        
                        bob = find (world, classname, "player");
        
                        while (bob != world)
                        {
                            if (bob.votemap != "")
                            {
                                for (i=0; i<10; i+=1)
                                {
                                    if (vote_map[i] == bob.votemap)
                                        mvotes[i] += 1;
                                }
        
                                voters += 1;
                            }
        
                            bob = find (bob, classname, "player");
                        }
        
                        if (voters >= NumberPlayers()/2 && !votestarted)
                            vote_start();
        
                        for (i=0; i<10 && mvotes[i] > 0; i+=1)
                        {
                            xprint(ftos(mvotes[i]), " vote(s) for ", vote_map[i], "","","");
                        }
                    }
                }
            }
        
            else clientcommand(self, s);
        };
        No maps setup yet apart from start and end. But it all works fine so far, although it doesn't handle tie situations yet.

        It doesn't need periodic checks to get input as SV_ParseClientCommand will handle any client input.

        -r0t.uk- cOOp - Mapvote - r0t.uk:26001
        -r0t.uk- DM - Mapvote - r0t.uk:26000

        Comment


        • #79
          Ok I have found what is causing the huge network activity noticed by Mr Burns and r00k, and it turns out to be the SV_ParseClientCommand function. The server starts sending at around 30 K/s.

          Just commenting it out puts things back to normal. Looks like impulse may have to stay.

          -r0t.uk- cOOp - Mapvote - r0t.uk:26001
          -r0t.uk- DM - Mapvote - r0t.uk:26000

          Comment


          • #80
            Oops! I wish I had noticed this post. Yeah that is a big nono The method with temp1 would work and the example code I sent uses it. In fact, it uses it for almost all of it's additional aliases.

            Comment


            • #81
              Just been testing a few things and it looks like it was MOTD that was causing the traffic and memory use.

              Drawing the MOTD every PlayerPostThink was just too much.

              So we are back of track for mapvote

              Also, it doesn't seem possible using temp1, because all the docs I can find say that cvar and cvar_get *only* work on the server cvars, so it seems impossible for the server to read a client's cvar and take action.

              -r0t.uk- cOOp - Mapvote - r0t.uk:26001
              -r0t.uk- DM - Mapvote - r0t.uk:26000

              Comment


              • #82
                Originally posted by slackhead View Post
                Just been testing a few things and it looks like it was MOTD that was causing the traffic and memory use.

                Drawing the MOTD every PlayerPostThink was just too much.

                So we are back of track for mapvote

                Also, it doesn't seem possible using temp1, because all the docs I can find say that cvar and cvar_get *only* work on the server cvars, so it seems impossible for the server to read a client's cvar and take action.
                Ok I see your point now.... Hmm.... What is your current limit now?

                Comment


                • #83
                  AFAIK there is no limit except for the limit of elements in an array, which I don't know. But I have over 500 maps up. I doubt there will many more than that nowadays.

                  -r0t.uk- cOOp - Mapvote - r0t.uk:26001
                  -r0t.uk- DM - Mapvote - r0t.uk:26000

                  Comment

                  Working...
                  X