Commands
Typed chat commands with automatic argument parsing.
Declare a command with a leading /name literal and typed arguments.
knight
player::command("/heal") {
SetPlayerHealth(playerid, 100.0);
};
player::command("/give", int amount, string reason) {
GivePlayerMoney(playerid, amount);
SendClientMessage(playerid, "Received {amount}: {reason}");
};
player::command("/tp", float x, float y, float z) {
SetPlayerPos(playerid, x, y, z);
};
How arguments are parsed
int— the next whitespace-separated token is parsed as an integer.float— parsed as a decimal number.string— the remainder of the line (or one token, per declaration).
Note
Unknown commands can be handled in
player::chat or left to the engine's SERVER: Unknown command reply.