Advertisement
djhonga2001

Untitled

Jan 20th, 2017
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. public enum Nodetype { AnyRoad, Road, Offroad, Water }
  2.  
  3. public static Vector3 GenerateSpawnPos(Vector3 desiredPos, Nodetype roadtype, bool sidewalk)
  4. {
  5.  
  6. Vector3 finalpos = Vector3.Zero;
  7. bool ForceOffroad = false;
  8.  
  9.  
  10. OutputArgument outArgA = new OutputArgument();
  11. int NodeNumber = 1;
  12. int type = 0;
  13.  
  14. if (roadtype == Nodetype.AnyRoad) type = 1;
  15. if (roadtype == Nodetype.Road) type = 0;
  16. if (roadtype == Nodetype.Offroad) { type = 1; ForceOffroad = true; }
  17. if (roadtype == Nodetype.Water) type = 3;
  18.  
  19.  
  20. int NodeID = Function.Call<int>(Hash.GET_NTH_CLOSEST_VEHICLE_NODE_ID, desiredPos.X, desiredPos.Y, desiredPos.Z, NodeNumber, type, 300f, 300f);
  21. if (ForceOffroad)
  22. {
  23. while (!Function.Call<bool>(Hash._GET_IS_SLOW_ROAD_FLAG, NodeID) && NodeNumber < 500)
  24. {
  25. NodeNumber++;
  26. NodeID = Function.Call<int>(Hash.GET_NTH_CLOSEST_VEHICLE_NODE_ID, desiredPos.X, desiredPos.Y, desiredPos.Z, NodeNumber, type, 300f, 300f);
  27. }
  28. }
  29. Function.Call(Hash.GET_VEHICLE_NODE_POSITION, NodeID, outArgA);
  30. finalpos = outArgA.GetResult<Vector3>();
  31.  
  32. if (sidewalk) finalpos = World.GetNextPositionOnSidewalk(finalpos);
  33. return finalpos;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement