Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ////////////////////////////////////////////////////////////////////////////////////////////
  2. //              (c) Copywright 2018 - HOBO Gaming. All rights reserved.                   //
  3. ////////////////////////////////////////////////////////////////////////////////////////////
  4. //              Please do not share or use this code without permission                   //
  5. ////////////////////////////////////////////////////////////////////////////////////////////
  6.  
  7. var blips = [];
  8. var markers = [];
  9. var locations = [];
  10.  
  11. var menu;
  12.  
  13.  
  14.  
  15. API.onResourceStop.connect(function() {
  16.     for (i=0; i<blips.length; i++) {
  17.         API.deleteEntity(blips[i]);
  18.     }
  19.     for (j=0; j<markers.length; j++) {
  20.         API.deleteEntity(markers[j]);
  21.     }
  22.     blips = [];
  23.     markers = [];
  24. });
  25.  
  26. API.onServerEventTrigger.connect(function (eventName, args) {
  27.     API.sendChatMessage("eventName: " + eventName);
  28.     if (eventName == "HOBO.JOB.Trucking.Blips.Enabled") {
  29.         API.sendChatMessage("HOBO.JOB.Trucking.Blips.Enabled");
  30.         locations = JSON.parse(args[0]);
  31.        
  32.         for (i=0; i<locations.length; i++) {
  33.             var name = locations[i][0];
  34.             var x = parseFloat(locations[i][1]);
  35.             var y = parseFloat(locations[i][2]);
  36.             var z = parseFloat(locations[i][3]);
  37.             var u = parseFloat(locations[i][4]);
  38.             var v = parseFloat(locations[i][5]);
  39.             var w = parseFloat(locations[i][6]);
  40.            
  41.             blips[i] = API.createBlip(new Vector3(x,y,z));
  42.             API.setBlipName(blips[i],name);
  43.             API.setBlipColor(blips[i],46);
  44.             API.setBlipSprite(blips[i],477);
  45.             markers[i] = API.createMarker(1, new Vector3(x,y,z-0.55), new Vector3(x,y,z-0.55), new Vector3(u,v,w-0.55), new Vector3(5,5,5), 255,255,0,175);
  46.         }
  47.     }
  48.     if (eventName == "HOBO.JOB.Trucking.Blips.Disabled") {
  49.         for (i=0; i<blips.length; i++) {
  50.             API.deleteEntity(blips[i]);
  51.         }
  52.         for (j=0; j<markers.length; j++) {
  53.             API.deleteEntity(markers[j]);
  54.         }
  55.         blips = [];
  56.         markers = [];
  57.     }
  58.     if (eventName == "HOBO.JOB.Trucking.GUI.Enabled") {
  59.         var col_index = args[1];
  60.         //API.sendChatMessage("HOBO.JOB.Trucking.GUI.Enabled");
  61.         API.sendChatMessage("col_index: " + col_index);
  62.        
  63.         locations = JSON.parse(args[0]);
  64.        
  65.         var county_index = 0;
  66.         var legal_index = 0;
  67.        
  68.         var legals = ["Legal","Illegal"];
  69.        
  70.         var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
  71.        
  72.         var goto_name = locations[county_index][0];
  73.         var x = parseFloat(locations[county_index][1]);
  74.         var y = parseFloat(locations[county_index][2]);
  75.         var z = parseFloat(locations[county_index][3]);
  76.        
  77.         var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
  78.         var new_vector = new Vector3(x,y,z);
  79.         var total_distance = cur_vector.DistanceTo(new_vector);
  80.        
  81.         total_money = Math.floor(total_distance/10);
  82.         if (legal_index == 1) {total_money = total_money + total_money*0.25}
  83.        
  84.         var total_distance = 123;
  85.         var total_money = 345;
  86.         //MENU
  87.             menu = API.createMenu("~u~Trucking", "~h~"+locations[col_index][0], 0, 0, 6);
  88.             API.setMenuBannerRectangle(menu, 255, 255,255,0);
  89.             menu.ResetKey(menuControl.Back);
  90.        
  91.        
  92.         //DISTANCE
  93.             var distance = API.createColoredItem("~u~Distance: "+Math.floor(total_distance)+"m", "The total distance from this truck stop to the next.", " #FFFF00", "#CCCC00");
  94.             menu.AddItem(distance);
  95.        
  96.         //MONEY
  97.             var money = API.createColoredItem("~u~Money: $"+total_money, "The total distance from this truck stop to the next.", " #FFFF00", "#CCCC00");
  98.             menu.AddItem(money);
  99.        
  100.         //COUNTY
  101.             var county_list = new List(String);
  102.             for (i=0; i<locations.length; i++) { county_list.Add(locations[i][0]); }
  103.             county_item = API.createListItem("Location", "The truck stop that you wish to deliver goods to.", county_list, 0);
  104.             county_item.OnListChanged.connect(function(item, new_index) {
  105.                 county_index = new_index;
  106.                 //API.setMenuSubtitle(menu,"$0 | 0m");
  107.                
  108.                 var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
  109.                
  110.                 var goto_name = locations[county_index][0];
  111.                 var x = parseFloat(locations[county_index][1]);
  112.                 var y = parseFloat(locations[county_index][2]);
  113.                 var z = parseFloat(locations[county_index][3]);
  114.                
  115.                 var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
  116.                 var new_vector = new Vector3(x,y,z);
  117.                 var total_distance = cur_vector.DistanceTo(new_vector);
  118.                
  119.                 total_money = Math.floor(total_distance/10);
  120.                 if (legal_index == 1) {total_money = total_money + total_money*0.25}
  121.                
  122.                 distance.Text = "~u~Distance: "+Math.floor(total_distance)+"m";
  123.                 money.Text = "~u~Money: $"+total_money;
  124.             });
  125.             menu.AddItem(county_item);
  126.        
  127.         //LEGAL
  128.             var legal_list = new List(String);
  129.             legal_list.Add("Legal");
  130.             legal_list.Add("Illegal");
  131.             legal_item = API.createListItem("Legal", "Are the goods you are transporting illegal or legal? Note: transporting illegal goods will earn you more cash, but you will gain wanted levels and possibly persued by the cops.", legal_list, 0);
  132.             legal_item.OnListChanged.connect(function(item, new_index) {
  133.                 legal_index = new_index;
  134.                 //API.setMenuSubtitle(menu,"$0 | 0m");
  135.                
  136.                 var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
  137.                
  138.                 var goto_name = locations[county_index][0];
  139.                 var x = parseFloat(locations[county_index][1]);
  140.                 var y = parseFloat(locations[county_index][2]);
  141.                 var z = parseFloat(locations[county_index][3]);
  142.                
  143.                 var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
  144.                 var new_vector = new Vector3(x,y,z);
  145.                 var total_distance = cur_vector.DistanceTo(new_vector);
  146.                
  147.                 total_money = Math.floor(total_distance/10);
  148.                 if (legal_index == 1) {total_money = total_money + total_money*0.25}
  149.                
  150.                 distance.Text = "~u~Distance: "+Math.floor(total_distance)+"m";
  151.                 money.Text = "~u~Money: $"+total_money;
  152.             });
  153.             menu.AddItem(legal_item);
  154.        
  155.        
  156.         //SELECT
  157.             select_btn = API.createMenuItem("Start Mission", "Hit enter to select the current setting for your trucking mission.");
  158.             select_btn.Activated.connect(function(menu, item) {
  159.                 menu.Visible = false;
  160.                 menu.Clear();
  161.                
  162.                 var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
  163.                
  164.                 var goto_name = locations[county_index][0];
  165.                 var x = parseFloat(locations[county_index][1]);
  166.                 var y = parseFloat(locations[county_index][2]);
  167.                 var z = parseFloat(locations[county_index][3]);
  168.                 var u = parseFloat(locations[county_index][4]);
  169.                 var v = parseFloat(locations[county_index][5]);
  170.                 var w = parseFloat(locations[county_index][6]);
  171.                
  172.                 API.sendChatMessage("cur name: " + "???");
  173.                 API.sendChatMessage("go to name: " + goto_name);
  174.                
  175.                 var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
  176.                 var new_vector = new Vector3(x,y,z);
  177.                 var total_distance = cur_vector.DistanceTo(new_vector);
  178.                
  179.                 total_money = Math.floor(total_distance/10);
  180.                 if (legal_index == 1) {total_money = total_money*0.25}
  181.                
  182.                 API.showColoredShard("Mission Started!", "It's time to get your fat ass trucking...", 1, 209, 5000);
  183.                 API.setWaypoint(x,y);
  184.                
  185.                 API.triggerServerEvent("HOBO.JOB.Trucking.MissionStart",new_vector);
  186.                
  187.                 //create destination colshape
  188.                 //remove event handling?
  189.                 //rewards
  190.                 //delete destination blip
  191.                 //delete destination marker
  192.                 //delete destination colshape
  193.                 //remove event handling?
  194.                
  195.                 //reinitialize
  196.             });
  197.            
  198.             menu.AddItem(select_btn);
  199.            
  200.         //fix
  201.         menu.GoDown();
  202.         menu.GoDown();
  203.        
  204.         menu.Visible = true;
  205.     }
  206.     if (eventName == "HOBO.JOB.Trucking.GUI.Disabled") {
  207.         //API.sendChatMessage("HOBO.JOB.Trucking.GUI.Disabled");
  208.        
  209.         menu.Visible = false;
  210.         menu.Clear();
  211.        
  212.         API.removeWaypoint();
  213.     }
  214. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement