aztectrev
-
Posts
3 -
Joined
-
Last visited
Never -
Donations
0.00 GBP
Content Type
Profiles
Bug Tracker
Wiki
Release Notes
Forums
Downloads
Blogs
Events
Posts posted by aztectrev
-
-
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:
-
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
New to mangos, trying to add to kill function
in OldC / C++
Posted
Like I've said, i'm new to C++ and the server compiling, don't quite know what all varaibles and functions are yet:D, only put it like that so I can remember where the function is, but thanks for pointing it out :lol: