[Support] Increase each player's score at the start of each new round in zombie mode !Help

Topic created · 14 Posts · 137 Views
  • Someone to help me how to implement that at each start of a new round each player is added 1000 more in addition to their current score, and so at each start of a new round

  • self.score+=1000;

  • @Xerxes I don't mean how to increase, I mean the end of round event

  • @Kalitos You will want to wait for end_of_round.

    level waittill( "end_of_round" );

  • @Xerxes At the end of the round each player is automatically assigned an additional 1000 points
    I tried this:

    
    init ()
    {
    level.clientid = 0;
    level.perk_purchase_limit = 9;
    level.infoHud = level createServerText ("default", "^ 2TeamSpeak 3: ^ 774.91.112.216", 1.5, "TOPLEFT", "TOPLEFT", 0, 0, (1, 1, 1), undefined, 1, undefined) ;
    level thread onplayerconnect ();
    thread addScore ();
    drawZombiesCounter ();
    thread gscRestart ();
        thread setPlayersToSpectator ();
        for (;;)
        {
            level waittill ("connected", player);
            if (level.scr_zm_ui_gametype_group == "zencounter" || level.scr_zm_ui_gametype_group == "zsurvival")
            {
           player thread give_team_characters (); // the real cause of the invisible player glitch these 2 functions aren't always called on map_restart so call them here
           }
           else
          {
          player thread give_personality_characters (); // this has to commented out when loading nuketown
    // unfortunately nuketown is the only map without this function therefore it can't find it and the server will throw an error
    // the only way to fix this would be to copy both give_team_characters () and give_personality_characters () into this file and account for all maps
    // this would make the fix more cumbersome which is why I haven't done it
          }
        }
    }
    addScore ()
    {
    level endon ("end_of_round");
            // self endon ("disconnect");
    
    for (;;)
    {
    self.score + = 1000;
    }
    }
    
    

    But it does not work, it is no more or load

  • Well yeah obviously it won't work like that.
    I don't spoonfeed but gave you all the infos you need now you need to write the stuff around it.

  • @Xerxes I've been trying and can't figure out the syntax or code structure for this to work.
    I'll just say "F"

    init()
    {
    level thread addScore();
    }
    addScore()
    {
    	level waittill ("end_of_round" );
            //self endon( "disconnect" );
    	
    	for(;;)
    	{
    		self.score+=1000;
    	}
    	level notify("end_of_round" );
    }
    

    With this, I kill the last zombie and the round stays there, it never ends.

  • @Kalitos the for loop?

  • @H3X1C i don't understand

  • @Kalitos Your codeblock basicially says add 1000 score over and over as fast as possible forever... How could it ever reach the statement below the forloop?

  • @H3X1C

    I fixed it

    init()
    {
    	level.clientid = 0;
            level thread onplayerconnect();
    }
    onplayerconnect()
    {
    	for ( ;; )
    	{
    		level waittill( "connecting", player );
    		player.clientid = level.clientid;
    		player thread onplayerspawned();
    		level.clientid++;
    	}
    }
    onplayerspawned()
    {
    	level endon( "game_ended" );
            self endon( "disconnect" );
    	
    	for(;;)
    	{
    		self welcome();
    		self addScore();
    	}
    }
    addScore()
    {
    	while (1) 
    	{
    	level waittill("between_round_over");
    	//self iprintln("More Score");
    	self.score+=1500;
    	}
    }
    

    I adapted it to the code that I already had implemented, the addScore function is what allows me to increase each round.

  • I feel your use of loops is unnecessary, wasteful and most definitely not performant. Why not just append x score at the end of the round?

    for(;;)
    {
    	self welcome();
    	self addScore();
    }
    

    This is the part that confuses me. Why loop this? Just call it once on spawn.

    This will execute every time the round ends which is fine:

    while (1) 
    {
    level waittill("between_round_over");
    //self iprintln("More Score");
    self.score+=1500;
    }
  • @H3X1C As the saying goes, if it works don't touch it 😊

  • That doesn't apply to writing code, even if you write proper code you probably revisit at some point to add additional functionality. But yeah do a few more of those mods and your server will be laggy af.

Log in to reply