getVehicleModelDummyPosition
Client-side
Server-side
Shared
Needs checking
This function was partially migrated from the old wiki. Please review manually:
- Missing section: Allowed dummies
Pair: setVehicleModelDummyPosition
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
This function gets position of the dummies contained in a vehicle model.
Syntax
getVehicleModelDummyPosition ( )Code Examples
client
Given example will draw rectangle over every dummy in vehicle player is currently sitting it.
local dummies = { "light_front_main", "light_rear_main", "light_front_second", "light_rear_second", "seat_front", "seat_rear", "exhaust", "engine", "gas_cap", "trailer_attach", "hand_rest", "exhaust_second", "wing_airtrail", "veh_gun"}
function draw() local veh = getPedOccupiedVehicle( localPlayer ) if not veh then return end
local mat = getElementMatrix(veh) local vx,vy,vz = getMatrixPosition(mat) local fx,fy,fz = getMatrixForward(mat) local lx,ly,lz = getMatrixLeft(mat) local ux,uy,uz = getMatrixUp(mat) local model = getElementModel(veh)
for i,dum in ipairs(dummies) do local v = {getVehicleModelDummyPosition(model, dum)} if v[1] ~= 0 or v[2] ~= 0 or v[3] ~= 0 then local px,py,pz = vx,vy,vz px = px+fx*v[2]+lx*v[1]+ux*v[3] py = py+fy*v[2]+ly*v[1]+uy*v[3] pz = pz+fz*v[2]+lz*v[1]+uz*v[3]
local sx,sy = getScreenFromWorldPosition( px,py,pz,0,false ) if sx then dxDrawRectangle( sx-10, sy-10, 20, 20, v[4] ) dxDrawText(i-1, sx-5,sy-5,20,20,tocolor( 0,0,0 )) end end endendaddEventHandler("onClientRender", root, draw)
-- Utility functions, not related to main functionalityfunction getElementMatrix(element) local rx, ry, rz = getElementRotation(element, "ZXY") rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz) local matrix = {} matrix[1] = {} matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry) matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry) matrix[1][3] = -math.cos(rx)*math.sin(ry) matrix[1][4] = 1
matrix[2] = {} matrix[2][1] = -math.cos(rx)*math.sin(rz) matrix[2][2] = math.cos(rz)*math.cos(rx) matrix[2][3] = math.sin(rx) matrix[2][4] = 1
matrix[3] = {} matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx) matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx) matrix[3][3] = math.cos(rx)*math.cos(ry) matrix[3][4] = 1
matrix[4] = {} matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element) matrix[4][4] = 1
return matrixend
function getMatrixLeft(m) return m[1][1], m[1][2], m[1][3]endfunction getMatrixForward(m) return m[2][1], m[2][2], m[2][3]endfunction getMatrixUp(m) return m[3][1], m[3][2], m[3][3]endfunction getMatrixPosition(m) return m[4][1], m[4][2], m[4][3]endSee Also
Vehicle Functions
- addVehicleSirens
- addVehicleUpgrade
- areVehicleLightsOn
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getHeliBladeCollisionsEnabled
- getModelHandling
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getVehicleAdjustableProperty
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleController
- getVehicleCurrentGear
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleDummyPosition
- getVehicleEngineState
- getVehicleEntryPoints
- getVehicleGravity
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleIdleRespawnDelay
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelFromName
- getVehicleModelWheelSize
- getVehicleName
- getVehicleNameFromModel
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleRespawnDelay
- getVehicleRespawnPosition
- getVehicleRespawnRotation
- getVehicleRotorSpeed
- getVehicleRotorState
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehiclesOfType
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgrades
- getVehicleUpgradeSlotName
- getVehicleVariant
- getVehicleWheelFrictionState
- getVehicleWheelScale
- getVehicleWheelStates
- isTrainChainEngine
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleRespawnable
- isVehicleSmokeTrailEnabled
- isVehicleTaxiLightOn
- isVehicleWheelOnGround
- isVehicleWindowOpen
- removeVehicleSirens
- removeVehicleUpgrade
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- resetVehicleExplosionTime
- resetVehicleIdleTime
- respawnVehicle
- setHeliBladeCollisionsEnabled
- setModelHandling
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setVehicleAdjustableProperty
- setVehicleColor
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleDummyPosition
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleGravity
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleIdleRespawnDelay
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroActivated
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleRespawnDelay
- setVehicleRespawnPosition
- setVehicleRespawnRotation
- setVehicleRotorSpeed
- setVehicleRotorState
- setVehicleSirens
- setVehicleSirensOn
- setVehicleSmokeTrailEnabled
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelScale
- setVehicleWheelsRotation
- setVehicleWheelStates
- setVehicleWindowOpen
- spawnVehicle
- spawnVehicleFlyingComponent
- toggleVehicleRespawn
Vehicle Events
- onClientTrailerAttach
- onClientTrailerDetach
- onClientVehicleCollision
- onClientVehicleDamage
- onClientVehicleEnter
- onClientVehicleExit
- onClientVehicleExplode
- onClientVehicleNitroStateChange
- onClientVehicleRespawn
- onClientVehicleStartEnter
- onClientVehicleStartExit
- onClientVehicleWeaponHit
- onTrailerAttach
- onTrailerDetach
- onVehicleDamage
- onVehicleEnter
- onVehicleExit
- onVehicleExplode
- onVehicleRespawn
- onVehicleStartEnter
- onVehicleStartExit