GetVehicleModelDummyPosition: Difference between revisions
Jump to navigation
Jump to search
(Syntax) |
No edit summary |
||
Line 16: | Line 16: | ||
==Allowed dummies== | ==Allowed dummies== | ||
{{VehicleDummies}} | |||
===Returns=== | ===Returns=== |
Latest revision as of 12:29, 18 January 2021
This function gets position of the dummies contained in a vehicle model.
Syntax
float, float, float getVehicleModelDummyPosition ( int modelID, string dummy )
OOP Syntax Help! I don't understand this!
- Method: Vehicle.getVehicleModelDummyPosition(...)
- Counterpart: setVehicleModelDummyPosition
Required Arguments
- modelID: The model ID which you want to apply the change to
- dummy: The dummy whose position you want to get
Allowed dummies
- light_front_main: Primary front lights position.
- light_rear_main: Primary rear lights position.
- light_front_second: Secondary front lights position.
- light_rear_second: Secondary rear lights position.
- seat_front: Front seat position.
- seat_rear: Rear seat position.
- exhaust: Exhaust fumes start position.
- engine: Engine smoke start position.
- gas_cap: Vehicle gas cap position (shooting it will explode vehicle).
- trailer_attach: Point at which trailers will be attached to vehicle.
- hand_rest: Point at which the steer of a bike is held.
- exhaust_second: Secondary exhaust position (for example in NRG-500)
- wing_airtrail: Point from which air trail will show in airplanes, visible while in sharp turns.
- veh_gun: Vehicle gun position (ex. Rustler).
Returns
Returns three floats indicating the position x, y and z of given dummy. It returns false otherwise.
Example
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 end end addEventHandler("onClientRender", root, draw) -- Utility functions, not related to main functionality function 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 matrix end function getMatrixLeft(m) return m[1][1], m[1][2], m[1][3] end function getMatrixForward(m) return m[2][1], m[2][2], m[2][3] end function getMatrixUp(m) return m[3][1], m[3][2], m[3][3] end function getMatrixPosition(m) return m[4][1], m[4][2], m[4][3] end
See Also
- areVehicleLightsOn
- getHeliBladeCollisionsEnabled
- getHelicopterRotorSpeed
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleDummyPosition
- getVehicleGravity
- getVehicleLandingGearDown
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHeliBladeCollisionsEnabled
- setHelicopterRotorSpeed
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleLandingGearDown
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroActivated
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleWheelScale
- setVehicleWheelStates
- setVehicleWindowOpen
- Shared
- 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