Removed Entity

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Removed Entity

Post by Opel » July 6th, 2011, 10:01 am

Hey guys, i don't get what is wrong with my code. I get an error saying "Removed entity is not an entity" with this line:

Code: Select all

self.stats[0] setValue(self.jmp["stats"]["saves"]);

Code: Select all

drawStats()
{
        self endon("disconnect");
        self endon("joined_spectators");
        self endon("death");
        
        self.stats = []; 
        
        self.stats[0] = newClientHudElem(self);
        self.stats[1] = newClientHudElem(self);
        self.stats[2] = newClientHudElem(self);
 
        self.stats[0].x = 350;
        self.stats[1].x = 350;
        self.stats[2].x = 350;
                
        self.stats[0].y = 100;
        self.stats[1].y = 115;
        self.stats[2].y = 130;
        
        self.stats[0].label = &"Saves: ";
        self.stats[1].label = &"Loads: ";
        self.stats[2].label = &"Bounces: ";
        
 
        for( i = 0; i < self.stats.size; i++ )
        {
                self.stats[i].alignX = "center";
                self.stats[i].alignY = "middle";
                self.stats[i].horzAlgin = "center";
                self.stats[i].vertAlgin = "top";
                self.stats[i].fontscale = 1.4;
                self.stats[i].hideWhenInMenu = true;
        }
 
        self thread updateStats();
}
 
updateStats()
{       
        self endon("disconnect");
        
        while(1)
        {
                wait 0.05;
        
                if( isDefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
        
                if( isDefined(self.jmp["stats"]["loads"]))
                        self.stats[1] setValue(self.jmp["stats"]["loads"]);
        }
        wait 0.05;
}
 
clearHuds()
{       
        for( i = 0; i < self.stats.size; i++ )
        {
                if(isDefined(self.stats[i]))
                        self.stats[i] destroy();
        }
}
 

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Removed Entity

Post by IzNoGoD » July 6th, 2011, 10:26 am

How do you call this code?
I think you use self the wrong way...

Else, try this:

Code: Select all

 
                if( isDefined(self.jmp) && isdefined(self.jmp["stats"]) && isdefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
        
                if( isDefined(self.jmp) && isdefined(self.jmp["stats"]) && isdefined(self.jmp["stats"]["loads"]))
                        self.stats[1] setValue(self.jmp["stats"]["loads"]);
LMGTFY!

Its not a glitch... Its the future!

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Removed Entity

Post by Opel » July 6th, 2011, 11:40 am

Thanks for the help but it didn't seem to fix it, but i did manage to fix it by replacing

Code: Select all

if( isDefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
with

Code: Select all

if( isDefined(self.stats[0]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Removed Entity

Post by IzNoGoD » July 6th, 2011, 11:54 am

Code: Select all

 
updateStats()
{       
        self endon("disconnect");
        self endon("stop_updating");
        while(1)
        {
                wait 0.05;
        
                if( isdefined(self.stats[0])&&isDefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
        
                if( isdefined(self.stats[1])&&isDefined(self.jmp["stats"]["loads"]))
                        self.stats[1] setValue(self.jmp["stats"]["loads"]);
        }
        wait 0.05;
}
 
clearHuds()
{       
        self notify("stop_updating");
        for( i = 0; i < self.stats.size; i++ )
        {
                if(isDefined(self.stats[i]))
                        self.stats[i] destroy();
        }
}
Added some stuff
Should work, even with the old line you used.
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Removed Entity

Post by Drofder2004 » July 7th, 2011, 7:19 pm

It has been a while since I have tested it, but I believe all HUDs should be initialised and followed by a 'wait 0.05;' to allow time for the HUD to be created, before any stats are passed. Although, I could be wrong.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Removed Entity

Post by IzNoGoD » July 7th, 2011, 8:41 pm

Drofder2004 wrote:It has been a while since I have tested it, but I believe all HUDs should be initialised and followed by a 'wait 0.05;' to allow time for the HUD to be created, before any stats are passed. Although, I could be wrong.
You are wrong :)
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Removed Entity

Post by Drofder2004 » July 8th, 2011, 12:17 am

IzNoGoD wrote:
Drofder2004 wrote:It has been a while since I have tested it, but I believe all HUDs should be initialised and followed by a 'wait 0.05;' to allow time for the HUD to be created, before any stats are passed. Although, I could be wrong.
You are wrong :)
Noted.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests