Advertisement
Eddlm

Vehicle node flags

Sep 28th, 2019
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1.  
  2.  
  3.  
  4.     public enum PathnodeFlags
  5.     {
  6.         Slow = 1,
  7.         Two = 2,
  8.         Intersection = 4,
  9.         Eight = 8, SlowTraffic = 12, ThirtyTwo = 32, Freeway = 64, FourWayIntersection = 128, BigIntersectionLeft = 512
  10.     }
  11.     public static string GetRoadFlags(Vector3 pos)
  12.     {
  13.         OutputArgument outArgA = new OutputArgument();
  14.         OutputArgument outArgB = new OutputArgument();
  15.         if (Function.Call<bool>(Hash.GET_VEHICLE_NODE_PROPERTIES, pos.X, pos.Y, pos.Z, outArgA, outArgB))
  16.         {
  17.             int busy = outArgA.GetResult<int>();
  18.             int flags = outArgB.GetResult<int>();
  19.  
  20.             string d = "";
  21.             foreach (int flag in Enum.GetValues(typeof(PathnodeFlags)).Cast<PathnodeFlags>())
  22.             {
  23.  
  24.                 if ((flag & flags) != 0) d += " " + (PathnodeFlags)flag;
  25.             }
  26.             return d;  // DisplayHelpTextThisFrame("Flags: " + d);
  27.         }
  28.         return "";
  29.     }
  30.     public static bool RoadHasFlag(Vector3 pos, PathnodeFlags flag)
  31.     {
  32.         OutputArgument outArgA = new OutputArgument();
  33.         OutputArgument outArgB = new OutputArgument();
  34.         if (Function.Call<bool>(Hash.GET_VEHICLE_NODE_PROPERTIES, pos.X, pos.Y, pos.Z, outArgA, outArgB))
  35.         {
  36.             int busy = outArgA.GetResult<int>();
  37.             int flags = outArgB.GetResult<int>();
  38.             if ((flags & (int)flag) != 0) return true;
  39.         }
  40.         return false;
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement