OnPlayerChat: Difference between revisions

From Onset Developer Wiki
(Created page with "{{Info|Event|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|OnPlayerChat}} {{FuncParameters}} == Example == __EDIT_ME__ {{RelatedFunctions}} {{ServerEvents}}")
 
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Info|Event|Server|1.0}}
{{Info|Event|Server & Client|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|The event that gets called when you type a message in the chat.}}


{{FuncSyntax|OnPlayerChat}}
{{FuncSyntax|OnPlayerChat(player, text)}}
{{FuncSyntaxClient|OnPlayerChat(text)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|player|The player who is texting in chat.}}
{{FuncParam|text|Text committed by the player.}}
== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
AddEvent("OnPlayerChat", function(playerid, text)
local x, y, z = GetPlayerLocation(playerid)
 
AddPlayerChatRange(x, y, 75.0, "<span color=\"#ffffffFF\">"..GetPlayerName(playerid).." says: "..text.."</>")
return false
end)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{ServerEvents}}
{{PlayerEvents}}

Latest revision as of 08:05, 16 January 2020

OnPlayerChat

Type: Event
Context: Server & Client
Introduced: v1.0

Description

The event that gets called when you type a message in the chat.

Syntax

OnPlayerChat(player, text)
Client Syntax
OnPlayerChat(text)

Parameters

  • player
    The player who is texting in chat.
  • text
    Text committed by the player.

Example

AddEvent("OnPlayerChat", function(playerid, text)
	local x, y, z = GetPlayerLocation(playerid)

	AddPlayerChatRange(x, y, 75.0, "<span color=\"#ffffffFF\">"..GetPlayerName(playerid).." says: "..text.."</>")
	return false
end)

See also