Jump to content

How to check if player is in group


Guest chmuun

Recommended Posts

Hi,

Can someone please tell me how to check if some one is in group ... and i tried using this to check if the person's group is a raid group but it makes the server crash:

if(pvpPlayer->GetGroup()->isRaidGroup())
{
   //If player is in a raid group
}

Thank you

Link to comment
Share on other sites

Hi,

Can someone please tell me how to check if some one is in group ... and i tried using this to check if the person's group is a raid group but it makes the server crash:

if(pvpPlayer->GetGroup()->isRaidGroup())
{
   //If player is in a raid group
}

Thank you

You first have to check if he's in a group, AFTER checking that you can check the grouptype (isRaidGroup() in your case) otherwise it will run the check for raid group even when the player is not in a group

if(pvpPlayer->GetGroup() && pvpPlayer->GetGroup()->isRaidGroup())
{
   // Do something
}

Link to comment
Share on other sites

Can you also tell me how to Send a global announcement

I tried

ChatHandler chatGlobal = ChatHandler();

char victimglobalmessage[1024];
snprintf(victimglobalmessage, 1024, PVP_COLOR"%s lost a %u kill, killing spree by %s! Extra [%s]x5 is rewarded!", pvpVictim->GetName(), OldVictimKillingSpree*10, pvpPlayer->GetName(), "Badge of Justice");
chatGlobal.SendGlobalSysMessage(victimglobalmessage);

But it gives an error:

Error 2 error C2248: 'ChatHandler::SendGlobalSysMessage' : cannot access protected member declared in class 'ChatHandler' e:\\Aaam\\Source Code\\src\\game\\Player.cpp 20371

Link to comment
Share on other sites

std::string message;
message = put your text here; // you could use a config from mangosd.conf for this (hope you know how )
if (message) // this check is only needed if you used a config for it.. if it's not set it will give a false here... if this check wouldn't be here and the message is empty it will crash
{
       WorldPacket data(SMSG_NOTIFICATION, (message.size()+1));
       data << message;
       sWorld.SendGlobalMessage(&data);
}

or more advanced way:

 std::ostringstream msg;
 std::ostringstream pvpVictimName;
 std::ostringstream pvpPlayerName;

 pvpVictimName << pvpVictim->GetName();
 pvpPlayerName << pvpPlayer->GetName();

 msg << pvpVictimName .str().c_str() << "lost a" << OldVictimKillingSpree*10 << "kill, killing spree by" << ... << ... << "]";
 SendWorldText(LANG_SYSTEMMESSAGE, msg.str().c_str());

note that you have to finish the 2nd one... i wont do everything for ya

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use