Player::call: Difference between revisions
No edit summary |
No edit summary |
||
| Line 12: | Line 12: | ||
That's example will call event added on client side for player with ID 1337, disable regeneration health and send number current player health. | That's example will call event added on client side for player with ID 1337, disable regeneration health and send number current player health. | ||
<div class="header" style="background-color: # | <div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;"> | ||
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div> | <div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
| Line 30: | Line 30: | ||
<div class="header" style="background-color: # | <div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;"> | ||
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div> | <div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
Revision as of 15:18, 4 May 2017
This function call added client-side event for selected player.
Syntax
void player.call(string eventName [, ...args]);
Required Arguments
- eventName: Event name, what will be called.
- args: Any arguments, what should be sended to client. Supports strings, numbers and booleans. (Objects and Arrays should be packed to JSON format.)
Example
That's example will call event added on client side for player with ID 1337, disable regeneration health and send number current player health.
Client-Side
let disableRegeneration = (currentHealth) => { //currentHealth - value, what we send from server.
mp.game.player.setHealthRechargeMultiplier(0); //Disable regeneration
let text = `Regeneration disabled. Current health: ${currentHealth}`;
mp.gui.execute(`insertMessageToChat(\`${text}\`)`); //Output text to default chatbox
};
mp.events.add(
{
`disablePlayerRegeneration`: disableRegeneration
}
);
Server-Side
let player = mp.player.at(1337); //Get player by ID
if (!!player) {
let playerHealth = player.health;
player.call(`disablePlayerRegeneration`, playerHealth);
};
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