描述

当玩家在客户端聊天窗口中输入命令时,会调用此回调。命令是任何以正斜杠开头的命令,例如/help。
姓名 描述
playerid 输入命令的玩家的 ID。
cmdtext[] 输入的命令(包括正斜杠)。

返回

它总是在过滤器脚本中首先被调用,因此返回 1 会阻止其他脚本看到它。

例子

  1. public OnPlayerCommandText(playerid, cmdtext[])
  2. {
  3. if (!strcmp(cmdtext, "/help", true))
  4. {
  5. SendClientMessage(playerid, -1, "SERVER: This is the /help command!");
  6. return 1;
  7. // Returning 1 informs the server that the command has been processed.
  8. // OnPlayerCommandText won't be called in other scripts.
  9. }
  10. return 0;
  11. // Returning 0 informs the server that the command hasn't been processed by this script.
  12. // OnPlayerCommandText will be called in other scripts until one returns 1.
  13. // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown to the player.
  14. }

笔记

提示
这个回调也可以被NPC调用。