SetVehicleModelDummyPosition

From Multi Theft Auto: Wiki

This function sets the position of the dummies contained in a vehicle model. Use setVehicleComponentPosition to adjust the vehicle component positions.

Syntax

bool setVehicleModelDummyPosition ( int modelID, string dummy, float x, float y, float z )

OOP Syntax Help! I don't understand this!

Method: Vehicle.setVehicleModelDummyPosition(...)
Counterpart: getVehicleModelDummyPosition

Required Arguments

  • modelID: The model ID which you want to apply the change to
  • dummy: The dummy whose position you want to change
  • posX, posY, posZ: The desired position

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 true if everything went fine, false otherwise.

Example

Given example will move all the dummies in vehicle that player is sitting in up and down, after he uses /move command.

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"
}
local cache = {}

function move()
	local veh = getPedOccupiedVehicle( localPlayer )
	if not veh then return end

	local model = getElementModel(veh)

	for i,dum in ipairs(dummies) do
		setVehicleModelDummyPosition(model, dum, cache[dum][1], cache[dum][2], cache[dum][3] + math.sin(getTickCount()/1500))
	end
end

addCommandHandler( "move", function()
	local veh = getPedOccupiedVehicle( localPlayer )
	if not veh then return end
	local model = getElementModel(veh)

	for i,dum in ipairs(dummies) do
		local v = {getVehicleModelDummyPosition(model, dum)}
		cache[dum] = v
	end
	addEventHandler("onClientRender", root, move)
end)

See Also

FROM VERSION 1.5.7 r19626 ONWARDS
FROM VERSION 1.6 r7485 ONWARDS
FROM VERSION 1.6 r7485 ONWARDS