Results 1 to 10 of 40

Thread: File handling

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    Well here's the file thing
    Code:
    load()
    {		
    	guid = self getGuid();
    	if(guid == 0)
    	    return;
    		
    	file = openFile(guid + ".txt", "read");
    	if(file != -1)
    	{
               freadln(file);
               self.ratio=int(fgetarg(file,0));
    	   closeFile(file);
    	}
    	
    	    else
    		{
                            self.ratio = 0;
    			self write();
    		}
    }
    
    write()
    {
    		
    	guid = self getGuid();
    	if(guid == 0)
    	    return;
    		
    	file = openFile(guid + ".txt", "write");
    	closeFile(file);
    	
    	file = openFile(guid + ".txt", "append");
    	fPrintln(file,self.ratio);
    	closeFile(file);
    }
    And the hud's like this
    Code:
    ratio()
    {
    	self endon("joined_spectators");
    	self endon("disconnect");
            self.ratio = self.score / self.deaths;
    	
    	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(self.ratio);
    }
    Hud is called at playerspawn, and load file is called at playerconnect

  2. The Following User Says Thank You to EvoloZz For This Useful Post:

    kung foo man (9th February 2013)

Posting Permissions

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