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