OnPlayerChat: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 20: | Line 20: | ||
==Example== | ==Example== | ||
This example adds | This example adds a !createhydra command, which creates a hydra nearby | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler ( "onPlayerChat ", getRootElement(), "onPlayerChat" ) -- add an event handler for onPlayerChat | addEventHandler ( "onPlayerChat ", getRootElement(), "onPlayerChat" ) -- add an event handler for onPlayerChat | ||
function onPlayerChat ( | function onPlayerChat ( message, type ) | ||
if ( | if ( gettok ( message , 1, 32 ) == "!createhydra" ) then | ||
x, y, z = getElementPosition ( | x, y, z = getElementPosition ( source ) | ||
createVehicle ( 520, x + 5, y, z ) | createVehicle ( 520, x + 5, y, z ) | ||
outputChatBox("You got a hydra", | outputChatBox("You got a hydra",source) | ||
end | end | ||
end | end |
Revision as of 19:49, 12 May 2007
This event is triggered when a player chats inside the chat box.
Syntax
void onPlayerChat ( string message, int type )
Variables
- player: A player element refering to the player who is chatting the message
- message: A string representing the message typed into the chat
- type: An integer value representing the chat type:
- 0: normal
- 1: action (/me)
- 2: team
Canceling
If this event is canceled, the game's chatsystem won't deliver the posts. Use outputChatBox to send the messages then.
Example
This example adds a !createhydra command, which creates a hydra nearby
addEventHandler ( "onPlayerChat ", getRootElement(), "onPlayerChat" ) -- add an event handler for onPlayerChat function onPlayerChat ( message, type ) if ( gettok ( message , 1, 32 ) == "!createhydra" ) then x, y, z = getElementPosition ( source ) createVehicle ( 520, x + 5, y, z ) outputChatBox("You got a hydra",source) end end
See Also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled