Browse Source

Added kick and kickban in-game commands.

pull/3/head
JustinAJ 10 years ago
parent
commit
73dd68fece
  1. 79
      RenX.Commands/RenX_Commands.cpp
  2. 2
      RenX.Commands/RenX_Commands.h

79
RenX.Commands/RenX_Commands.cpp

@ -1440,6 +1440,85 @@ const Jupiter::ReadableString &ModRequestGameCommand::getHelp(const Jupiter::Rea
GAME_COMMAND_INIT(ModRequestGameCommand) GAME_COMMAND_INIT(ModRequestGameCommand)
// Kick Game Command
void KickGameCommand::create()
{
this->addTrigger(STRING_LITERAL_AS_REFERENCE("kick"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("qkick"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("k"));
this->setAccessLevel(1);
}
void KickGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters)
{
if (parameters.isEmpty() == false)
{
RenX::PlayerInfo *target = source->getPlayerByPartName(parameters);
if (target == nullptr)
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player not found."));
else if (player == target)
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: You can not kick yourself."));
else if (target->access >= player->access)
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: You can not kick higher level moderators."));
else
{
source->kickPlayer(target);
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Player has been kicked from the game."));
}
}
else
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Too few parameters. Syntax: kick <player>"));
}
const Jupiter::ReadableString &KickGameCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Kicks a player from the game. Syntax: kick <player>");
return defaultHelp;
}
GAME_COMMAND_INIT(KickGameCommand)
// KickBan Game Command
void KickBanGameCommand::create()
{
this->addTrigger(STRING_LITERAL_AS_REFERENCE("ban"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("kickban"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("kb"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("b"));
this->setAccessLevel(2);
}
void KickBanGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters)
{
if (parameters.isEmpty() == false)
{
RenX::PlayerInfo *target = source->getPlayerByPartName(parameters);
if (target == nullptr)
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player not found."));
else if (player == target)
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: You can not ban yourself."));
else if (target->access >= player->access)
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: You can not ban higher level moderators."));
else
{
source->banPlayer(target);
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Player has been banned and kicked from the game."));
}
}
else
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Too few parameters. Syntax: ban <player>"));
}
const Jupiter::ReadableString &KickBanGameCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Kicks a player from the game. Syntax: ban <player>");
return defaultHelp;
}
GAME_COMMAND_INIT(KickBanGameCommand)
// Plugin instantiation and entry point. // Plugin instantiation and entry point.
RenX_CommandsPlugin pluginInstance; RenX_CommandsPlugin pluginInstance;

2
RenX.Commands/RenX_Commands.h

@ -68,5 +68,7 @@ GENERIC_GAME_COMMAND(HelpGameCommand)
GENERIC_GAME_COMMAND(ModsGameCommand) GENERIC_GAME_COMMAND(ModsGameCommand)
GENERIC_GAME_COMMAND(RulesGameCommand) GENERIC_GAME_COMMAND(RulesGameCommand)
GENERIC_GAME_COMMAND(ModRequestGameCommand) GENERIC_GAME_COMMAND(ModRequestGameCommand)
GENERIC_GAME_COMMAND(KickGameCommand)
GENERIC_GAME_COMMAND(KickBanGameCommand)
#endif // _RENX_COMMANDS_H_HEADER #endif // _RENX_COMMANDS_H_HEADER
Loading…
Cancel
Save