Random Chitchat 2012-2016
Which OnRightClicked() do you mean? There's only OnPlayerRightClickingEntity() and there's a reason for it to give a cPlayer - only players may right-click other entities. So what are you trying to accomplish here?
Thanks given by:
In Wolf.h I have
cEntity * m_bOwner;
void SetOwner(cEntity * a_Entity = NULL) { m_bOwner = a_Entity; }
so that other entities can have a dog using plugins, but because of that I can't use
SetOwner(a_Player);
in Wolf.cpp.
Thanks given by:
You can. cPlayer IS a cEntity, so once you fix the indirections, it will work. SetOwner() is expecting a pointer, you're (probably) giving it a reference.
SetOwner(&a_Player);
should work
Thanks given by:
It was that simple.. Thanks Wink
Thanks given by:
Also, I think you should get rid of the default param for SetOwner(). It doesn't make sense that we even allow a call to SetOwner without the param; and if we want to remove ownership, we want to have it explicit: SetOwner(NULL)
Thanks given by:
I've commited my changes to an branch: https://github.com/mc-server/MCServer/tree/WolfUpdate
Thanks given by:
Problem with this code is that once the owner disconnects from the server, the wolf will crash - it has a pointer to an object that's no longer there. And when the player reconnects, there's no way they can re-claim their wolves.
I think it'd be better to store the owner's name. That way it won't crash and it will survive a reconnect; a name can also be saved to the world file. Your best bet would be to check the NBT structure in vanilla to see how it does this.
Thanks given by:
Now you mention it thats a big problem. I gues my idea to make other entities have wolves isn't going to work ;( Could you them maybe explain how to create an callback? So I can use it in cWorld::FindAndDoWithPlayer().
Thanks given by:
I created an callback but I get spammed with the message
Quote:[17:34:41] Compared STR_Warrior and STR_Warrior with rating 11
Thanks given by:
That's the string comparison function having some debugging output. Why are you using "FindAndDoWithPlayer()"? That one does similarity comparison, you want exact-matching, so DoWithPlayer() should be the right one.

What are you using the callback for anyway? Is that even needed?
Thanks given by:




Users browsing this thread: 18 Guest(s)