Scripting/Server/Classes/Vehicle/SetPart

(v0.3.5+) Swaps a body part of this car for the same part of another vehicle model - a Sentinel bumper on a Kuruma, a different bonnet, doors, wings. part is VPART_BUMPER_FRONT 7, BUMPER_REAR 8, WING_FRONT_RIGHT 9, WING_REAR_RIGHT 10, DOOR_FRONT_RIGHT 11, DOOR_REAR_RIGHT 12, WING_FRONT_LEFT 13, WING_REAR_LEFT 14, DOOR_FRONT_LEFT 15, DOOR_REAR_LEFT 16, BONNET 17, BOOT 18, WINDSCREEN 19. donorModel is a vehicle model id (90-150 or a custom vehicle); the client loads it when needed. Because the parts come from another car they will not always fit: sx/sy/sz scale the part along its own axes (default 1), x/y/z move it (metres, in the part's frame) and rx/ry/rz rotate it (degrees) - tune them with a test command until it sits right. The part keeps the car's paint colour and still takes damage / flies off. RestorePart puts the original back, ClearMods removes every decal, texture, rim and part change of the car. Synced to every player; plain cars only.

Syntax

vehicle.SetPart(part, donorModel [, sx, sy, sz [, x, y, z [, rx, ry, rz]]])
vehicle.RestorePart(part)
vehicle.ClearMods()

Arguments

Example

function onPlayerCommand( player, cmd, params )
{
	if ( cmd == "setpart" )
	{
		local veh = player.Vehicle;
		if ( !veh ) return MessagePlayer( "Sit in a vehicle first.", player );
		veh.SetPart( 0, 0 );
	}
}

This sample was generated from the signature – adapt the values to your gamemode.

Section: Vehicle

Categories: Server methods | Vehicle