Beispiel #1
0
 public Checkpoint(Vector3 coordinates, OnEnterCheckpointDelegate enterDelegate, int dimension = 0)
 {
     entrance = API.shared.createMarker(0, coordinates, new Vector3(), new Vector3(), new Vector3(1, 1, 1), 255, 255, 0, 0, dimension);
     shape    = API.shared.createSphereColShape(coordinates, range);
     shape.onEntityEnterColShape += EntityEnteredCheckpoint;
     OnEnterCheckPointEvent      += enterDelegate;
 }
Beispiel #2
0
        //public SphereColShape entershape = null;
        //public SphereColShape exitshape = null;
        #endregion

        #region methods
        public static Door Create(int type, String name, Vector3 pos, int vw)
        {
            Door door = new Door();

            Database.command.CommandText  = "INSERT INTO doors (name, enterx, entery, enterz, entervw, markertype) ";
            Database.command.CommandText += String.Format("VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')",
                                                          name, pos.X.ToString().Replace(",", "."), pos.Y.ToString().Replace(",", "."), pos.Z.ToString().Replace(",", "."), vw, type);
            Database.command.ExecuteNonQuery();
            door.uid        = (int)Database.command.LastInsertedId;
            door.name       = name;
            door.enterx     = pos.X;
            door.entery     = pos.Y;
            door.enterz     = pos.Z;
            door.entervw    = vw;
            door.markerType = type;
            Marker marker = API.shared.createMarker(type, pos, new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(1, 1, 1),
                                                    door.alpha, door.colr, door.colg, door.colb, vw);

            door.marker = marker;
            SphereColShape entershape = API.shared.createSphereColShape(new Vector3(door.enterx, door.entery, door.enterz), 2f);

            Door.DoorSpheres.Add(entershape, door);
            DoorList.Add(door);
            return(door);
        }
Beispiel #3
0
 /// <summary>
 /// Removes the checkpoint
 /// </summary>
 public void DestroyCheckpoint()
 {
     entrance.delete();
     API.shared.deleteColShape(shape);
     shape    = null;
     entrance = null;
 }
Beispiel #4
0
 /// <summary>
 /// Removes the checkpoint
 /// </summary>
 public void DestroyCheckpoint()
 {
     API.shared.consoleOutput("Deleted checkpoint!");
     entrance.delete();
     API.shared.deleteColShape(shape);
     shape    = null;
     entrance = null;
 }
Beispiel #5
0
 private Checkpoint(Vector3 coords, OnEnterCheckpointDelegate enterDelegate, OnExitCheckpointDelegate exitDelegate, int markerType, int dimension, float scaleX, float scaleY, float scaleZ, int alpha, int colorR, int colorG, int colorB, bool popUpAndDown)
 {
     entrance = API.shared.createMarker(markerType, coords, new Vector3(), new Vector3(), new Vector3(scaleX, scaleY, scaleZ), alpha, colorR, colorG, colorB, dimension, popUpAndDown);
     shape    = API.shared.createSphereColShape(coords, range * Math.Max(scaleX, scaleY));
     shape.onEntityEnterColShape += EntityEnteredCheckpoint;
     shape.onEntityExitColShape  += EntityExitedCheckpoint;
     OnEnterCheckPointEvent      += enterDelegate;
     OnExitCheckPointEvent       += exitDelegate;
 }
Beispiel #6
0
 public static void DrawSphereColShape(SphereColShape colshape, bool draw = true)
 {
     if (draw)
     {
         SphereColShape = colshape;
         API.shared.triggerClientEventForAll("drawSphereColShape", colshape.Center, colshape.Range, colshape.handle);
         colshape.onEntityEnterColShape += OnEntityEnterColShapeHandler;
     }
     else
     {
         API.shared.triggerClientEventForAll("delSphereColShape");
     }
 }
Beispiel #7
0
        public ClientCheckpoint(int id, Client client, Vector3 coords, int type, OnEnterCheckpointDelegate delegate1, OnExitCheckpointDelegate delegate2)
        {
            this.id     = id;
            this.client = client;
            shape       = API.shared.createSphereColShape(coords, range);
            shape.onEntityEnterColShape += EntityEnteredCheckpoint;
            shape.onEntityExitColShape  += EntityExitedCheckpoint;

            this.onEnterCheckpointEvent += delegate1;
            this.onExitCheckpointEvent  += delegate2;

            // Send info to client with triggerClientCommand, need to send id too
            API.shared.triggerClientEvent(client, "EVENT_CREATE_CHECKPOINT", id, coords, type, 255, 0, 0);
        }
