PlayPlayerEmote
Makes a player perform an emote - the heart of an emote command.
As if they had picked it on the wheel - the server’s own rules still apply (in the world and alive, standing still on
foot, no weapon out, not fighting, not knocked out, carried or carrying) but OnPlayerEmote is not asked. A new emote
replaces the one playing. When it cannot play, the second value says why in words the player can read (“Stand still
first.”, “Put your weapon away first.”, “Not while knocked out.”, “Not while carrying.”, “There is no emote ‘juggle’
here.” …), ready for the chat. A locked emote (AddEmote’s opts.locked) asks only that the player is in the world,
alive, on foot, not knocked out and not carried or carrying.
Syntax
Section titled “Syntax”PlayPlayerEmote(pid, name)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
name |
string | the emote (any case) |
Returns
Section titled “Returns”true, or false, reason - the reason as the player reads it ("Stand still first.", "There is no emote 'juggle' here." …)
Example
Section titled “Example”-- the shipped modes' /anim: /anim <name> plays one, /anim stop ends it, /anim alone lists themfunction OnPlayerCommandText(pid, cmd, args) if cmd == "anim" then local name = args:match("^(%S+)") if not name then SendClientMessage(pid, COLOR_SERVER, "anims: " .. table.concat(GetEmotes(), ", ") .. " - /anim <name>, /anim stop") elseif name:lower() == "stop" then if not StopPlayerEmote(pid) then SendClientMessage(pid, COLOR_SERVER, "No animation is playing.") end else local ok, why = PlayPlayerEmote(pid, name) if not ok then SendClientMessage(pid, COLOR_RED, why) end end return true end return falseend
-- the winner of a duel cheersfunction OnPlayerDeath(victim, killer) if killer >= 0 then PlayPlayerEmote(killer, "cheer") endendSee also
Section titled “See also”StopPlayerEmote · GetEmotes · GetPlayerEmote · OnPlayerEmote · the Emotes group of the index
