RemovePlayerFromVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(fixed bad example) |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool removePlayerFromVehicle ( | bool removePlayerFromVehicle ( player thePlayer ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''thePlayer:''' The player you wish to remove from a vehicle | ||
===Returns=== | ===Returns=== | ||
Line 16: | Line 16: | ||
This example forces a player out of a police vehicle if he is not a policeman. | This example forces a player out of a police vehicle if he is not a policeman. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local policevehicles = { [596]=true,[597]=true,[598]=true,[599]=true } --make a table of police vehicle IDs | |||
local policeskins = { [283]=true,[284]=true,[285]=true,[286]=true } --make a table of police skin IDs | |||
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), "enterVehicle" ) --add an event for onPlayerEnterVehicle | addEventHandler ( "onPlayerEnterVehicle", getRootElement(), "enterVehicle" ) --add an event for onPlayerEnterVehicle | ||
function enterVehicle ( vehicle, seat, jacked ) --when a player enters a vehicle | function enterVehicle ( vehicle, seat, jacked ) --when a player enters a vehicle | ||
local skinID = getPlayerSkin ( source ) --get his skin ID | |||
local vehID = getVehicleID ( vehicle ) | |||
if policevehicles[vehID] and not policeskins[skinID] then --if the vehicle is one of 4 police cars, and the skin is not a police skin | |||
removePlayerFromVehicle ( source )--force the player out of the vehicle | removePlayerFromVehicle ( source )--force the player out of the vehicle | ||
outputChatBox ( "Only | outputChatBox ( "Only policemen can enter police cars!", source ) --and tell the player why | ||
end | end | ||
end | end |
Revision as of 22:56, 28 March 2007
This function removes a player from a vehicle immediately. This works for drivers and passengers. Note that this removes the player from the vehicle and puts him in the exact position where the command was initiated.
Syntax
bool removePlayerFromVehicle ( player thePlayer )
Required Arguments
- thePlayer: The player you wish to remove from a vehicle
Returns
Returns true if the operation was successful, false otherwise.
Example
This example forces a player out of a police vehicle if he is not a policeman.
local policevehicles = { [596]=true,[597]=true,[598]=true,[599]=true } --make a table of police vehicle IDs local policeskins = { [283]=true,[284]=true,[285]=true,[286]=true } --make a table of police skin IDs addEventHandler ( "onPlayerEnterVehicle", getRootElement(), "enterVehicle" ) --add an event for onPlayerEnterVehicle function enterVehicle ( vehicle, seat, jacked ) --when a player enters a vehicle local skinID = getPlayerSkin ( source ) --get his skin ID local vehID = getVehicleID ( vehicle ) if policevehicles[vehID] and not policeskins[skinID] then --if the vehicle is one of 4 police cars, and the skin is not a police skin removePlayerFromVehicle ( source )--force the player out of the vehicle outputChatBox ( "Only policemen can enter police cars!", source ) --and tell the player why end end
See Also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates