Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.61 KB | None | 0 0
  1. // structure
  2. namespace GMResource
  3. {
  4.     public class WorkBus
  5.     {
  6.         public class RouteInfo
  7.         {
  8.             public string NAME;
  9.             public int COUNT_POINTS;
  10.             public Dictionary<int, WorkBus.PointInfo> POINT;
  11.         }
  12.        
  13.         public class PointInfo
  14.         {
  15.             public int ROUTE_ID;
  16.             public int PRIORITY;
  17.             public int TYPE;
  18.             public Vector3 POSITION;
  19.         }
  20.     }
  21. }
  22.  
  23. // global
  24. namespace GMResource
  25. {
  26.     public class WorkBusGlobal
  27.     {
  28.         public static void LoadRoutes(DataTable BusRouteData)
  29.         {
  30.             Dictionary<int, WorkBus.RouteInfo> WorkBusGlobal = new Dictionary<int, WorkBus.RouteInfo>();
  31.             foreach(DataRow Row in BusRouteData.Rows)
  32.             {
  33.                 WorkBus.RouteInfo Route = new WorkBus.RouteInfo();
  34.                 Route.NAME = (string)Row["route_name"];
  35.                 Route.COUNT_POINTS = (int)Row["route_points"];
  36.                
  37.                 WorkBusGlobal.Add((int)Row["route_id"], Route);
  38.                 API.shared.consoleOutput("[WorkBus] Route (id: " + (int)Row["route_id"] + ") " + Route.NAME + " loaded.");
  39.             }
  40.         //  API.shared.setWorldSyncedData("WorkBusGlobal", Misc.TO_JSON(WorkBusGlobal));
  41.         }
  42.        
  43.         public static void LoadPoints(DataTable PointData)
  44.         {
  45.             Dictionary<int, WorkBus.PointInfo> WorkBusGlobal = new Dictionary<int, WorkBus.PointInfo>();
  46.             foreach(DataRow Row in PointData.Rows)
  47.             {
  48.                 WorkBus.PointInfo Point = new WorkBus.PointInfo();
  49.                 Point.ROUTE_ID = (int)Row["route_id"];
  50.                 Point.PRIORITY = (int)Row["point_priority"];
  51.                 Point.TYPE = (int)Row["point_type"];
  52.                 Point.POSITION = new Vector3((float)Row["point_x"], (float)Row["point_y"], (float)Row["point_z"]);
  53.                
  54.                 WorkBusGlobal.Add((int)Row["route_id"], Point);
  55.                 API.shared.consoleOutput("[WorkBus] Point (route_id: " + (int)Row["route_id"] + ") priority: " + Point.PRIORITY+ " loaded.");
  56.             }
  57.         //  API.shared.setWorldSyncedData("WorkBusGlobal", Misc.TO_JSON(WorkBusGlobal));
  58.         }      
  59.     }
  60. }
  61.  
  62. // commands
  63. [Command("create_busroute")]
  64.         [Command("create_busroute")]
  65.         public void Command_create_busroute(Client player, string route_name)
  66.         {
  67.             if(API.getEntityData(player, "BusRouteEditorID") != 0)
  68.             {
  69.                 API.sendChatMessageToPlayer(player, "Ошибка: Выйдите из режима редактирования маршрута.");
  70.                 return;
  71.             }
  72.             else if(route_name.Length < 5)
  73.             {
  74.                 API.sendChatMessageToPlayer(player, "Ошибка: Название маршрута должно быть не менее 5 символов.");
  75.                 return;
  76.             }
  77.             else if(route_name.Length > 50)
  78.             {
  79.                 API.sendChatMessageToPlayer(player, "Ошибка: Название маршрута должно быть не более 50 символов.");
  80.                 return;
  81.             }
  82.            
  83.            
  84.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement