Player::outputChatBox: Difference between revisions
No edit summary |
(→Syntax) |
||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
This functions writes a chat message to player. | This functions writes a chat message to player. | ||
== Syntax == | == Syntax == | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
player.outputChatBox( | player.outputChatBox(text); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''text:''' Text what should be output in player chat. | *'''text:''' {{RageType|String}} Text what should be output in player chat. | ||
== Example == | |||
== Example #1 == | |||
This example welcomes player on connect. | This example welcomes player on connect. | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" highlight="3"> | ||
mp.events.add(`playerJoin`, | mp.events.add(`playerJoin`, | ||
player => { | player => { | ||
player.outputChatBox(`Welcome to the server, ${player.name}!`); | player.outputChatBox(`Welcome to the server, ${player.name}!`); | ||
} | } | ||
); | ); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Example #2 == | |||
This example just output color texts. | |||
Note: [[chat.colors]] property should be enabled - if you wanna use that. | |||
==See | <syntaxhighlight lang="javascript" highlight="4,5"> | ||
let red = `#ff0000`; | |||
let player = mp.players.at(1337); // 1337 is a player id | |||
if (player) { | |||
player.outputChatBox(`!{#dddddd}This is Grey! !{#ffffff}This is White! !{${red}}This is Red!`); | |||
player.outputChatBox(` !{255, 0, 0}This is too Red! !{green}This is Green! !{255, 0, 255, 0.5}This is opacity Pink!`); | |||
}; | |||
</syntaxhighlight> | |||
==See also== | |||
{{Player_block}} | {{Player_block}} | ||
[[Category:Player API]] | |||
[[Category:Server-side Function]] | |||
Latest revision as of 09:55, 1 December 2019
This functions writes a chat message to player.
Syntax
player.outputChatBox(text);
Required Arguments
- text: String Text what should be output in player chat.
Example #1
This example welcomes player on connect.
mp.events.add(`playerJoin`,
player => {
player.outputChatBox(`Welcome to the server, ${player.name}!`);
}
);
Example #2
This example just output color texts. Note: chat.colors property should be enabled - if you wanna use that.
let red = `#ff0000`;
let player = mp.players.at(1337); // 1337 is a player id
if (player) {
player.outputChatBox(`!{#dddddd}This is Grey! !{#ffffff}This is White! !{${red}}This is Red!`);
player.outputChatBox(` !{255, 0, 0}This is too Red! !{green}This is Green! !{255, 0, 255, 0.5}This is opacity Pink!`);
};
See also
- Functions
- Player::ban
- Player::call
- Player::callProc
- Player::callToStreamed
- Player::callUnreliable
- Player::cancelPendingRpc
- Player::clearDecorations
- Player::getClothes
- Player::getDecoration
- Player::getFaceFeature
- Player::getHeadBlend
- Player::getHeadOverlay
- Player::getProp
- Player::getWeaponAmmo
- Player::giveWeapon
- Player::hasPendingRpc
- Player::invoke
- Player::isStreamed
- Player::isStreamedFor
- Player::kick
- Player::kickSilent
- Player::notify
- Player::outputChatBox
- Player::playAnimation
- Player::playScenario
- Player::putIntoVehicle
- Player::removeFromVehicle
- Player::removeObject
- Player::removeWeapon
- Player::removeAllWeapons
- Player::resetWeapon
- Player::setClothes
- Player::setCustomization
- Player::setDecoration
- Player::setFaceFeature
- Player::setHairColor
- Player::setHeadBlend
- Player::setHeadOverlay
- Player::setProp
- Player::setWeaponAmmo
- Player::spawn
- Player::stopAnimation
- Player::updateHeadBlend
- Player::enableVoiceTo
- Player::disableVoiceTo
- Weapons::clear
- Entity::destroy
- Entity::dist
- Entity::distSquared
- Entity::getVariable
- Entity::setVariable
- Entity::setVariables
- Properties
- Player::action
- Player::aimTarget
- Player::allWeapons
- Player::armour
- Player::eyeColor
- Player::faceFeatures
- Player::hairColor
- Player::hairHighlightColor
- Player::heading
- Player::health
- Player::rgscId
- Player::ip
- Player::serial
- Player::isAiming
- Player::isClimbing
- Player::isEnteringVehicle
- Player::isInCover
- Player::isInMelee
- Player::isJumping
- Player::isLeavingVehicle
- Player::isOnLadder
- Player::isReloading
- Player::name
- Player::packetLoss
- Player::ping
- Player::seat
- Player::socialClub
- Player::streamedPlayers
- Player::vehicle
- Player::voiceListeners
- Player::disableOutgoingSync
- Player::weapon
- Player::weaponAmmo
- Player::weapons
- Entity::alpha
- Entity::data
- Entity::dimension
- Entity::id
- Entity::model
- Entity::position
- Entity::type