Advertisement
DonSibleyGames

init.c for Offline Mode to Get Object Co Ordinates

Jun 24th, 2021
7,769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.55 KB | None | 0 0
  1.  
  2.  
  3. void findLocations()
  4.     {
  5.         array<Object> objects = new array<Object>;
  6.         array<CargoBase> proxy_cargos = new array<CargoBase>;
  7.         FileHandle file = OpenFile("$profile:traintrackposevents.txt", FileMode.APPEND);
  8.         GetGame().GetObjectsAtPosition("7500 0 7500", 16000, objects, proxy_cargos);
  9.         for(int i = 0; i < objects.Count(); i++)
  10.         {
  11.             //repalce "YOURSELECTEDOBJECT" with your Static Object name
  12.             YOURSELECTEDOBJECT theObject = YOURSELECTEDOBJECT.Cast(objects.Get(i));
  13.             if(theObject)
  14.             {
  15.                 vector pos = theObject.GetPosition();
  16.                 vector ori = theObject.GetOrientation();
  17.                 int a;
  18.                
  19.                 if(ori[0] <= -90){
  20.                      a = -270 - ori[0];
  21.                 }else{
  22.                      a = 90 - ori[0];
  23.                 }
  24.  
  25.                 FPrintln(file, "<pos x=\"" + pos[0] + "\" z=\"" + pos[2] + "\" a=\"" + a + "\" />");  
  26.                 //FPrintln(file, "<group name=\"" + "YOURSELECTEDOBJECT\" " + "pos=\"" + pos[0] + " " + pos[1] + " " + pos[2] + "\"" + " rpy=\"" + ori[2] + " " + ori[1] + " " + ori[0] + "\"" + " " + "a=\"" + a + "\"" + "/>" );
  27.             }
  28.            
  29.         }
  30.         CloseFile(file);
  31.     }
  32. #define DISABLE_PERSISTENCY
  33.  
  34. #include "$CurrentDir:Missions\\DayZCommunityOfflineMode.ChernarusPlus\\core\\BaseModuleInclude.c"
  35.  
  36. Mission CreateCustomMission(string path)
  37. {  
  38.     if ( GetGame().IsServer() && GetGame().IsMultiplayer() )
  39.         return new CommunityOfflineServer();
  40.  
  41.     return new CommunityOfflineClient();
  42. }
  43.  
  44.  
  45. void main()
  46. {
  47.  
  48.  
  49. findLocations();
  50.  
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement