Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Player Health - Puzzled #84570
08/04/06 17:17
08/04/06 17:17
Joined: Apr 2004
Posts: 82
Pirate Utopia
marxist_reloaded Offline OP
Junior Member
marxist_reloaded  Offline OP
Junior Member

Joined: Apr 2004
Posts: 82
Pirate Utopia
When the player's health drops below zero I want to show some splash screens then end the game. I am trying to do this in the main game loop which begins while(1). But when I try to access player health, I get an empty pointer error.

The value I'm using for player health is plBiped01_entity._health__003 This appears to be the correct variable because I use it in a panel in the main function outside of the main game loop, and the correct health is displayed in the panel. But when I do if(plBiped01_entity._health__003 < 0){ do something here} in the main game loop I get an empty pointer error. I am very puzzled. Help appreciated


GameStudio Commercial 6.40.5 / WED V6.731 / MED 6.814
Re: Player Health - Puzzled [Re: marxist_reloaded] #84571
08/04/06 19:27
08/04/06 19:27
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
before using the pointer, check whether it's valid

while(...)
{
...
if(plBiped01_entity != null)
{
Do your stuff
}
...
}

Re: Player Health - Puzzled [Re: Claus_N] #84572
08/06/06 03:18
08/06/06 03:18
Joined: Apr 2004
Posts: 82
Pirate Utopia
marxist_reloaded Offline OP
Junior Member
marxist_reloaded  Offline OP
Junior Member

Joined: Apr 2004
Posts: 82
Pirate Utopia
Thanks. Yes, I tried exactly that

Code:
 

if(plBiped01_entity._health__003 != NULL)
{

//do something here with player health plBiped01_entity._health__003

}




The game starts up OK but immediately after loading I still get a W1501 error message saying that plBiped01_entity._health__003 is an empty pointer. If I click OK on the error message the game proceeds perfectly. This doesn't seem logical to me.

Anyhow it got me thinking that the issue only comes up in the first game loop. I added a counter to check for the first game loop and no empty pointer error!

Code:
 
if(loop_count > 1)
{
//do something here with player health plBiped01_entity._health__003

}




And it worked! I'm relieved I've solved the problem but still don't understand why the checking for the NULL pointer didn't work.


GameStudio Commercial 6.40.5 / WED V6.731 / MED 6.814
Re: Player Health - Puzzled [Re: marxist_reloaded] #84573
08/06/06 10:06
08/06/06 10:06
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Quote:

if(plBiped01_entity._health__003 != NULL)



you are checking whether the SKILL is null (though a skill can't have this value ;P), you need to check whether the ENTITY is null

if(plBiped01_entity != NULL)

Re: Player Health - Puzzled [Re: Claus_N] #84574
08/08/06 04:07
08/08/06 04:07
Joined: Apr 2004
Posts: 82
Pirate Utopia
marxist_reloaded Offline OP
Junior Member
marxist_reloaded  Offline OP
Junior Member

Joined: Apr 2004
Posts: 82
Pirate Utopia
Yes, of course! Thanks for that. Works fine now.


GameStudio Commercial 6.40.5 / WED V6.731 / MED 6.814

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1