HUD
Functions

Vehicle: get Exit Data

Provides most optimal, unobstructed exit point. This will work with all VCMod compatible vehicles. Includes all of default vehicle (attachment based) points, but gives priority to custom points.

Used in: VCMod Main addon.

Server Entity Vehicle:VC_getExitData(Vector pos)

Arguments

1. Vector pos; Player position
Position to which the point should be calculated for, generally player position, but could be anything.

Returns

1. Table Position, angle are local to the main entity body. If return is nil, no free positions were found. Return structure: {vec - Position, ang = Angle, dist - Dist from point to given position, type - {0 = worst case (such as above roof, in rear, in front), 1 = attachment point, 2 = predicted from driver data, 3 = predicted from passenger seat data}, valid = if it was empty or not}.

Example

// Place player at the most optimal exit position of a vehicle
concommand.Add("vehicle_getExitPos", function(ply)
	local ent = ply:GetVehicle()
	if IsValid(ent) then
		print("You are not in a vehicle.")
	else
		local posPly = ply:GetPos() // Could be anything
		local data = ent:VC_getExitData(posPly)

		if !data then print("All exit positions are taken!") return end

		ply:SetPos(ent:LocalToWorld(data.vec))
		ply:SetAngles(ent:LocalToWorldAngles(data.ang))

		// Would also be useful to apply velocity data to a player
	end
end)
Page modified:
...2020-10-07 09:12:00