Beispiel #8
0
        // Load all doors
        public static void LoadDoors()
        {
            API.shared.consoleOutput("[load] Wczytuje drzwi...");
            Database.command.CommandText = String.Format("SELECT * FROM doors");
            Database.Reader = Database.command.ExecuteReader();

            var r = Database.Reader;

            while (r.Read())
            {
                Door door = new Door();
                door.uid        = r.GetInt32("uid");
                door.owner      = r.GetInt32("owner");
                door.ownertype  = r.GetInt32("ownertype");
                door.name       = r.GetString("name");
                door.enterx     = r.GetFloat("enterx");
                door.entery     = r.GetFloat("entery");
                door.enterz     = r.GetFloat("enterz");
                door.exitx      = r.GetFloat("exitx");
                door.exity      = r.GetFloat("exity");
                door.exitz      = r.GetFloat("exitz");
                door.entervw    = r.GetInt32("entervw");
                door.exitvw     = r.GetInt32("exitvw");
                door.enterangle = r.GetFloat("enterangle");
                door.exitangle  = r.GetFloat("exitangle");
                door.markerType = r.GetInt32("markertype");
                door.colr       = r.GetInt32("colr");
                door.colg       = r.GetInt32("colg");
                door.colb       = r.GetInt32("colb");
                door.alpha      = r.GetInt32("alpha");
                door.marker     = API.shared.createMarker(door.markerType, new Vector3(door.enterx, door.entery, door.enterz),
                                                          new Vector3(), new Vector3(), new Vector3(1, 1, 1), door.alpha, door.colr, door.colg, door.colb, door.entervw);

                SphereColShape entershape = API.shared.createSphereColShape(new Vector3(door.enterx, door.entery, door.enterz), 2f);
                Door.DoorSpheres.Add(entershape, door);
                Door.DoorList.Add(door);
            }

            Database.Reader.Close();
            API.shared.consoleOutput("[load] Załadowano " + Door.DoorList.Count + " drzwi.");
        }
