*Kick command CLI support - by Machiavelli
--HG-- branch : trunk
This commit is contained in:
+80
-56
@@ -1679,71 +1679,95 @@ bool ChatHandler::HandleNpcFactionIdCommand(const char* args)
|
|||||||
//kick player
|
//kick player
|
||||||
bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const char* kickName = strtok((char*)args, " ");
|
const char* kickName = strtok((char*)args, " ");
|
||||||
if(!kickName)
|
|
||||||
{
|
|
||||||
|
|
||||||
SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string name = kickName;
|
|
||||||
|
|
||||||
if(!normalizePlayerName(name))
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_session && name==m_session->GetPlayer()->GetName())
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_KICKSELF);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player* player = objmgr.GetPlayer(kickName);
|
|
||||||
if(!player)
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(player->GetSession()->GetSecurity() > m_session->GetSecurity())
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); //maybe replacement string for this later on
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* kickReason = strtok(NULL, "\n");
|
char* kickReason = strtok(NULL, "\n");
|
||||||
std::string reason = "No Reason";
|
std::string reason = "No Reason";
|
||||||
|
std::string kicker = "Console";
|
||||||
if(kickReason)
|
if(kickReason)
|
||||||
{reason = kickReason;}
|
reason = kickReason;
|
||||||
|
if(m_session)
|
||||||
|
kicker = m_session->GetPlayer()->GetName();
|
||||||
|
|
||||||
if(sWorld.KickPlayer(name.c_str()))
|
if(!kickName)
|
||||||
{
|
{
|
||||||
if(sWorld.getConfig(CONFIG_SHOW_KICK_IN_WORLD) == 1)
|
Player* player = getSelectedPlayer();
|
||||||
|
if(!player)
|
||||||
{
|
{
|
||||||
sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, name.c_str(), m_session->GetPlayer()->GetName(), reason.c_str());
|
SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player==m_session->GetPlayer())
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_COMMAND_KICKSELF);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sWorld.getConfig(CONFIG_SHOW_KICK_IN_WORLD) == 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, player->GetName(), kicker.c_str(), reason.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_COMMAND_KICKMESSAGE, player->GetName(), kicker.c_str(), reason.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
player->GetSession()->KickPlayer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string name = kickName;
|
||||||
|
if(!normalizePlayerName(name))
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_session && name==m_session->GetPlayer()->GetName())
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_COMMAND_KICKSELF);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* player = objmgr.GetPlayer(kickName);
|
||||||
|
if(!player)
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_session && player->GetSession()->GetSecurity() > m_session->GetSecurity())
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); //maybe replacement string for this later on
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sWorld.KickPlayer(name.c_str()))
|
||||||
|
{
|
||||||
|
if(sWorld.getConfig(CONFIG_SHOW_KICK_IN_WORLD) == 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, name.c_str(), kicker.c_str(), reason.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_COMMAND_KICKMESSAGE, name.c_str(), kicker.c_str(), reason.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_COMMAND_KICKMESSAGE, name.c_str(), m_session->GetPlayer()->GetName(), reason.c_str());
|
PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER, name.c_str());
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER, name.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user