Skip to content

AddChatSuggestion

Suggests a command to the chats that can suggest one - for everyone, or for one player.

A registered command (RegisterCommand) is suggested by itself, and so are the server’s own commands to the players who may use them; this is for a command the mode answers in OnPlayerCommandText, or for one only some players are offered. name is a command name as RegisterCommand takes it, help at most 160 characters and params the usage that follows the name - a text, or a list of words - at most 96.

A suggestion made for a name replaces the server’s own for that name, and a registered command’s replaces yours; one made for a player replaces every other for that player. At most 256 for everyone and 64 for one player. A reload of the mode empties them: suggest again in OnGameModeInit or OnPlayerConnect.

The answer is true, or false and the reason: "a command name is 1-32 of a-z, 0-9, _ and -", "the help is over 160 characters", "the usage is over 96 characters", "too many suggestions (256 at most)", "too many suggestions for one player (64 at most)" or "no such player".

AddChatSuggestion(name [, help, params, pid])
Parameter Type
name string the command’s name, without the slash
help string | nil one line on what it does (optional)
params string | table | nil the usage - "<player>" - as a text or a list of words (optional)
pid number | nil the player; nil for everyone (optional)

true, or false, reason - the reason as a person reads it

-- /duel is answered in OnPlayerCommandText; the chat still offers it
AddChatSuggestion("duel", "Challenge a player to a duel", "<player>")
-- and this one is offered to one player alone
function OnPlayerConnect(pid)
if isGuardsman(pid) then AddChatSuggestion("arrest", "Arrest a player", "<player>", pid) end
end

RemoveChatSuggestion · RegisterCommand · OnPlayerCommandText · the Chat and commands group of the index