• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

TrinityCore 3.3.5 Custom Gameobject Command - delete nearest Object

Meistro

New member
Hei Emudevs :)

Info: I´m using TrinityCore merged with Eluna - the latest version.

I have a small problem about deleting Gameobjects since its so annoying to delete a specified Object.

Its alot of work to write down The gobject GUI everytime when you want to delete a wrong placed object.


well this is what I did, trying to make life easier,


I added a ChatCommand in gobjectCommandTable

Code:
{ "delclosest",  rbac::RBAC_PERM_COMMAND_GOBJECT_DELCLOSEST,  false, &HandleGameObjectDelclosestCommand,   ""	   },


Then Added The Handler to it... like this



Code:
//delete object without selecting any guid


    static bool HandleGameObjectDelclosestCommand(ChatHandler* handler, char const* args)
    {
           GameObject* object = handler->GetNearbyGameObject();

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        ObjectGuid ownerGuid = object->GetOwnerGUID();
        if (ownerGuid)
        {
            Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
            if (!owner || !ownerGuid.IsPlayer())
            {
                handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), guidLow);
                handler->SetSentErrorMessage(true);
                return false;
            }

            owner->RemoveGameObject(object, false);
        }

        object->SetRespawnTime(0);                                 // not save respawn time
        object->Delete();
        object->DeleteFromDB();

        handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetSpawnId());

        return true;
    }

I also created a new permission in RBAC.h :


Code:
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYSCENE = 844, // not on 3.3.5a
RBAC_PERM_COMMAND_GO_OFFSET = 845,
[COLOR="#FF0000"]RBAC_PERM_COMMAND_GOBJECT_DELCLOSEST = 1012,[/COLOR]


    // custom permissions 1000+
    RBAC_PERM_MAX
};

red: the new one


and finaly I created these one for the Database


Code:
USE auth 
INSERT INTO `rbac_linked_permissions` VALUES (192, 1012); 
INSERT INTO `rbac_permissions` VALUES (1012, 'Command: gobject delclosest'); 
USE world
INSERT INTO `command` VALUES ('gobject delclosest', 1000, 'Syntax: .gobject delclosest deletes nearest gobject in world and delete it from DB.');


Well, 1. I recompiled 2. then I just used the released stuff. is it wrong ? is anything I should do after all these. or maybe everything wrong ?

Thanks in advance for your patience and any kind of Help.

greats :RpS_smile:
 

Rochet2

Moderator / Eluna Dev
btw. just in case you did not know, it is intended that you can do .gobject target and then you open the chat and write .gobject delete and then you should press shift and click the white link that you got from .gobject target. Then press enter.
 

Meistro

New member
aw thank you :) better then nothing.

still would interesst me if what I wrote was correct or not :/ ... ^^

greats :)
 

Rochet2

Moderator / Eluna Dev
Looks fine to me I guess. I would have been lazy and used an existing permission though :p

Btw. "INSERT INTO `command` VALUES ('gobject delclosest', 1000, 'Syntax: .gobject delclosest deletes nearest gobject in world and delete it from DB.');"
The 1000 here should be 1012 right? Im not quite sure what that permission ID is used for though.
 

Meistro

New member
Looks fine to me I guess. I would have been lazy and used an existing permission though :p

Haha normaly I am lazy too but i just want to know some new things ^^.


Btw. "INSERT INTO `command` VALUES ('gobject delclosest', 1000, 'Syntax: .gobject delclosest deletes nearest gobject in world and delete it from DB.');"
The 1000 here should be 1012 right? Im not quite sure what that permission ID is used for though .

Ahh yes i think this should be 1012 just to link the created one inside RBAC and those other C++ things

Okei emm I compiled it and recompiled and again and again ... well it is not working...

So I just did what you said at the beginning. In addition to That I found an Addon called " GM Genie". Its doing What I want haha xD.

Life is hard man lol

Greats
 
Top