描述
当玩家在客户端聊天窗口中输入命令时,会调用此回调。命令是任何以正斜杠开头的命令,例如/help。
姓名 |
描述 |
playerid |
输入命令的玩家的 ID。 |
cmdtext[] |
输入的命令(包括正斜杠)。 |
返回
它总是在过滤器脚本中首先被调用,因此返回 1 会阻止其他脚本看到它。
例子
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/help", true))
{
SendClientMessage(playerid, -1, "SERVER: This is the /help command!");
return 1;
// Returning 1 informs the server that the command has been processed.
// OnPlayerCommandText won't be called in other scripts.
}
return 0;
// Returning 0 informs the server that the command hasn't been processed by this script.
// OnPlayerCommandText will be called in other scripts until one returns 1.
// If no scripts return 1, the 'SERVER: Unknown Command' message will be shown to the player.
}
笔记
提示
这个回调也可以被NPC调用。