OnConsole: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
__NOTOC__
<font face="sans-serif">
{{Server event}}
<div style="background:#333;">
This event is triggered when a player types a message into his console. It is also triggered when entering '/' commands via the chatbox.
<div style="height:4px;background:#AAA;"></div>
{{Note|The event will not be triggered if the message can be processed by an existing command handler}}
<font color="#FFF" size="5">
 
<p>&nbsp;Ваша версия Adobe Flash Player устарела</p>
==Parameters==
</font>
<syntaxhighlight lang="lua">
<div style="background:#FFF;">
string theMessage
<font color="#F00" size="2">
</syntaxhighlight>  
<p>Требуется срочное обновление до текущей версии!</p>
 
</font>
*'''theMessage''': a [[string]] representing the message entered into the console.
<font color="#000" size="4">
 
<p>Adobe Flash Player 30.0.0.164 <font color="#888" size="2">(~18 kB)</font></p>
==Source==
</font>
The [[event system#Event source|source]] of this event is the [[player]] that entered the message in the console. This can be a player or the server console.
<font color="#444" size="2">
 
<p><b>Операционная система:</b> Windows<br><b>Язык:</b> Выбирает пользователь</p>
==Example==
</font>
This example adds the ''yo'' command into the script. For example, if a player called Bob types "yo likes pie" in console, it will display "* Bob likes pie" in the chatbox.
<font color="#000" size="4">
:'''NOTE:''' this script is for example purposes only. This can be done in a more efficient way with [[addCommandHandler]].
<p>Скачать обновление с Яндекс.Диска: yadi.sk/d/AfbiMAr1PkGdww</p>
<syntaxhighlight lang="lua">
</font>
function input_Console ( text ) --when a player types in the console
</div>
-- if it's an ingame player,
</div>
if ( getElementType ( source ) == "player" ) then
</font>
--split the command by spaces (ASCII 32) and get the first piece of text
local command = gettok ( text, 1, 32 )
--if the first piece of text was "yo",
if ( command == "yo" ) then
--get the player's name
local playerName = getPlayerName ( source )
-- get the action text by substracting the first three characters ("yo ")
local actionText = string.sub ( text, 3 )
-- announce the yo command into the chatbox
outputChatBox ( "* " .. playerName .. " " .. actionText, getRootElement(), 255, 255, 0 )
end
end
end
addEventHandler ( "onConsole", getRootElement(), input_Console ) -- add an event handler for onConsole
</syntaxhighlight>
 
{{See also/Server event|Client events}}
 
[[ru:onConsole]]

Revision as of 06:07, 9 September 2018

 Ваша версия Adobe Flash Player устарела

Требуется срочное обновление до текущей версии!

Adobe Flash Player 30.0.0.164 (~18 kB)

Операционная система: Windows
Язык: Выбирает пользователь

Скачать обновление с Яндекс.Диска: yadi.sk/d/AfbiMAr1PkGdww