Beispiel #9
0
 public Checkpoint(Vector3 coordinates)
 {
     entrance = API.shared.createMarker(0, coordinates, new Vector3(), new Vector3(), new Vector3(1, 1, 1), 255, 255, 0, 0, 0);
     shape    = API.shared.createSphereColShape(coordinates, range);
 }
        public void FarmZone()
        {
            try
            {
                // resourceName - The name of the item, will be displayed in inventy with the same name | String
                // itemPrice - The price for the item at the trader | int
                // unprocessedItemID - The item ID before it was processed, see initItem.cs | int
                // processedItemID - The item ID before it was processed, see initItem.cs | int
                // farmZoneName - The name of the farm zone on the map | String
                // processName - The name of the process zone on the map | String
                // traderName - The name of the trader PNJ on the map | String
                // farmZonePos - The position of the farm zone on the map | Vector3
                // processPos - The position of the process zone on the map | Vector3
                // traderPos - The position of the trader PNJ on the map | Vector3
                // processPnjRotation - Determinate the direction the pnj will be | float
                // traderPnjRotation - Determinate the direction the pnj will be | float
                // blip - the blip type | int
                // blipColor - Determinate the color of the blip | int
                // legal - set true if the resource is legal, else the blip is disabled | bool
                // farmZoneScale - set the zone range | float
                // skin traitetement | PedHash
                // skin trader | PedHash
                var farm = new object[5, 18] {
                    { "Cuivre", 190, 85, 86, "Mine de cuivre", "Fonderie de cuivre", "Vendeur de Cuivre", new Vector3(2684.724, 2866.268, 33), new Vector3(741.797, -972.2991, 24.50507), new Vector3(606, -3073.102, 6.06), -94.82858f, -11.52882f, 85, 64, true, 100f, -973145378, 797459875 },
                    { "Raisin", 215, 87, 88, "Vignes", "Traitement de Raisin", "Vendeur de Raisin", new Vector3(-1791, 2146, 30), new Vector3(-67.01217, 1909.044, 196.1046), new Vector3(-1341.587, -1078.23, 6.938033), -94.82858f, -155.4158f, 85, 25, true, 100f, -973145378, 797459875 },
                    { "Weed", 532, 90, 91, "Weed", "Traitement de Weed", "Dealer de Weed", new Vector3(2224.306, 5577.014, 53.85302), new Vector3(709.16, 4185.644, 40.70919), new Vector3(-1156.675, -1574.621, 8.344103), -90f, -151f, 85, 27, false, 10f, -1835459726, -459818001 },
                    { "Pétrole", 192, 94, 95, "Pétrole Brut", "Raffinerie de Pétrole", "Dépot d'essence", new Vector3(600.788, 2859.656, 39.58144), new Vector3(826.7706, -1992.382, 29.30135), new Vector3(580.2372, -2805.223, 6.059413), -21f, -126f, 361, 85, true, 50f, -1835459726, -459818001 },
                    { "Sable", 192, 96, 97, "Carrière de Sable", "Traitement de Sable", "Vendeur de verre", new Vector3(232.136, 7009.544, 1.883199), new Vector3(973.6821, -1942.985, 31.06884), new Vector3(575.4752, 137.3664, 99.47485), -178f, -179f, 85, 81, true, 50f, -1835459726, -459818001 }
                };

                int v = farm.GetLength(0);
                for (int i = 0; i < v; i++)
                {
                    string  resourceName       = (string)farm[i, 0];
                    int     itemPrice          = (int)farm[i, 1];
                    int     unprocessedItemID  = (int)farm[i, 2];
                    int     processedItemID    = (int)farm[i, 3];
                    string  farmZoneName       = (string)farm[i, 4];
                    string  processName        = (string)farm[i, 5];
                    string  traderName         = (string)farm[i, 6];
                    Vector3 farmZonePos        = (Vector3)farm[i, 7];
                    Vector3 processPos         = (Vector3)farm[i, 8];
                    Vector3 traderPos          = (Vector3)farm[i, 9];
                    float   processPnjRotation = (float)farm[i, 10];
                    float   traderPnjRotation  = (float)farm[i, 11];
                    int     blip           = (int)farm[i, 12];
                    int     blipColor      = (int)farm[i, 13];
                    bool    legal          = (bool)farm[i, 14];
                    float   farmZoneScale  = (float)farm[i, 15];
                    PedHash traitementhash = (PedHash)farm[i, 16];
                    PedHash traiderhash    = (PedHash)farm[i, 17];
                    API.consoleOutput("[FARM] Création de la zone: " + resourceName);

                    SphereColShape colshape = API.createSphereColShape(farmZonePos, farmZoneScale);
                    //Marker marker = API.createMarker(1, farmZonePos - new Vector3(0, 0, 1f), new Vector3(), new Vector3(), new Vector3(200f, 200f, 250), 30, 255, 255, 255);
                    colshape.setData("FarmValue", unprocessedItemID);

                    Ped pnjtraitement = API.createPed((PedHash)(traitementhash), processPos, processPnjRotation);
                    API.setEntityRotation(pnjtraitement, new Vector3(0, 0, processPnjRotation));
                    API.setEntitySyncedData(pnjtraitement, "Interaction", "Traitement");
                    API.setEntitySyncedData(pnjtraitement, "unprocessedItemID", unprocessedItemID);
                    API.setEntitySyncedData(pnjtraitement, "processedItemID", processedItemID);

                    Ped pnjtraider = API.createPed((PedHash)traiderhash, traderPos, traderPnjRotation);
                    API.setEntityRotation(pnjtraitement, new Vector3(0, 0, traderPnjRotation));
                    API.setEntitySyncedData(pnjtraider, "Interaction", "Trader");
                    API.setEntitySyncedData(pnjtraider, "Trader", resourceName);
                    API.setEntitySyncedData(pnjtraider, "ItemPrice", itemPrice);
                    API.setEntitySyncedData(pnjtraider, "processedItemID", processedItemID);

                    if (legal)
                    {
                        // Farm Zone Marker
                        Blip BlipFarm = API.createBlip(farmZonePos);
                        API.setBlipName(BlipFarm, farmZoneName);
                        API.setBlipColor(BlipFarm, blipColor);
                        API.setBlipShortRange(BlipFarm, true);
                        API.setBlipSprite(BlipFarm, 85);

                        // Traitement Zone Marker
                        Blip BlipTraitement = API.createBlip(processPos);
                        API.setBlipName(BlipTraitement, processName);
                        API.setBlipColor(BlipTraitement, blipColor);
                        API.setBlipShortRange(BlipTraitement, true);
                        API.setBlipSprite(BlipTraitement, 499);

                        // Trader Zone Marker
                        Blip BlipTraider = API.createBlip(traderPos);
                        API.setBlipName(BlipTraider, traderName);
                        API.setBlipColor(BlipTraider, blipColor);
                        API.setBlipShortRange(BlipTraider, true);
                        API.setBlipSprite(BlipTraider, 500);
                    }
                }
            }
            catch (Exception e)
            {
                API.consoleOutput("~r~[ERROR][INITFARM] : ~s~" + e.ToString());
            }
        }
Beispiel #11
0
 public static void Draw(this SphereColShape colshape, bool draw = true)
 {
     Main.DrawSphereColShape(colshape, draw);
 }
Beispiel #12
0
 private void SpawnParking()
 {
     ParkingCol    = API.createSphereColShape(parkingpos, 1f);
     ParkingMarker = API.createMarker(1, parkingpos - new Vector3(0, 0, 1f), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1f), 100, 255, 255, 255);
     ParkingCol.onEntityEnterColShape += ParkingCol_onEntityEnterColShape;
 }