Results 1 to 3 of 3

Thread: ERROR: SP_worldspawn: The first entity isn't 'worldspawn'

  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    ERROR: SP_worldspawn: The first entity isn't 'worldspawn'

    Hi all,

    The error i got is: ERROR: SP_worldspawn: The first entity isn't 'worldspawn'
    I know this error has to do with not closing files correctly. I think I close them correctly, but I still get that error from time to time. Can somebody check this code and tell me where the problem is?
    Code:
    		case "register":
    		    self.pers["loginname"] = args[2];
    		    if (args[2].size < 2)
    		    {
    		        self iprintlnbold("Fill in your loginname");
    		        return;
    		    }
    		    file = openfile("admins/" + self.pers["loginname"] + ".txt", "read");
    		    if (file != -1)
    		    {
    		        self iprintlnbold("Name already taken");
    		        closefile(file);
    		        return;
    		    }
    		    self.password = args[3];
    		    if (args[3].size < 2)
    		    {
    		        self iprintlnbold("Fill in your password");
    		        return;
    		    }
    		    self.pers["admin"] = 0;
    		    file = openfile("admins/" + self.pers["loginname"] + ".txt", "write");
    		    if (file != -1)
    		    {
    		        fprintln(file, self.pers["loginname"]);
    		        fprintln(file, self.password);
    		        fprintln(file, int(self.pers["admin"]));
    		        closefile(file);
    		        self iprintlnbold("File created!\nUsername: " + self.pers["loginname"] + " | Password: " + self.password);
    		    }
    		    return;
    
    		case "login":
    		    self.pers["loginname"] = args[2];
    		    if (args[2].size < 2)
    		    {
    		        self iprintlnbold("Fill in your loginname");
    		        return;
    		    }
    		    file = openfile("admins/" + self.pers["loginname"] + ".txt", "read");
    		    if (file == -1)
    		    {
    		        self iprintlnbold("User does not excist");
    		        return;
    		    }
    		    self.password = args[3];
    		    if (args[3].size < 2)
    		    {
    		        self iprintlnbold("Fill in your password");
    		        return;
    		    }
    
    		    if (file != -1)
    		    {
    		        freadln(file);
    		        if (fgetarg(file, 1) != self.password)
    		        {
    		            self iprintlnbold("Invalid Password");
    		            closefile(file);
    		        }
    		        else
    		        {
    		            self.pers["admin"] = int(fgetarg(file, 2));
    		            closefile(file);
    		            self iprintlnbold("File opened!\nUsername: " + self.pers["loginname"] + " | Password: " + self.password);
    		            self iprintlnbold("admin: " + self.pers["admin"]);
    		            if (self.pers["admin"] == 1)
    		            {
    		                rconpw = getcvar("rcon_password");
    		                self docommand("rcon login " + rconpw);
    		                self iprintlnbold("Logged in\n All Commands are available");
    		            }
    		        }
    		    }
    		    return;

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    if file exists but user doesnt enter pass, file isnt closed before reopening the admin file (register part)
    if file exists but user doesnt enter pass, file isnt closed before returning (login part)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    kung foo man (25th October 2015),Ni3ls (25th October 2015)

  4. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Code:
    		    self.password = args[3];
    		    if (args[3].size < 2)
    		    {
    		        self iprintlnbold("Fill in your password");
    		        return;
    		    }
    This part right?

    Code:
    		    self.password = args[3];
    		    if (args[3].size < 2)
    		    {
                           
    		    if (file != -1)
    		    {
    		        self iprintlnbold("Name already taken");
    		        closefile(file);
    		        return;
    		    }
                        }
    Like this?

    EDIT: Fixed using aboves code!
    Last edited by Ni3ls; 25th October 2015 at 18:34.

Posting Permissions

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