Example #1
0
        public void OnResourceStart()
        {
            // set up database connection
            MySqlInsightDbProvider.RegisterProvider();
            _database           = new MySqlConnectionStringBuilder("server=localhost;user=root;database=gtanserver;port=3306;password="******"GAS_STATION");

            // get delivery locations, convert to Vector3's, and create col shapes
            // also save id in colshape entity data
            foreach (var station in gasStations)
            {
                dynamic d     = API.fromJson(station.DeliverLocation);
                Vector3 pos   = new Vector3((float)d.X, (float)d.Y, (float)(d.Z - 1));
                var     shape = API.createCylinderColShape(pos, 4, 8);
                shape.setData("ID", station.Id);

                // add shapes to list
                deliveryColShapes.Add(shape);
            }

            // initailize list of tanker models
            tankerModels.Add(-730904777);
            tankerModels.Add(1956216962);
            tankerModels.Add(-1207431159);

            // synchronize list of contracts
            contracts = ArrayList.Synchronized(contractsAsync);

            // set up start job start blip, shape, etc...
            var jobStartPos     = new Vector3(1383.331, -2079.071, 51.99853 + 1);
            var jobStartTextPos = new Vector3(1383.331, -2079.071, 51.99853 + 1.5);

            jobStartShape = API.createSphereColShape(jobStartPos, 3f);

            var jobStartMarker    = API.createMarker(20, jobStartPos, new Vector3(), new Vector3(180, 0, -25), new Vector3(1, 1, 1), 150, 0, 0, 255, 0);
            var jobStartTextLabel = API.createTextLabel("~b~ Trucking Job: Gas", jobStartTextPos, 100f, 0.3f, true);

            var jobStartBlip = API.createBlip(jobStartMarker);

            API.setBlipSprite(jobStartBlip, 477);
            API.setBlipColor(jobStartBlip, 26);
            API.setBlipName(jobStartBlip, "Trucking Job: Gas");

            // create job return shape
            jobEndPos   = new Vector3(1361, -2066, 52);
            jobEndShape = API.createSphereColShape(jobEndPos, 4f);
        }