Player::ban: Difference between revisions
(Created page with "This function ban a player. == Syntax == <syntaxhighlight lang="javascript"> player.ban(String reason) </syntaxhighlight>") |
m (category) |
||
| (4 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
This function ban | This function bans the player from your server. | ||
''Note:'' The ban reason doesn't display for the player, you need to use something else to display it for the player. Also, all bans that use this function are cleared once the server restarts. You need to save the bans yourself if you want them to stay after restarting your server. | |||
== Syntax == | == Syntax == | ||
< | <pre> | ||
player.ban( | player.ban(reason) | ||
</ | </pre> | ||
=== Parameters === | |||
*'''reason''': {{RageType|String}} | |||
== Example == | |||
Creates a ban command. | |||
{{ServersideCode| | |||
<pre> | |||
mp.events.addCommand('ban', (player, target) => { | |||
let newTarget = mp.players.at(target); | |||
if(!target || isNaN(target)) return player.outputChatBox("Syntax: /ban [playerID]"); | |||
if(newTarget === null) return player.outputChatBox("There is no player online with the ID given.") | |||
newTarget.outputChatBox("You have been banned from the server."); | |||
newTarget.ban('Banned.'); | |||
}); | |||
</pre> | |||
}} | |||
==See Also== | |||
{{Player_block}} | |||
[[Category:Player API]] | |||
[[Category:Server-side Function]] | |||
Latest revision as of 16:57, 17 May 2019
This function bans the player from your server.
Note: The ban reason doesn't display for the player, you need to use something else to display it for the player. Also, all bans that use this function are cleared once the server restarts. You need to save the bans yourself if you want them to stay after restarting your server.
Syntax
player.ban(reason)
Parameters
- reason: String
Example
Creates a ban command.
Server-Side
mp.events.addCommand('ban', (player, target) => {
let newTarget = mp.players.at(target);
if(!target || isNaN(target)) return player.outputChatBox("Syntax: /ban [playerID]");
if(newTarget === null) return player.outputChatBox("There is no player online with the ID given.")
newTarget.outputChatBox("You have been banned from the server.");
newTarget.ban('Banned.');
});
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