Simple entity properties crash

Posted By: Yking

Simple entity properties crash - 09/10/14 22:19

Hello everyone,

I seem to have a minor problem with SED, maybe I just sat too long in front of my Screen but I absolutely do not know, why I get a "Crash in Main" Alert Window everytime I run this simple code.


Quote:
#include <acknex.h>
#include <default.c>

#define Lifepoints skill1

ENTITY* Player; //Public Entity

function main()
{
Player.Lifepoints = 10;
}


I defined skill1 as Lifepoints so its easier to program with, it does not matter if I use Player.skill1 (that does not work either).
I created the Entity* Player before my Main-Code so its accessible from everywhere, placing it in the Main also does not work (Still getting a crash).

I must overlook something obvious but I dont know what shocked ,
is there someone who can help me? It would be very appreciated laugh !
Posted By: Kartoffel

Re: Simple entity properties crash - 09/10/14 22:59

1. your entity-pointer is empty (there's no entity it points to). you have to create an entity first. (I guess you'll need some more knowledge about what pointers do, how they work, etc.)
2. there already exists a pointer 'player' (no capital 'p'), you can use that
Posted By: AceX

Re: Simple entity properties crash - 09/11/14 06:30

You need to read the whole manual to understand how this engine works,and how to do a game.

And this is the code:

Code:
#include <acknex.h>
#include <default.c>

#define Lifepoints skill1

function main()
{
player = ent_create("your_player_model.mdl",vector(0,0,0),NULL);

player.Lifepoints = 10;
}



}
Posted By: Kartoffel

Re: Simple entity properties crash - 09/11/14 08:07

@^: you don't have to read the whole manual in order to understand it. The workshops are a better place to start.

also your example won't work because there's no level loaded. Besides that theres also nullvector which you can use instead of vector(0, 0, 0).
Posted By: AceX

Re: Simple entity properties crash - 09/11/14 08:55

Yeah,workshops is a better solution laugh

And my example show what he need .I think he already know some basics wink
Posted By: Yking

Re: Simple entity properties crash - 09/11/14 14:01

Thanks for all the help grin !!
I feel like an idiot now ^^
© 2024 lite-C Forums