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 //
- ////////////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Linq;
- using System.Globalization;
- using System.Collections.Generic;
- using GrandTheftMultiplayer.Server;
- using GrandTheftMultiplayer.Server.API;
- using GrandTheftMultiplayer.Server.Elements;
- using GrandTheftMultiplayer.Server.Constant;
- using GrandTheftMultiplayer.Server.Managers;
- using GrandTheftMultiplayer.Shared;
- using GrandTheftMultiplayer.Shared.Math;
- public class HOBO_JOB_Trucking : Script {
- public int[] vehicle_hashes;
- public string[,] locations;
- public string dataInJson;
- public HOBO_JOB_Trucking() {
- API.onResourceStart += Start;
- API.onPlayerEnterVehicle += OnPlayerEnterVehicle;
- API.onPlayerExitVehicle += OnPlayerExitVehicle;
- API.onClientEventTrigger += OnClientEvent;
- }
- public void Start() {
- //ALLOWED VEHICLE HASHES
- vehicle_hashes = new int[] {
- 1518533038
- };
- //DELIVERY AND PICKUP DATA
- locations = new string[,] {
- {"Fat-Ass Bob's " ,"175.1914","-1841.425","27.99922", "0","0","-137.5902"},
- {"Some smelly spot" ,"468.2673","-1691.558","29.28567", "0","0","-164.2898"},
- {"Adcent's house" ,"-745.4157","-1037.919","12.36418", "0","0","25.49856"}
- };
- dataInJson = API.toJson(locations);
- int length = (locations.Length/7);
- for (int i=0; i <= length-1; i++) {
- float x = float.Parse(locations[i,1]);
- float y = float.Parse(locations[i,2]);
- float z = float.Parse(locations[i,3]);
- CylinderColShape the_col = API.createCylinderColShape(new Vector3(x,y,z), 5.0f, 5.0f);
- the_col.onEntityEnterColShape += Trucker_onEntityEnterColShape;
- the_col.onEntityExitColShape += Trucker_onEntityExitColShape;
- the_col.setData("index", i);
- API.sendChatMessageToAll("~y~INFO: ~w~SPOT: " + locations[i,0] + " | INDEX: " + i);
- }
- }
- private void OnPlayerEnterVehicle(Client player, NetHandle vehicle, int targetSeat) {
- if(API.hasEntitySyncedData(player.handle, "HOBO.Subclass") == false) { API.setEntitySyncedData(player.handle, "HOBO.Subclass", "none"); }
- if(API.getEntitySyncedData(player.handle, "HOBO.Subclass") == "none") {
- if(targetSeat == -1) {
- if(vehicle_hashes.Contains(player.vehicle.model)) {
- API.setEntitySyncedData(player, "on misson",0);
- API.sendChatMessageToPlayer(player, "~y~INFO: ~w~Trucking locations are displayed on the map!");
- API.triggerClientEvent(player, "HOBO.JOB.Trucking.Blips.Enabled",dataInJson);
- }
- }
- }
- }
- private void OnPlayerExitVehicle(Client player, NetHandle vehicle, int fromSeat) {
- if(API.getEntitySyncedData(player.handle, "HOBO.Subclass") == "none") {
- if(fromSeat == -1) {
- if(vehicle_hashes.Contains(API.getEntityModel(vehicle))) {
- API.sendChatMessageToPlayer(player, "~y~INFO: ~w~Trucking mission canceled!");
- API.triggerClientEvent(player, "HOBO.JOB.Trucking.Blips.Disabled");
- }
- }
- }
- }
- private void Trucker_onEntityEnterColShape(ColShape shape, NetHandle entity) {
- var player = API.getPlayerFromHandle(entity);
- if (player == null) {
- return;
- }else{
- var col_index = shape.getData("index");
- API.sendChatMessageToPlayer(player, "~y~INFO: ~w~COL INDEX: " + col_index);
- if (API.getEntitySyncedData(player, "on misson") == 0) {
- API.triggerClientEvent(player, "HOBO.JOB.Trucking.GUI.Enabled",dataInJson,col_index);
- }
- }
- }
- private void Trucker_onEntityExitColShape(ColShape shape, NetHandle entity) {
- var player = API.getPlayerFromHandle(entity);
- if (player == null) {
- return;
- }else{
- var col_index = shape.getData("index");
- API.sendChatMessageToPlayer(player, "~y~INFO: ~w~COL INDEX: " + col_index);
- if (API.getEntitySyncedData(player, "on misson") == 0) {
- API.triggerClientEvent(player, "HOBO.JOB.Trucking.GUI.Disabled");
- }
- }
- }
- public void OnClientEvent(Client player, string eventName, params object[] arguments) {
- if (eventName == "HOBO.JOB.Trucking.MissionStart") {
- API.sendChatMessageToPlayer(player, "~y~INFO: ~w~MISSION STARTED!");
- API.setEntitySyncedData(player, "on misson",1);
- var pla_index = API.getEntitySyncedData(player, "current index");
- API.sendChatMessageToPlayer(player, "~y~INFO: ~w~PLA INDEX: " + pla_index);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement