Jump to content

Recommended Posts

Posted

Hey mates

MessageReceiveCallback does not seem to work with an entity Loaded from a file!

Anyone experienced that as well? Or maybe found a solution?

I would be happy to hear one :)

 

Cya

TEntity Cube = LoadModel("abstract::tree.gmf");
SetEntityCallback(Cube,(byte*)MessageReceiveCallback,ENTITYCALLBACK_MESSAGERECEIVE);

And
void _stdcall MessageReceiveCallback( TEntity entity, str message, byte* extra ) 
{
char str[256];
sprintf(str, "%d got a message. Message name: \"%s\"", (int)entity, message);
MessageBox(0, str, "MessageReceiveCallback called", 0);
}

It does work correctly if i don't load the file but use CreateCube(0);

Posted

shouldn't you be using TModel name = ?

 

Then EntityType(name, 1)

I don't know if that will make a difference on your messages or not.

AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD

76561197984667096.png

Posted

Nope that does not help =( Thanks anyway

P.S. i did not put the whole code in here:

8code]

TModel Cube = LoadModel("abstract::oldtree.gmf");

SetEntityKey(Cube,"Health","100");

EntityColor(Cube,Vec4(1,1,1,255));

ScaleEntity(Cube,Vec3(1,5,1));

PositionEntity(Cube,Vec3(x,y-1.25,z));

EntityType(Cube,1);

SetEntityCallback(Cube,(byte*)MessageReceiveCallback,ENTITYCALLBACK_MESSAGERECEIVE);

[/code]

Posted

Where are you sending the message to the entity? Can we see that code?

 

if (KeyHit(KEY_E)==1){
if((CameraPick(&pick, cam,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,1),50))!= NULL){
	SendEntityMessage(pick.entity, "Open");
}
}

Posted

pick.entity from what I remember returns the mesh not the model. Try GetParent(pick.entity), or it's the other way around. Anyway, it has to do with that. A better test would be to step through the code and see what value your model returns after you load it, and then see what value pick.entity returns and what value GetParent(pick.entity) returns.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...