Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool HandleGameObjectHausCommand(ChatHandler* handler, char const* args)
- {
- uint32 objectId = 1234;
- const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
- Player* player = handler->GetSession()->GetPlayer();
- float x = float(player->GetPositionX());
- float y = float(player->GetPositionY());
- float z = float(player->GetPositionZ());
- float o = float(player->GetOrientation());
- Map* map = player->GetMap();
- GameObject* object = new GameObject;
- uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
- if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
- {
- delete object;
- return false;
- }
- // fill the gameobject data and save to the db
- object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn());
- // this will generate a new guid if the object is in an instance
- if (!object->LoadGameObjectFromDB(guidLow, map))
- {
- delete object;
- return false;
- }
- // TODO: is it really necessary to add both the real and DB table guid here ?
- sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow));
- handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), guidLow, x, y, z);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement