Around Position Function?

Hello,
is there a around position function like Game.Player.Character.Postion.Around from ScriptHookVDotNet ?

and what this around is giving in scripthook ?

There is no native for it, you would have to create your own function. I was looking through the src of ScriptHookVDotNet here and found the functions Vector3 Vector3::Around and Vector3 Vector3::RandomXY. Basically those functions make up a random XY and add it to the current Vector3.

        Vector3 Vector3::Around(float distance)
		{
			return *this + Vector3::RandomXY() * distance;
		}

		Vector3 Vector3::RandomXY()
		{
			Vector3 v;
			double radian = Random::Instance->NextDouble() * 2 * System::Math::PI;

			v.X = (float)(System::Math::Cos(radian));
			v.Y = (float)(System::Math::Sin(radian));
			v.Normalize();
			return v;
		}
1 Like

When I got home I whipped up a LUA function that should work (I never tested it out):

function GetAroundVector3(vector3, distance)
	local variation = distance * 2

	local xBef = math.random(variation) - distance
	local yBef = math.random(variation) - distance

	local x = vector3.x + xBef
	local y = vector3.y + yBef
	local z = vector3.z

	-- Uncomment next part out if you want to return Vector3 on the ground
	-- z = GetGroundZFor_3dCoord(x, y, z, 0)

	return vector3(x, y, z)
end