Roarl Posted January 14, 2016 Share Posted January 14, 2016 (edited) Hi there! How do you access the (player) user of a gameobject?For instance, let us consider this simple gameobject script :class go_chairofjudgmentgood : public GameObjectScript { public: go_chairofjudgmentgood() : GameObjectScript("go_chairofjudgmentgood") { } struct go_chairofjudgmentgoodAI : public GameObjectAI { uint32 goTimer; go_chairofjudgmentgoodAI(GameObject* go) : GameObjectAI(go) {} void Reset() { goTimer = 7000; } void UpdateAI(uint32 diff) override { GameObjectAI::UpdateAI(diff); if (goTimer <= diff) { //HERE } else goTimer -= diff; } }; GameObjectAI * GetAI(GameObject * go) const { return new go_chairofjudgmentgoodAI(go); } };Let us assume the object type of the chairofjudgmentgood is indeed a chair. How could I get the Player (class) of the player sitting on the chair at line 23 (//HERE)?Thanks in advance for your help Edited January 14, 2016 by Roarl Link to comment Share on other sites More sharing options...
Rangorn Posted January 14, 2016 Share Posted January 14, 2016 According To this : https://github.com/TrinityCore/TrinityCore/blob/6.x/src/server/game/Entities/GameObject/GameObject.cppThe code for Chairs and barbershop chair is something like that if (user->GetTypeId() != TYPEID_PLAYER) return; Player* player = user->ToPlayer(); Link to comment Share on other sites More sharing options...
Roarl Posted January 14, 2016 Author Share Posted January 14, 2016 That will do! Thanks dude! Link to comment Share on other sites More sharing options...
[SOLVED] Accessing the (player) user of a gameobject
By Roarlin Serverside
Recommended Posts