吾爱尚玩资源基地
标题:
最新T端的延迟踢玩家出游戏的GM命令
[打印本页]
作者:
admin
时间:
2016-4-23 16:59
标题:
最新T端的延迟踢玩家出游戏的GM命令
内容介绍
不用说,这个是一个GM命令的系统。通过事件系统的控制,来限制多少时间后踢玩家下线。
#include "ScriptMgr.h"#include "ObjectMgr.h"
#include "Chat.h"
#include "Language.h"
#define KICKDELAY 5000 /*Time in milliseconds 1s = 1000 */ //这里定义多少时间踢玩家下线。例如5000就是5秒,你执行命令后,5秒后对应的玩家被踢下线
class kickplayer : public BasicEvent
{
public:
kickplayer(Player* player) : _player(player) { }
bool Execute(uint64 /*time*/, uint32 /*diff*/)
{
if (_player && _player->GetSession())
_player->GetSession()->KickPlayer();
return true;
}
private:
Player* _player;
};
class Newkickcommand : public CommandScript
{
public:
Newkickcommand() : CommandScript("Newkickcommand") { }
ChatCommand* GetCommands() const
{
static ChatCommand commandTable[] =
{
{ "kickp", SEC_GAMEMASTER, true, &HandleKickPlayerWithDelayCommand, "", NULL},
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
static bool HandleKickPlayerWithDelayCommand(ChatHandler* handler, char const* args)
{
Player* target = NULL;
std::string playerName;
std::stringstream announcer;
if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
return false;
if (handler->GetSession() && target == handler->GetSession()->GetPlayer())
{
handler->SendSysMessage(LANG_COMMAND_KICKSELF);
handler->SetSentErrorMessage(true);
return false;
}
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
char const* kickReason = strtok(NULL, " ");
std::string kickReasonStr = "No reason";
if (kickReason != NULL)
kickReasonStr = kickReason;
if(handler->GetSession() != NULL)
{
Player * plr = handler->GetSession()->GetPlayer();
switch(plr->GetSession()->GetSecurity())
{
case SEC_GAMEMASTER:
{
announcer <<"|cffFF0000"<<"GameMaster "<<plr->GetName()<<" has kicked "<<target->GetName()<<" for reason: "<<kickReasonStr<<"|r";
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE,announcer.str().c_str());
announcer.rdbuf()->str()="";
}
break;
case SEC_ADMINISTRATOR:
{
announcer <<"|cffFF0000"<<"Administrator "<<plr->GetName()<<" has kicked "<<target->GetName()<<" for reason: "<<kickReasonStr<<"|r";
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE,announcer.str().c_str());
announcer.rdbuf()->str()="";
}
break;
}
}
else
{
announcer <<"|cffFF0000"<<"Core"<<" has kicked "<<target->GetName()<<" for reason: "<<kickReasonStr<<"|r";
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE,announcer.str().c_str());
announcer.rdbuf()->str()="";
}
ChatHandler(target->GetSession()).PSendSysMessage("You will be kicked in %u seconds for %s", KICKDELAY, kickReasonStr);
target->m_Events.AddEvent(new kickplayer(target), target->m_Events.CalculateTime(KICKDELAY)); //这里,就把踢下线的任务安排成为一个事件,到时间就自动踢下线了
return true;
}
};
void AddSC_NewKickDelay()
{
new Newkickcommand();
}
复制代码
附件下载
(如果本资源侵犯到您的权益,请联系在线管理员QQ:
1589479632
处理!)
作者:
goodsosc
时间:
2019-3-11 19:22
终于找到需要的了!有需求就来吾爱尚玩!
欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/)
Powered by Discuz! X3.4