I'm trying to rewrite the gm 'die' command so an admin with equal to or less rights than you cant kill you.
I'm new to C++ and MaNGOS but have done other programming languages so can follow the code logic.
I only added a few line but already stuggling, wondered if anyone could give me a quick help.
so far i got
bool ChatHandler::HandleDieCommand(const char* /*args*/)
{
Unit* target = getSelectedUnit();
if(!target || !m_session->GetPlayer()->GetSelection())
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
if( target->isAlive() )
{
Player* targetPlayer = getSelectedPlayer();
// check if target is player
if( targetPlayer )
{
// check if player has greater than or equal rights
if( /*dont know how to check player/target security right such as gm and admin */ )
{
//send error message
SendSysMessage("You cannot kill that player");
SetSentErrorMessage(true);
}
else
{
// is player with less rights than you so kill
m_session->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
}
}
else
{
// if not player kill anyway
m_session->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
}
}
return true;
}
Hope someone can help :lol:
thought this would be a start to learning C++ if i managed this