gsc causing the server to suddenly crash

Topic created · 11 Posts · 87 Views
  • The code is pretty messed up, but since I used only one kill, score and zombie counter, it caused the server to restart. There is no pattern, it is suddenly, sometimes in very high rounds, sometimes with a few minutes in the game. Any suggestion?

    the code:

    #include maps\mp\_utility;
    #include common_scripts\utility;
    #include maps\mp\gametypes_zm\_hud_util;
    #include maps\mp\gametypes_zm\_hud_message;
    #include maps\mp\zombies\_zm_utility;
    #include maps\mp\zm_transit;
    #include maps\mp\zombies\_zm;
    
    init()
    { 
        level.start_weapon = "fiveseven_zm";
        level.player_starting_points = 2500; 
        level.perk_purchase_limit = 11;
        level.zombie_ai_limit = 40;
        level.zombie_actor_limit = 40;
        level.zombieMaxAi = 40;
        level thread onPlayerConnect();
        level thread drawZombiesCounter();
        thread gscRestart();
        thread setPlayersToSpectator();
        for(;;)
        {
            level waittill("connected", player);
    		player thread [[level.givecustomcharacters]]();
    	}
    }
    
    onPlayerConnect()
    {
        for(;;)
        {
            level waittill("connected", player);
            player thread healthPlayer();
            player thread killCount();
            player thread onPlayerSpawned();
            player thread showScore();
            player thread onPlayerRevived();
            player thread onPlayerDowned();
            newLimit();
        }
    }
    
    onPlayerSpawned()
    {
        self endon("disconnect");
        level endon("game_ended");
    
        for(;;)
        {
            self waittill("spawned_player", player);
            self iprintln("Vida maxima definida como^2 150");
            self iprintln("Limite de perks removido");
        }
    }
    
    onPlayerRevived()
    {
    	self endon("disconnect");
    	
    	for(;;)
    	{
    		self waittill( "player_revived", player);
    
    	}
    
    }
    onPlayerDowned()
    {
    	self endon("disconnect");
    	
    	for(;;)
    	{
    		self waittill("player_downed", player);
    	}
    }
    
    healthPlayer()
    
    {
    	self endon("disconnect");
    	self.healthText = createFontString("Objective" , 2); //Fixed
        self.healthText setPoint("CENTER", "BOTTOM", "CENTER", 3.5);
        while(true)
            {
            self.healthText setText( "^2HP: ^7"+ self.health);
    		if(self.maxhealth == 100)
    			{
    		    self.maxhealth = 150;
    	        }
            wait 0.1;
         	}
    }
    
    drawZombiesCounter()
    {
        level.zombiesCounter = createServerFontString("Objective" , 1.4);
        level.zombiesCounter setPoint("CENTER", "BOTTOM", -55, 20);
        level thread updateZombiesCounter(); 
    }
    
    updateZombiesCounter()
    {
        oldZombiesCount = get_current_zombie_count();
        while(true)
        {   	
            newZombiesCount = get_current_zombie_count();
            wait 0.4;
            if(oldZombiesCount != newZombiesCount)
            {
                level thread updateZombiesCounter();
                return;
            }
            else
            {
            	if(newZombiesCount != 0)
            		level.zombiesCounter.label = &"Zumbis: ^1";
            	else
            		level.zombiesCounter.label = &"Zumbis: ^5";
            	level.zombiesCounter setValue(newZombiesCount);
            }
        }
    }
    
    killCount()
    {
    	i = 0;
    
    	while( i < level.players.size)
    	{
    		if(level.players[i] == self)
    		{
    			self thread killCountSelf(level.players[i]);
    			self thread setAmmo(level.players[i]);
    		}
    		i++;
    		wait 0.2;
    	}
    }
    setAmmo(thisPlayer)
    {
    	self.nec = 20;
    	while(true)
    	{
    		currentWeapon = self getcurrentweapon();
    		ammoAdded = weaponclipsize( currentWeapon ) + self getweaponammostock( currentWeapon );
    		if( self.nec == thisPlayer.kills )
    		{
    			self setweaponammostock( currentWeapon, ammoAdded);	
    			self.nec += 20;
    		}
    		wait 0.5;
    	}
    }
    killCountSelf(thisPlayer)
    {
    	self.kill = createFontString("small" , 1.2); //Fixed
    	self.kill setPoint("CENTER", "BOTTOM", "CENTER", 20);
    	while(true)
    	{
    		self.kill.label = &"^3Baixas:  ^7";
    		self.kill setValue(thisPlayer.kills);
    		//currentWeapon = self getcurrentweapon();
    		//necessarios;
    		//baixas = thisPlayer.kills;
    		//ammoAdded = weaponclipsize( currentWeapon ) + self getweaponammostock( currentWeapon );
    		//if( necessarios == baixas )
    		//{
    		//	self setweaponammostock( currentWeapon, ammoAdded);
    		//}
    		wait 0.2;
    	}
    }
    
    showScore()
    {
    	self.scoreShow = createFontString("small" , 1.2); //Fixed
    	self.scoreShow setPoint("CENTER", "BOTTOM", 60, 20);
    	while(true)
    	{
    		self.scoreShow.label = &"^6Score:  ^7";
    		self.scoreShow setValue(self.score);
    		wait 0.1;
    	}
    }
    
    gscRestart()
    {
    	level waittill( "end_game" );
          	wait 12;
            map_restart( false );
    }
    
    setPlayersToSpectator()
    {
    	level.no_end_game_check = 1;
    	wait 3;
    	players = get_players();
    	i = 0;
    	while ( i < players.size )
    	{
    		if ( i == 0 )
    		{
    			i++;
    		}
    		players[ i ] setToSpectator();
    		i++;
    	}
    	wait 5; 
    	spawnAllPlayers();
    }
    
    setToSpectator()
    {
        self.sessionstate = "spectator"; 
        if (isDefined(self.is_playing))
        {
            self.is_playing = false;
        }
    }
    
    spawnAllPlayers()
    {
    	players = get_players();
    	i = 0;
    	while ( i < players.size )
    	{
    		if ( players[ i ].sessionstate == "spectator" && isDefined( players[ i ].spectator_respawn ) )
    		{
    			players[ i ] [[ level.spawnplayer ]]();
    			if ( level.script != "zm_tomb" || level.script != "zm_prison" || !is_classic() )
    			{
    				thread maps\mp\zombies\_zm::refresh_player_navcard_hud();
    			}
    		}
    		i++;
    	}
    	level.no_end_game_check = 0;
    }
    
    newLimit()
    {
    	level.get_player_weapon_limit = ::new_weapon_limit;
    }
    new_weapon_limit( player )
    {
    	  return 3;
    }
    
  • @broken168 said in gsc causing the server to suddenly crash:

    When server crash wich error you see? You see connection interupted? you get kicked with no messages? you get overflow error?

  • @Sorex The server breaks and restarts, automatically losing the connection to the host. I get the error "Oops! Plutonium T6 ran into a problem and must be closed" in the server cmd. Two files are generated, one .txt containing the error ```

    Exception Code: 0xC0000005
    Exception Address: 0x00000006
     
    

    and the other is a 600mb dmp file that I was unable to open to try to find the error. I used the initial script (hud with kill counter, score, health) from an old server in my region, and I was adding functions, and I found a post from the owner talking about the same error, but I couldn't apply the solution he proposed ( https://forum.plutonium.pw/topic/1312/is-there-anything-in-this-gsc-file-that-explains-eventual-crashes?_=1600180398764)

  • @broken168

    healthPlayer()
    
    {
    	self endon("disconnect");
    	self.healthText = createFontString("Objective" , 2); 
            self.healthText setPoint("CENTER", "BOTTOM", "CENTER", 3.5);
           self.healthText.label = &"^2HP:  ^7";
           while(true)
            {
    		self.healthText setValue(self.health);
            wait 0.1;
         	}
    }
    

    Try replacing this function. (rewritten to use setValue instead of setText as setText can cause overflows)

  • Did not work. The same error occurred.

  • @Cahz Aaa ... I simplified the code and went to try. I thought it was working, when, in round 21, the server hung up. I can't really see anything wrong with this code.

    #include maps\mp\_utility;
    #include common_scripts\utility;
    #include maps\mp\gametypes_zm\_hud_util;
    #include maps\mp\gametypes_zm\_hud_message;
    #include maps\mp\zombies\_zm_utility;
    #include maps\mp\zm_transit;
    #include maps\mp\zombies\_zm;
    #include maps\mp\zombies\_zm_stats;
    
    init()
    { 
        level.start_weapon = "fiveseven_zm";
        level.player_starting_points = 2500; 
        level.perk_purchase_limit = 9;
        level.zombie_ai_limit = 32;
        level.zombie_actor_limit = 32;
        level thread onPlayerConnect();
        level thread drawZombiesCounter();
    }
    
    onPlayerConnect()
    {
        for(;;)
        {
            level waittill("connected", player);
            player thread healthPlayer();
            player thread onPlayerSpawned();
            player thread showScore();
            player thread setAmmo();
            newLimit();
        }
    }
    
    onPlayerSpawned()
    {
        self endon("disconnect");
        level endon("game_ended");
    
        for(;;)
        {
            self waittill("spawned_player", player);
            self iprintln("MAX HEALTH DEFINED AS 150");
            self iprintln("PERK LIMIT REMOVED");
            wait 1;
            self iprintln("YOU RECEIVE AMMO EVERY 20 KILLS");
           
        }
    }
    
    healthPlayer()
    
    {
    	self endon("disconnect");
    	self.healthText = createFontString("Objective" , 2); 
        self.healthText setPoint("CENTER", "BOTTOM", "CENTER", 3.5);
        self.healthText.label = &"^2HP:  ^7";
        while(true)
        {
    		self.healthText setValue(self.health);
            if(self.maxhealth == 100)
            {
            	self.maxhealth = 150;
            }
            wait 0.1;
        }
    }
    
    drawZombiesCounter()
    {
        level.zombiesCounter = createServerFontString("small" , 1.4);
        level.zombiesCounter setPoint("CENTER", "BOTTOM", -55, 20);
        while(true)
        {
        	enemies = get_round_enemy_array().size + level.zombie_total;
            if( enemies != 0 )
            	level.zombiesCounter.label = &"Zombies: ^1";
            else
            	level.zombiesCounter.label = &"Zombies: ^6";
            level.zombiesCounter setValue( enemies );
            wait 0.2;
        }
    }
    
    setAmmo()
    {
    	self.nec = 20;
    	while(true)
    	{
    		currentWeapon = self getcurrentweapon();
    		ammoAdded = weaponclipsize( currentWeapon ) + self getweaponammostock( currentWeapon );
    		if( self.nec == self.pers[ "kills" ] )
    		{
    			self setweaponammostock( currentWeapon, ammoAdded);	
    			self.nec += 20;
    		}
    		wait 0.1;
    	}
    }
    
    
    showScore()
    {
    	self.scoreShow = createFontString("small" , 1.2); //Fixed
    	self.scoreShow setPoint("CENTER", "BOTTOM", 60, 20);
    	while(true)
    	{
    		self.scoreShow.label = &"^6Score:  ^7";
    		self.scoreShow setValue(self.score);
    		wait 0.1;
    	}
    }
    
    newLimit()
    {
    	level.get_player_weapon_limit = ::new_weapon_limit;
    }
    new_weapon_limit( player )
    {
    	  return 3;
    }
    
  • @broken168 https://drive.google.com/file/d/1kQDY_zuEuaSY2JjOPepzsxSSjfYrb_8H/view?usp=sharing Compile this script as _zm_bot.gsc and place it maps/mp/zombies. Include these dvars in your server config:

    set debugModTimescale 5
    set debugModPersonalGodMode 1
    

    Play on the server until it crashes with your mod installed. Next comment out features of your mod in order to determine what affects the stability of the server.

  • @JezuzLizard initially thank you. I did everything you said, but I can't connect to the server, I get the error "server disconnect - time out". after several attempts I was able to connect only once and was able to test, but I'm here again, trying to connect to the server and without success. the folder you shared has a .txt with other dvars, I tried to use them, but got the error "Server is full".

  • @broken168 I didn't say to use the other dvars from the dvars.txt. If you want to use them maybe read what each dvars name is so you what they do first. As for not being able to connect to the server with the mod loaded I don't have an answer. I use this mod all the time because it has several useful functions that I can enable with dvars making it convenient to use.

  • @JezuzLizard Really, I just tried to use it to see how it worked. I will keep trying.

  • @JezuzLizard Hey. I managed to make it work. I changed the value of debugModTimescale to 4, maybe I was not connecting because my pc is low-end.

    Thank you so much for your help.

Log in to reply