Jump to content

aztectrev

Members
  • Posts

    3
  • Joined

  • Last visited

    Never
  • Donations

    0.00 GBP 

Posts posted by aztectrev

  1. I wanted to create this so other people testing the server with me all are set to security level 3 and use the die command alot, but sometimes can be bad if another player is selected by mistake (and especially if your brother is annoyed with me and keeps hitting the die command on me :( )

    anyways thanks for the link. i just couldnt work out how to access the GetSecurity function for another player.

    This is the bit i needed to know, so cheers:

    getSelectedPlayer()->GetSession()->GetSecurity()

    fixed:

    // check if player has greater than or equal rights
    if(targetPlayer->GetSession()->GetSecurity() >= m_session->GetPlayer()->GetSession()->GetSecurity()  )
    {
       //send error message
       SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
       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);
    }
    

    Now when i try to kill another admin i get the LANG_YOURS_SECURITY_IS_LOW message :lol:

  2. 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 :)

×
×
  • 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