Results 1 to 10 of 40

Thread: File handling

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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

  2. #2
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by EvoloZz View Post
    That would work for the ratio, but as i already said, i also tried huds for other things and got the same error
    Then you need to post all your other huds as well so we can see where you've gone wrong. If the other ones are like the one I just worked on, then it is because you aren't doing any checks on the values, and the game simply wont stand for it.

    The important thing is for you to post your code. If you don't post it, how are we supposed to help you? We are modders. Not mind readers. If you don't want to post your code, then don't expect any help. It really is as simple as that.

  3. #3
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    Okay here's just everything, all scripts, all errors, whatever you need

    _file.gsc:
    Code:
    init()
    {
        thread onPlayerConnect();
    }
    
    onPlayerConnect()
    {
        level waittill("connecting",player);
        player thread load();
    }
    
    load()
    {
    	guid = self getGuid();
    	
    	if(guid != 0)
    	{
    		file = openFile(guid + ".txt", "read");
    		if(file != -1)
    		{
    			freadln(file);
    			self.kills = int(fgetarg(file,0));
    			closeFile(file);
    		}
    		
    		else
    		{
    			self.kills = 0;
    			self write();
    		}
    	}
    
    	else if(guid == 0)
    		return;
    }
    
    write()
    {
    		
    	guid = self getGuid();
    	
    	if(guid != 0)
    	{
    		file = openFile(guid + ".txt", "write");
    		closeFile(file);
    	
    		file = openFile(guid + ".txt", "append");
    		fPrintln(file,self.kills);
    		closeFile(file);
    	}
    
    	else if(guid == 0)
    		return;
    }
    tdm.gsc:
    callback_startgametype
    Code:
    	thread maps\mp\gametypes\_file::init();
    callback_playerkilled
    Code:
    				attacker.kills++;
    				attacker maps\mp\gametypes\_file::write();
                                    attacker updatehud();
    updatehud
    Code:
    updateHud()
    {
        self.killhud setValue(self.kills);
    }
    spawnplayer
    Code:
    	self thread kills();
    hud
    Code:
    kills()
    {
    	self endon("joined_spectators");
    	self endon("disconnect");
    	
    	if(!isDefined(self.killhud))
    	{
    	       self.killhud = newClientHudElem(self);
    		self.killhud.vertAlign = "fullscreen";
    		self.killhud.horzAlign = "fullscreen";
    		self.killhud.alignX = "left";
    		self.killhud.alignY = "middle";
    		self.killhud.x = 25;
    		self.killhud.y = 474;
    		self.killhud.sort = 1; 
    		self.killhud.alpha = 1;
    		self.killhud.fontScale = 0.8;
    		self.killhud.archived = true;
    		self.killhud.label = (game["ratio"]);
    		self.killhud setValue(self.kills);
    	}
    }
    Error:
    Code:
    type undefined is not a float: (file 'maps/mp/gametypes/_tdm.gsc', line 589)
      self.killhud setValue(self.kills);
                                 *
    Well i still cant figure out whats the problem, and i have tried this all just without saving into file and it worked, but it doesnt work anymore.
    I think that the problem is because the file handle and hud arent connected to each other, so thats why hud doesnt understand what the fuck is self.kills.
    Last edited by EvoloZz; 10th February 2013 at 09:31.

Posting Permissions

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