13 enum SCR_EBanCreateArgs
24 enum SCR_EBanRemoveArgs
49 const static int BAN_LIST_ITEMS_PER_PAGE_CHAT = 10;
50 const static int BAN_LIST_ITEMS_PER_PAGE_RCON = 25;
63 if (argv.Count() < SCR_EBanCreateArgs.EBCA_REASON)
68 if (argv[SCR_EBanCreateArgs.EBCA_ID].Length() != 36)
72 m_iDuration = argv[SCR_EBanCreateArgs.EBCA_DURATION].ToInt(-1);
74 return ScrServerCmdResult(
"Not Valid time value in seconds", EServerCmdResultType.ERR);
78 if (argv.Count() > SCR_EBanCreateArgs.EBCA_REASON)
80 for (
int i = SCR_EBanCreateArgs.EBCA_REASON, count = argv.Count() - 1; i < count; i++)
107 PrintFormat(
"Request Ban %1 for %2 seconds. Reason: '%3'", argv[SCR_EBanCreateArgs.EBCA_ID],
m_iDuration,
m_sBanReason);
120 if (argv.Count() < SCR_EBanRemoveArgs.EBRA_END)
123 PrintFormat(
"Unban user with identity: '%1'", argv[SCR_EBanRemoveArgs.EBRA_ID]);
135 if (argv.Count() < SCR_EBanListArgs.EBLA_END)
141 m_iPage = argv[SCR_EBanListArgs.EBLA_PAGE].ToInt();
150 m_Params.limit = BAN_LIST_ITEMS_PER_PAGE_RCON;
152 m_Params.limit = BAN_LIST_ITEMS_PER_PAGE_CHAT;
173 ref array<OnlineBanListData> banList =
new array<OnlineBanListData>;
175 string banListStr =
"Total bans: " +
m_BanApi.GetTotalItemCount() +
" | Page: " + (
m_BanApi.GetPage() + 1) +
"/" +
m_BanApi.GetPageCount() +
"\n";
176 banListStr +=
"- Identity Id | Banned name\n";
177 foreach (OnlineBanListData ban : banList)
179 banListStr +=
string.Format(
"- %1 | %2\n", ban.identityId, ban.bannedName);
189 if (RplSession.Mode() != RplMode.Dedicated)
190 return ScrServerCmdResult(
"Command is supported only on Dedicated Servers", EServerCmdResultType.ERR);
192 BackendApi bApi =
GetGame().GetBackendApi();
200 if (argv.Count() > 1)
202 if (argv[1] ==
"create")
204 else if (argv[1] ==
"remove")
206 else if (argv[1] ==
"list")
220 return ScrServerCmdResult(
"Help for ban command. \n#ban create <playerId> <duration> <reason> \n#ban create <identityId> <duration> <reason> \n#ban remove <identityId>\n#ban list <page>\n\n- <duration> is in seconds and can be set to 0 for permanent.\n- <reason> is optional.", EServerCmdResultType.OK);
255 return ERCONPermissions.PERMISSIONS_ADMIN;
329 override string GetKeyword()
336 override bool IsServerSide()
343 override int RequiredRCONPermission()
345 return ERCONPermissions.PERMISSIONS_ADMIN;
350 override int RequiredChatPermission()
359 if (argv.Count() < 2)
362 int kickPlayerId = argv[1].ToInt();
363 if (kickPlayerId < 1)
366 string kickPlayerName =
GetGame().GetPlayerManager().GetPlayerName(kickPlayerId);
367 if (kickPlayerName ==
"")
370 PrintFormat(
"Kick %1[%2]", kickPlayerName, kickPlayerId);
373 return ScrServerCmdResult(
string.Format(
"Player '%1' kicked!", kickPlayerName), EServerCmdResultType.OK);
378 override ref
ScrServerCmdResult OnChatServerExecution(array<string> argv,
int playerId)
380 return KickPlayer(argv, playerId);
385 override ref
ScrServerCmdResult OnChatClientExecution(array<string> argv,
int playerId)
394 return KickPlayer(argv);