Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum Nodetype {AnyRoad,Road,Offroad,Water}
- public static Vector3 GenerateSpawnPos(Vector3 desiredPos, Nodetype roadtype, bool sidewalk)
- {
- Vector3 finalpos = Vector3.Zero;
- bool ForceOffroad = false;
- OutputArgument outArgA = new OutputArgument();
- OutputArgument outArgB = new OutputArgument();
- OutputArgument outArgC = new OutputArgument();
- int NodeNumber = 1;
- int type = 0;
- if (roadtype == Nodetype.AnyRoad) type = 1;
- if (roadtype == Nodetype.Road) type = 0;
- if (roadtype == Nodetype.Offroad) { type = 1; ForceOffroad = true; }
- if (roadtype == Nodetype.Water) type = 4;
- int NodeID = Function.Call<int>(Hash.GET_NTH_CLOSEST_VEHICLE_NODE_ID, desiredPos.X, desiredPos.Y, desiredPos.Z, NodeNumber, type, 300f, 300f);
- if (ForceOffroad)
- {
- while (!Function.Call<bool>(Hash._GET_IS_SLOW_ROAD_FLAG, NodeID) && NodeNumber < 500)
- {
- NodeNumber++;
- NodeID = Function.Call<int>(Hash.GET_NTH_CLOSEST_VEHICLE_NODE_ID, desiredPos.X, desiredPos.Y, desiredPos.Z, NodeNumber + 5, type, 300f, 300f);
- }
- }
- Function.Call(Hash.GET_VEHICLE_NODE_POSITION, NodeID, outArgA);
- finalpos = outArgA.GetResult<Vector3>();
- if (sidewalk) finalpos = World.GetNextPositionOnSidewalk(finalpos);
- return finalpos;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement