Script/Commands: Add command to join an existing group/party.

This commit is contained in:
w1sht0l1v3 committed 2013-01-23 20:58:01 +02:00
1 parent 5e367c910a
commit 70490c8238
3 files changed
+70

No files matched your search

+56
View File
@@ -46,6 +46,7 @@ public:
{ "leader", SEC_ADMINISTRATOR, false, &HandleGroupLeaderCommand, "", NULL },
{ "disband", SEC_ADMINISTRATOR, false, &HandleGroupDisbandCommand, "", NULL },
{ "remove", SEC_ADMINISTRATOR, false, &HandleGroupRemoveCommand, "", NULL },
{ "join", SEC_ADMINISTRATOR, false, &HandleGroupJoinCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand petCommandTable[] =
@@ -2725,6 +2726,61 @@ public:
return true;
}
static bool HandleGroupJoinCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* playerSource = NULL;
Player* playerTarget = NULL;
Group* groupSource = NULL;
Group* groupTarget = NULL;
uint64 guidSource = 0;
uint64 guidTarget = 0;
char* nameplgrStr = strtok((char*)args, " ");
char* nameplStr = strtok(NULL, " ");
if (handler->GetPlayerGroupAndGUIDByName(nameplgrStr, playerSource, groupSource, guidSource, true))
{
if (groupSource)
{
if (handler->GetPlayerGroupAndGUIDByName(nameplStr, playerTarget, groupTarget, guidTarget, true))
{
if (!groupTarget && playerTarget->GetGroup() != groupSource)
{
if (!groupSource->IsFull())
{
groupSource->AddMember(playerTarget);
groupSource->BroadcastGroupUpdate();
handler->PSendSysMessage(LANG_GROUP_PLAYER_JOINED, playerTarget->GetName().c_str(), playerSource->GetName().c_str());
return true;
}
else
{
// group is full
handler->PSendSysMessage(LANG_GROUP_FULL);
return true;
}
}
else
{
// group is full or target player already in a group
handler->PSendSysMessage(LANG_GROUP_ALREADY_IN_GROUP, playerTarget->GetName().c_str());
return true;
}
}
}
else
{
// specified source player is not in a group
handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, playerSource->GetName().c_str());
return true;
}
}
return true;
}
static bool HandlePlayAllCommand(ChatHandler* handler, char const* args)
{
if (!*args)