MrIslomaniac Posted February 9, 2010 Share Posted February 9, 2010 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); Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 9, 2010 Share Posted February 9, 2010 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. Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
MrIslomaniac Posted February 9, 2010 Author Share Posted February 9, 2010 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] Quote Link to comment Share on other sites More sharing options...
Rick Posted February 9, 2010 Share Posted February 9, 2010 Where are you sending the message to the entity? Can we see that code? Quote Link to comment Share on other sites More sharing options...
MrIslomaniac Posted February 9, 2010 Author Share Posted February 9, 2010 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"); } } Quote Link to comment Share on other sites More sharing options...
Rick Posted February 9, 2010 Share Posted February 9, 2010 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. Quote Link to comment Share on other sites More sharing options...
MrIslomaniac Posted February 9, 2010 Author Share Posted February 9, 2010 GetParent(pick.entity) did it =) never thought of that xD Thank you Rick Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 9, 2010 Share Posted February 9, 2010 Good call Rick... That's what we keep you around for. Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Rick Posted February 9, 2010 Share Posted February 9, 2010 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.