Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////////////////
- // (c) Copywright 2018 - HOBO Gaming. All rights reserved. //
- ////////////////////////////////////////////////////////////////////////////////////////////
- // Please do not share or use this code without permission //
- ////////////////////////////////////////////////////////////////////////////////////////////
- var blips = [];
- var markers = [];
- var locations = [];
- var menu;
- API.onResourceStop.connect(function() {
- for (i=0; i<blips.length; i++) {
- API.deleteEntity(blips[i]);
- }
- for (j=0; j<markers.length; j++) {
- API.deleteEntity(markers[j]);
- }
- blips = [];
- markers = [];
- });
- API.onServerEventTrigger.connect(function (eventName, args) {
- API.sendChatMessage("eventName: " + eventName);
- if (eventName == "HOBO.JOB.Trucking.Blips.Enabled") {
- API.sendChatMessage("HOBO.JOB.Trucking.Blips.Enabled");
- locations = JSON.parse(args[0]);
- for (i=0; i<locations.length; i++) {
- var name = locations[i][0];
- var x = parseFloat(locations[i][1]);
- var y = parseFloat(locations[i][2]);
- var z = parseFloat(locations[i][3]);
- var u = parseFloat(locations[i][4]);
- var v = parseFloat(locations[i][5]);
- var w = parseFloat(locations[i][6]);
- blips[i] = API.createBlip(new Vector3(x,y,z));
- API.setBlipName(blips[i],name);
- API.setBlipColor(blips[i],46);
- API.setBlipSprite(blips[i],477);
- 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);
- }
- }
- if (eventName == "HOBO.JOB.Trucking.Blips.Disabled") {
- for (i=0; i<blips.length; i++) {
- API.deleteEntity(blips[i]);
- }
- for (j=0; j<markers.length; j++) {
- API.deleteEntity(markers[j]);
- }
- blips = [];
- markers = [];
- }
- if (eventName == "HOBO.JOB.Trucking.GUI.Enabled") {
- var col_index = args[1];
- //API.sendChatMessage("HOBO.JOB.Trucking.GUI.Enabled");
- API.sendChatMessage("col_index: " + col_index);
- locations = JSON.parse(args[0]);
- var county_index = 0;
- var legal_index = 0;
- var legals = ["Legal","Illegal"];
- var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
- var goto_name = locations[county_index][0];
- var x = parseFloat(locations[county_index][1]);
- var y = parseFloat(locations[county_index][2]);
- var z = parseFloat(locations[county_index][3]);
- var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
- var new_vector = new Vector3(x,y,z);
- var total_distance = cur_vector.DistanceTo(new_vector);
- total_money = Math.floor(total_distance/10);
- if (legal_index == 1) {total_money = total_money + total_money*0.25}
- var total_distance = 123;
- var total_money = 345;
- //MENU
- menu = API.createMenu("~u~Trucking", "~h~"+locations[col_index][0], 0, 0, 6);
- API.setMenuBannerRectangle(menu, 255, 255,255,0);
- menu.ResetKey(menuControl.Back);
- //DISTANCE
- var distance = API.createColoredItem("~u~Distance: "+Math.floor(total_distance)+"m", "The total distance from this truck stop to the next.", " #FFFF00", "#CCCC00");
- menu.AddItem(distance);
- //MONEY
- var money = API.createColoredItem("~u~Money: $"+total_money, "The total distance from this truck stop to the next.", " #FFFF00", "#CCCC00");
- menu.AddItem(money);
- //COUNTY
- var county_list = new List(String);
- for (i=0; i<locations.length; i++) { county_list.Add(locations[i][0]); }
- county_item = API.createListItem("Location", "The truck stop that you wish to deliver goods to.", county_list, 0);
- county_item.OnListChanged.connect(function(item, new_index) {
- county_index = new_index;
- //API.setMenuSubtitle(menu,"$0 | 0m");
- var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
- var goto_name = locations[county_index][0];
- var x = parseFloat(locations[county_index][1]);
- var y = parseFloat(locations[county_index][2]);
- var z = parseFloat(locations[county_index][3]);
- var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
- var new_vector = new Vector3(x,y,z);
- var total_distance = cur_vector.DistanceTo(new_vector);
- total_money = Math.floor(total_distance/10);
- if (legal_index == 1) {total_money = total_money + total_money*0.25}
- distance.Text = "~u~Distance: "+Math.floor(total_distance)+"m";
- money.Text = "~u~Money: $"+total_money;
- });
- menu.AddItem(county_item);
- //LEGAL
- var legal_list = new List(String);
- legal_list.Add("Legal");
- legal_list.Add("Illegal");
- 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);
- legal_item.OnListChanged.connect(function(item, new_index) {
- legal_index = new_index;
- //API.setMenuSubtitle(menu,"$0 | 0m");
- var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
- var goto_name = locations[county_index][0];
- var x = parseFloat(locations[county_index][1]);
- var y = parseFloat(locations[county_index][2]);
- var z = parseFloat(locations[county_index][3]);
- var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
- var new_vector = new Vector3(x,y,z);
- var total_distance = cur_vector.DistanceTo(new_vector);
- total_money = Math.floor(total_distance/10);
- if (legal_index == 1) {total_money = total_money + total_money*0.25}
- distance.Text = "~u~Distance: "+Math.floor(total_distance)+"m";
- money.Text = "~u~Money: $"+total_money;
- });
- menu.AddItem(legal_item);
- //SELECT
- select_btn = API.createMenuItem("Start Mission", "Hit enter to select the current setting for your trucking mission.");
- select_btn.Activated.connect(function(menu, item) {
- menu.Visible = false;
- menu.Clear();
- var PlayerPos = API.getEntityPosition(API.getLocalPlayer());
- var goto_name = locations[county_index][0];
- var x = parseFloat(locations[county_index][1]);
- var y = parseFloat(locations[county_index][2]);
- var z = parseFloat(locations[county_index][3]);
- var u = parseFloat(locations[county_index][4]);
- var v = parseFloat(locations[county_index][5]);
- var w = parseFloat(locations[county_index][6]);
- API.sendChatMessage("cur name: " + "???");
- API.sendChatMessage("go to name: " + goto_name);
- var cur_vector = new Vector3(PlayerPos.X,PlayerPos.Y,PlayerPos.Z);
- var new_vector = new Vector3(x,y,z);
- var total_distance = cur_vector.DistanceTo(new_vector);
- total_money = Math.floor(total_distance/10);
- if (legal_index == 1) {total_money = total_money*0.25}
- API.showColoredShard("Mission Started!", "It's time to get your fat ass trucking...", 1, 209, 5000);
- API.setWaypoint(x,y);
- API.triggerServerEvent("HOBO.JOB.Trucking.MissionStart",new_vector);
- //create destination colshape
- //remove event handling?
- //rewards
- //delete destination blip
- //delete destination marker
- //delete destination colshape
- //remove event handling?
- //reinitialize
- });
- menu.AddItem(select_btn);
- //fix
- menu.GoDown();
- menu.GoDown();
- menu.Visible = true;
- }
- if (eventName == "HOBO.JOB.Trucking.GUI.Disabled") {
- //API.sendChatMessage("HOBO.JOB.Trucking.GUI.Disabled");
- menu.Visible = false;
- menu.Clear();
- API.removeWaypoint();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement