problem with ent_createlocal

Posted By: wacek

problem with ent_createlocal - 01/26/10 12:08

Hello

I have simple code for create entity, but not works and I have no idea why.

Code:
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "pix";
#define PRAGMA_PATH "maps";
#define PRAGMA_PATH "models";

ENTITY* postac1 =
{
type = "postac1.mdl";
layer = 2;
x = 0;
y = 0;
z = 37;
flags = SHOW;
}
function main()
{
	level_load("level1.wmb"); //wczytuje pierwsza mape z wyborem postaci
	wait(-2);
	ent_createlocal(postac1, vector(0,0,37), NULL);
	
}



My model are in "models" folder.
as I run the program shows the error
"Can't open file"
Posted By: Helghast

Re: problem with ent_createlocal - 01/26/10 12:38

This is a common mistake, your making a view entity and try to create a world entity from that.
You dont need the ent_createlocal at all, they view entity will show up anyway.
Try it without that laugh

regards,
Posted By: KDuke

Re: problem with ent_createlocal - 01/26/10 12:39

It would be more like this:

Code:
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "pix";
#define PRAGMA_PATH "maps";
#define PRAGMA_PATH "models";

ENTITY* postac1 = null;

function main()
{
	level_load("level1.wmb"); //wczytuje pierwsza mape z wyborem postaci
	wait(-2);
	postac1 = ent_create("postac1.mdl", vector(0,0,37), NULL);
	
}



greetings K-Duke
Posted By: MrGuest

Re: problem with ent_createlocal - 01/29/10 02:43

Originally Posted By: KDuke
It would be more like this:

Code:
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "pix";
#define PRAGMA_PATH "maps";
#define PRAGMA_PATH "models";

ENTITY* postac1 = null;

function main()
{
	level_load("level1.wmb"); //wczytuje pierwsza mape z wyborem postaci
	wait(-2);
	postac1 = ent_create("postac1.mdl", vector(0,0,37), NULL);
	
}



greetings K-Duke
1stly, remove the ; you have after #define PRAGMA_PATH "pix" ("maps" and "models") this should then locate your model

Originally Posted By: Helghast
view entity will show up anyway.
Try it without that laugh

regards,
Incorrect.
View entities are always drawn based on the views position, if you're trying to create something that's always in 1 place on the camera, use a view entity, otherwise use ent_create, (or if you're doing multiplayer scripts use ent_createlocal, to make it appear only on the client (though ignore that for now)). You'll need to set flags2 = SHOW; instead of flags = SHOW;
and change the z = 37; to x = 37;

if you're trying to create a view entity,
Code:
ENTITY* postac1 =
{
type = "postac1.mdl";
layer = 2;
x = 0;
y = 0;
z = 37;
flags = SHOW;
}//change this to

ENTITY* postac1 =
{
type = "postac1.mdl";
layer = 2;
x = 37;
y = 0;
z = 0;
flags2 = SHOW;
}



if you want the entity specifically at (0, 0, 37) in world coordinates, use KDudes' example, but still remove the ; on lines 3,4 and 5

Hope this helps
© 2024 lite-C Forums