描述
当通过服务器控制台、远程 RCON 或通过游戏中的“/rcon 命令”发送命令时,会调用此回调。
姓名 |
描述 |
cmd[] |
包含键入的命令以及任何传递的参数的字符串。 |
返回
它总是在过滤器脚本中首先被调用,因此返回 1 会阻止游戏模式看到它。
例子
public OnRconCommand(cmd[])
{
printf("[RCON]: You typed '/rcon %s'!", cmd);
return 0;
}
public OnRconCommand(cmd[])
{
if (!strcmp(cmd, "hello", true))
{
SendClientMessageToAll(0xFFFFFFAA, "Hello World!");
print("You said hello to the world."); // This will appear to the player who typed the rcon command in the chat in white
return 1;
}
return 0;
}
笔记
提示
当玩家输入命令时,“cmd”中不包含“/rcon”。如果您在此处使用“打印”功能,它将向在游戏中输入命令的玩家发送一条消息以及日志。当玩家未以 RCON 管理员身份登录时,不会调用此回调。当玩家未以 RCON admin 身份登录并使用 /rcon 登录时,不会调用此回调,而是调用 OnRconLoginAttempt。但是,当玩家以 RCON admin 身份登录时,使用此命令将调用此回调。
警告
您需要将此回调包含在加载的过滤器脚本中,才能使其在游戏模式下工作!