Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 40

Thread: File handling

  1. #11
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    How are you testing this? On a dedicated server? Or a local/listen server?

  2. #12
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Code:
            self.ratio = self.score / self.deaths;
    Thats causing divide-by-zero.


    Try something like:


    Code:
            if (self.deaths)
                self.ratio = self.score / self.deaths;
            else
                self.ratio = 0;
    timescale 0.01

  3. #13
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    Ofc on dedicated, and kung i dont think that is the problem because i have tried tracking other stuff, but same happened

  4. #14
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Could you try to iprintln the player.ratio after this line?

    Code:
    self.ratio=int(fgetarg(file,0));
    Thanks to Infinity Ward, we dont have any Builtin-Debugger.
    timescale 0.01

  5. #15
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    the server crashes right after choosing weapon, so i couldn't see it

  6. #16
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    If I were doing this, I would first get the hud working independently of the file function method. Then, once it's working correctly without any errors, I would introduce the file function method.

    Doing it that way will narrow the problems down. You will then be able to isolate any errors without having to determine what effect the other method is having on things.

    I'm saying this because I am pretty sure the hud code is not correct and is causing runtime errors. Sort that out first. Then move on to the file function method.

  7. The Following User Says Thank You to Tally For This Useful Post:

    kung foo man (9th February 2013)

  8. #17
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Ok, as I suspected, the ratio hud was a mess, so I wrote a test script in order to see what was crashing the server. And it was that you can't divide 0 by a 0. Below is the test script I wrote. I have no idea exactly what you are trying to do, so I just updated the value every frame. Obviously, you change that to suit your purposes. But the method is sound - don't update the value while self.ratio is zero (otherwise it throws an error) and only apply a division once both self.score and self.deaths are defined.

    This is what I ended up with:

    Code:
    init()
    {
    	level thread onPlayerConnect();
    }
    
    onPlayerConnect()
    {
    	for( ;; )
    	{
    		level waittill( "connected", player );
    		
    		player thread onPlayerSpawned();
    		player thread onPlayerKilled();
    	}
    }
    
    onPlayerSpawned()
    {
    	self endon( "disconnect" );
    	
    	for( ;; )
    	{
    		self waittill( "spawned_player" );
    		
    		self thread ratio();
    	}
    }
    
    onPlayerKilled()
    {
    	self endon( "disconnect" );
    	
    	for( ;; )
    	{
    		self waittill( "killed_player" );
    		
    		if( isDefined( self.ratiohud ) ) 
    			self.ratiohud destroy();
    	}
    }
    
    ratio()
    {
    	self endon( "killed_player" );
    	self endon( "disconnect" );
    	
    	if( isDefined( self.ratiohud ) ) self.ratiohud destroy();
    	
    	if( !isDefined( self.ratiohud ) )
    	{
    	    self.ratiohud = newClientHudElem( self );
    		self.ratiohud.vertAlign = "fullscreen";
    		self.ratiohud.horzAlign = "fullscreen";
    		self.ratiohud.alignX = "left";
    		self.ratiohud.alignY = "middle";
    		self.ratiohud.x = 25;
    		self.ratiohud.y = 474;
    		self.ratiohud.sort = 1; 
    		self.ratiohud.alpha = 1;
    		self.ratiohud.fontScale = 0.8;
    		self.ratiohud.archived = true;
    		self.ratiohud.label = (game["ratio"]);
    		self.ratiohud setValue( 0 );
    	}
    	
    	for( ;; )
    	{
    		wait( 0.05 );
    		
    		self.ratio = self getRatio();
    		
    		if( !isDefined( self.ratio ) )
    			continue;
    		else
    		{
    			if( isDefined( self.ratiohud ) )
    				self.ratiohud setValue( self.ratio );
    		}
    	}
    }
    
    getRatio()
    {
    	value = undefined;
    	
    	if( !self.score && !self.deaths )
    		value = 0;
    	else if( self.score && !self.deaths )
    		value = self.score;
    	else if( self.score && self.deaths )
    		value = ( self.score / self.deaths );
    		
    	return( value );
    }
    Once you've got your hud working, you can then move on to using the file functions.

  9. The Following 2 Users Say Thank You to Tally For This Useful Post:

    EvoloZz (10th February 2013),kung foo man (9th February 2013)

  10. #18
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    That would work for the ratio, but as i already said, i also tried huds for other things and got the same error

  11. #19
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Quote Originally Posted by EvoloZz View Post
    Code:
    type undefined is not a float: (file 'maps/mp/gametypes/_tdm.gsc', line 585)
      self.ratiohud setValue(self.ratio);
    You got THIS error for other huds?
    timescale 0.01

  12. #20
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    Same expect the value was different of course

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •