Vendor restricter

Hello, i was wondeing if i could get some assistense with a script i found, and i dont have any c++ experience, so i was wondering where i should put this script.

here is the script:

pPlayer->GetSession()->GetSecurity()
That is the pointer info. GetSecurity() will hold the security level.

if((pPlayer->GetSession()->GetSecurity()) >= 1 && (pPlayer->GetSession()->GetSecurity() <= 3)) {

//all the info fo if the account is between 1 and 3.

}

thanks,

joshua

You need to give more detail on what you want the script to do. That current script does absolutely nothing and if you do not have any C++ experience then there is no point in implementing it. My guess is you would need to put it in the Player.cpp but where depends on what you need it for. If I were you I would start Googling some C++ tutorials and get familiar with the Trinitycore coding style, otherwise I would say you are going no where with this.

Create “npc_gmvendor.cpp” in src/server/scripts/Custom/ with the following content:

[CODE]#include “ScriptPCH.h”

class npc_gmvendor : public CreatureScript

{

public:

npc_gmvendor() : CreatureScript("npc_gmvendor") { }


bool OnGossipHello(Player *pPlayer, Creature *pCreature)

{

    if (pPlayer->GetSession()->GetSecurity() > SEC_PLAYER)

        pPlayer->GetSession()->SendListInventory(pCreature->GetGUID());

    else

        pCreature->MonsterWhisper("Go away, $N!", pPlayer->GetGUID());


    return true;

}


bool OnGossipSelect(Player *pPlayer, Creature *pCreature, uint32 sender, uint32 action)

{

    if(!pPlayer->getAttackers().empty())

    {

        pPlayer->CLOSE_GOSSIP_MENU();

        pCreature->MonsterWhisper("Not while infight, $N!",pPlayer->GetGUID());

    }

    return true;

}

};

void AddSC_npc_gmvendor()

{

new npc_gmvendor();

}

[/CODE]

Edit src/server/scripts/Custom/CMakeLists.txt and add an entry for the newly created file.

Edit src/server/game/Scripting/ScriptLoader.cpp and add “void AddSC_npc_gmvendor();” after “/* This is where custom scripts’ loading functions should be declared. /" and add “AddSC_npc_gmvendor();” after "/ This is where custom scripts should be added. */” at the bottom of the file.

Rerun CMake and generate new projectfiles and recompile…

Use “npc_gmvendor” as ScriptName in the creature_template entry of the vendor.

this script aint working properly… the else declaration goes on. So even if your level 3, and you talk to it the npcs whispers you saying: “go away, name!”

[CODE]#include “ScriptPCH.h”

class npc_gmvendor : public CreatureScript

{

public:

npc_gmvendor() : CreatureScript("npc_gmvendor") { }


bool OnGossipHello(Player *pPlayer, Creature *pCreature)

{

    if (pPlayer->GetSession()->GetSecurity() > SEC_PLAYER)

 {

        pPlayer->SEND_VENDORLIST(pCreature->GetGUID());

 } else {

        pPlayer->PlayerTalkClass->CloseGossip();

        pCreature->MonsterWhisper("Your not a VIP, i cant sell to you $N!", pPlayer->GetGUID());

 }


    return true;

}


bool OnGossipSelect(Player *pPlayer, Creature *pCreature, uint32 sender, uint32 action)

{

    pPlayer->PlayerTalkClass->ClearMenus();


    if(!pPlayer->getAttackers().empty())

    {

        pPlayer->PlayerTalkClass->CloseGossip();

        pCreature->MonsterWhisper("I will not sell items to you $N when your in a fight!",pPlayer->GetGUID());

    }

    return true;

}

};

void AddSC_npc_gmvendor()

{

new npc_gmvendor();

}[/CODE]

that works fine for me /emoticons/default_smile.png

Well it works perfectly fine for me. No need to add brackets if you call only one function.

You probably added “pPlayer->PlayerTalkClass->CloseGossip();” without adding brackets which would indeed lead to the npc always telling you to go away.

So has nothing to do with my version