public void ItemSelected(Client sender, int index)
 {
     try
     {
         var Products = API.getEntityData(sender, "ProductsOfUsingShop");
         var item     = ItemByID(Products[index].Key);
         var price    = Products[index].Value;
         API.resetEntityData(sender, "ProductsOfUsingShop");
         if (Money.TakeMoney(sender, price))
         {
             InventoryHolder ih = API.shared.getEntityData(sender, "InventoryHolder");
             ih.AddItemToInventory(item, 1);
             UpdatePlayerMoney(sender);
             API.shared.triggerClientEvent(sender, "display_subtitle", "Item ajouté à votre inventaire", 3000);
         }
         else
         {
             API.shared.triggerClientEvent(sender, "display_subtitle", "Désolé, vous n'avez pas assez d'argent", 3000);
         }
     }
     catch (Exception e)
     {
         API.consoleOutput("~r~[ERROR][INITITEM] : ~s~" + e.ToString());
     }
 }
Example #2
0
 private void OnClientEventTrigger(Client sender, string eventName, object[] arguments)
 {
     if (eventName == "menu_handler_select_item")
     {
         if ((int)arguments[0] == 181)
         {
             var Products = API.getEntityData(sender, "ProductsOfUsingShop");
             var item     = ItemByID(Products[(int)arguments[1]].Key);
             var price    = Products[(int)arguments[1]].Value;
             API.resetEntityData(sender, "ProductsOfUsingShop");
             InventoryHolder ih = API.getEntityData(sender, "InventoryHolder");
             if (ih.CheckWeightInventory(item, 1))
             {
                 if (Money.TakeMoney(sender, price))
                 {
                     ih.AddItemToInventory(item, 1);
                     UpdatePlayerMoney(sender);
                     API.triggerClientEvent(sender, "display_subtitle", "L'arme a été ajouté à votre inventaire", 3000);
                 }
                 else
                 {
                     API.triggerClientEvent(sender, "display_subtitle", "Désolé, vous n'avez pas assez d'argent", 3000);
                 }
             }
             else
             {
                 API.triggerClientEvent(sender, "display_subtitle", "Désolé, vous n'avez pas assez de place dans votre inventaire.", 3000);
             }
         }
     }
 }
        public static void StartFarming(Client sender)
        {
            try
            {
                if (Players.Player.IsOnProgress(sender))
                {
                    return;
                }
                InventoryHolder ih = API.shared.getEntityData(sender, "InventoryHolder");
                var             unprocessedItemID = API.shared.getEntityData(sender, "OnFarmZone");
                Item            itemfarm          = ItemByID(unprocessedItemID);

                if (ih.CheckWeightInventory(itemfarm))
                {
                    Players.Player.OnProgress(sender);
                    API.shared.triggerClientEvent(sender, "display_subtitle", "Vous commencez à ramasser du ~r~" + itemfarm.Name, 5000);
                    bool _exit = false;
                    int  count = 0;

                    while (!_exit)
                    {
                        API.shared.sleep(10000);
                        if (!API.shared.hasEntityData(sender.handle, "OnFarmZone"))
                        {
                            API.shared.triggerClientEvent(sender, "display_subtitle", "Récolte interrompue : Veuillez retourner dans la zone pour récolter.", 60000); _exit = true;
                            return;
                        }
                        else if (!ih.CheckWeightInventory(itemfarm))
                        {
                            _exit = true;
                        }
                        else if (sender.vehicle != null)
                        {
                            _exit = true;
                        }
                        count = count + 1;
                        ih.AddItemToInventory(itemfarm, 1);
                        API.shared.triggerClientEvent(sender, "display_subtitle", "Récolte en cours: Vous avez ramassé +1 ~r~" + itemfarm.Name, 5000);
                    }
                    API.shared.triggerClientEvent(sender, "display_subtitle", "Récolte terminée : Vous avez ramassé ~r~" + count.ToString() + " " + itemfarm.Name.ToString(), 60000);
                    Players.Player.OnProgress(sender, false);
                }
                else
                {
                    API.shared.triggerClientEvent(sender, "display_subtitle", "Vous inventaire est plein!", 60000);
                }
            }
            catch (Exception e)
            {
                API.shared.consoleOutput("~r~[ERROR][INITFARM] : ~s~" + e.ToString());
            }
        }
Example #4
0
 private void OnClientEventTrigger(Client sender, string eventName, object[] arguments)
 {
     try
     {
         if (eventName == "menu_handler_select_item")
         {
             if ((int)arguments[0] == 182)
             {
                 if (arguments[1] == null)
                 {
                     return;
                 }
                 var Products = API.getEntityData(sender, "ProductsOfUsingShop");
                 var item     = ItemByID(Products[(int)arguments[1]].Key);
                 var price    = Products[(int)arguments[1]].Value;
                 API.resetEntityData(sender, "ProductsOfUsingShop");
                 InventoryHolder ih = API.getEntityData(sender, "InventoryHolder");
                 if (ih.CheckWeightInventory(item, 1))
                 {
                     if (Money.TakeMoney(sender, price))
                     {
                         ih.AddItemToInventory(item, 1);
                         UpdatePlayerMoney(sender);
                         API.triggerClientEvent(sender, "display_subtitle", "Item ajouté à votre inventaire", 3000);
                     }
                     else
                     {
                         API.triggerClientEvent(sender, "display_subtitle", "Désolé, vous n'avez pas assez d'argent", 3000);
                     }
                 }
                 else
                 {
                     API.triggerClientEvent(sender, "display_subtitle", "Désolé, vous n'avez pas assez de place dans votre inventaire.", 3000);
                 }
             }
         }
     }
     catch (Exception e)
     {
         API.shared.consoleOutput("~r~[ERROR][OnClientEventTrigger] : ~s~" + e.ToString());
     }
 }
        private void OpenHouseInventory(Client sender)
        {
            NetHandle House = API.createObject((int)-53650680, new Vector3(0, 0, 0), new Vector3(0, 0, 0), 10);

            HandleList.Add(House);
            InventoryHolder HouseStock = new InventoryHolder();

            HouseStock.Owner = House;
            API.setEntityData(House, "weight_max", 100);
            API.setEntityData(House, "weight", 0);
            API.setEntityData(sender, "HouseObject", House);
            string OwnerHouseName = sender.getData("Housing_Owner"); // check à qui appartient l'appartement
            int    ID             = sender.getData("Housing_ID");    // check de l'id de l'appartement

            //Client OwnerHouseClient = EntityManager.GetClientName(OwnerHouseName);
            var           result  = GetHouseInventory(ID, OwnerHouseName);
            List <String> Actions = new List <string>();

            if (result.Rows.Count != 0)
            {
                foreach (DataRow row in result.Rows)
                {
                    if (!((row["Inventory"]).Equals("[]")))
                    {
                        var inventairerow = Convert.ToString(row["inventory"]);
                        var inventaire    = inventairerow.Split(new[] { "],[" }, StringSplitOptions.None);
                        foreach (var I in inventaire)
                        {
                            var  I2      = I.ToString().Replace("[", "").Replace("]", "");
                            var  I3      = I2.Split(new[] { "," }, StringSplitOptions.None);
                            Item item    = ItemByID(Convert.ToInt16(I3[0]));
                            int  ItemQty = Convert.ToInt16(I3[1]);
                            Actions.Add(item.Name + " :  " + ItemQty);
                            HouseStock.AddItemToInventory(item, ItemQty);
                        }
                    }
                }
                API.triggerClientEvent(sender, "bettermenuManager", 54, "Inventaire Maison", "Selectionner l'item : ", false, Actions);
            }
            API.setEntityData(sender, "Home_InventoryHolder", HouseStock);
        }
        public static void StartTraitement(Client sender, NetHandle pnj)
        {
            try
            {
                if (Players.Player.IsOnProgress(sender))
                {
                    return;
                }
                int idnontraite = API.shared.getEntitySyncedData(pnj, "unprocessedItemID");
                int idtraite    = API.shared.getEntitySyncedData(pnj, "processedItemID");

                InventoryHolder ih            = API.shared.getEntityData(sender, "InventoryHolder");
                Item            itemnontraite = ItemByID(idnontraite);
                Item            itemtraite    = ItemByID(idtraite);

                InventoryItem items = ih.Inventory.SingleOrDefault(ii => ii.Details.ID == itemnontraite.ID);
                if (items != null)
                {
                    int qtitem = items.Quantity;
                    Players.Player.OnProgress(sender);
                    API.shared.triggerClientEvent(sender, "display_subtitle", "Vous traitez vos  ~r~" + qtitem.ToString() + " " + itemnontraite.Name.ToString(), 2000);

                    if (qtitem > 0)
                    {
                        API.shared.setEntitySyncedData(sender.handle, "InProgress", true);
                        API.shared.sleep(30000 + (1000 * qtitem));
                        ih.RemoveItemFromInventory(itemnontraite, qtitem);
                        ih.AddItemToInventory(itemtraite, qtitem);
                        API.shared.setEntitySyncedData(sender.handle, "InProgress", false);
                    }



                    /*
                     * bool _exit = false;
                     * var startTime = DateTime.UtcNow;
                     *
                     * while (!_exit || sender !=null) {
                     *  if(sender.vehicle != null || sender.position.DistanceToSquared(API.getEntityPosition(pnj)) > 60f || DateTime.UtcNow - startTime > TimeSpan.FromSeconds(15 * qtitem)) {
                     *      _exit = true;
                     *      ih.AddItemToInventory(itemnontraite, qtitem);
                     *      Players.Player.OnProgress(sender, false);
                     *      API.sendNotificationToPlayer(sender, "[TRAITEMENT] Abandonné.");
                     *      return;
                     *  }
                     * }
                     *
                     * ih.AddItemToInventory(itemtraite, qtitem);
                     *
                     * API.setEntitySyncedData(sender.handle, "InProgress", false);
                     */
                    UpdatePlayerInfo(sender);
                    API.shared.triggerClientEvent(sender, "display_subtitle", "Vous avez traité vos ~r~" + itemnontraite.Name, 30000);
                    Players.Player.OnProgress(sender, false);
                }
                else
                {
                    API.shared.triggerClientEvent(sender, "display_subtitle", "Vous n'avez rien à traiter", 30000);
                }
            }
            catch (Exception e)
            {
                API.shared.consoleOutput("~r~[ERROR][INITFARM] : ~s~" + e.ToString());
            }
        }
Example #7
0
        private void OnClientEventTrigger(Client sender, string eventName, params object[] arguments)
        {
            if (eventName == "menu_handler_select_item")
            {
                if ((int)arguments[0] == 132)
                {
                    if (API.hasEntityData(sender, "InventoryHolder"))
                    {
                        InventoryHolder ih   = API.getEntityData(sender, "InventoryHolder");
                        var             item = ih.Inventory[(int)arguments[1]];
                        API.setEntityData(sender, "LastSelectedItem", item);
                        List <String> Actions = new List <string>();
                        Actions.Add("Utiliser /Equiper");
                        Actions.Add("Description");
                        Actions.Add("Donner");
                        Actions.Add("Ranger dans le coffre");
                        Actions.Add("Jeter");
                        API.triggerClientEvent(sender, "bettermenuManager", 133, API.getEntitySyncedData(sender, "Nom_Prenom"), "Selectionner l'item :               Poids : " + API.getEntityData(sender.handle, "weight") + " / " + API.getEntityData(sender.handle, "weight_max"), false, Actions);
                    }
                }
                if ((int)arguments[0] == 133)
                {
                    // Utilise Equiper
                    InventoryItem item = API.getEntityData(sender, "LastSelectedItem");
                    if ((int)arguments[1] == 0)
                    {
                        item.Details.Use(sender);
                        API.resetEntityData(sender, "LastSelectedItem");
                    }
                    // Description
                    if ((int)arguments[1] == 1)
                    {
                        object[] ar = new object[2];
                        ar[0] = item.Details.Description;
                        ar[1] = 2000;
                        API.triggerClientEvent(sender, "display_subtitle", ar);
                    }
                    // Donner au joueur
                    if ((int)arguments[1] == 2)
                    {
                        var peopleNearby = API.getPlayersInRadiusOfPlayer(4, sender);
                        peopleNearby.Remove(sender);
                        API.setEntityData(sender, "NearbyList", peopleNearby);
                        List <String> Actions = new List <string>();
                        foreach (Client player in peopleNearby)
                        {
                            Actions.Add(API.getEntitySyncedData(player, "Nom_Prenom"));
                        }
                        API.triggerClientEvent(sender, "bettermenuManager", 134, API.getEntitySyncedData(sender, "Nom_Prenom"), "Donner l'object au ~g~joueur:", false, Actions);
                    }
                    //Mettre en coffre
                    if ((int)arguments[1] == 3)
                    {
                        API.shared.triggerClientEvent(sender, "get_user_input", 137, "", 3, null);
                    }
                    if ((int)arguments[1] == 4)
                    {
                        var itemS = API.getEntityData(sender, "LastSelectedItem");
                        Items.Items.InventoryHolder invplayer = API.getEntityData(sender, "InventoryHolder");
                        invplayer.RemoveItemFromInventory(item.Details, 1);
                        API.resetEntityData(sender, "LastSelectedItem");
                    }
                }
                // QUANTITE à Donner au Joueur
                if ((int)arguments[0] == 134)
                {
                    API.shared.triggerClientEvent(sender, "get_user_input", 135, "", 3, (int)arguments[1]);
                }
            }

            if (eventName == "menu_handler_user_input")
            {
                // Donner au Joueur VALIDATION
                if ((int)arguments[0] == 135)
                {
                    var item       = API.getEntityData(sender, "LastSelectedItem");
                    var nearbylist = API.getEntityData(sender, "NearbyList");
                    var reciever   = nearbylist[(int)arguments[2]];


                    bool result = Int32.TryParse(arguments[1].ToString(), out int number);
                    if (!result)
                    {
                        API.sendNotificationToPlayer(sender, "Vous devez rentrer exlusivement un nombre."); return;
                    }

                    InventoryHolder invplayer   = API.getEntityData(sender, "InventoryHolder");
                    InventoryHolder invreciever = API.getEntityData(reciever, "InventoryHolder");

                    var itemplayerqty = item.Quantity;
                    if (qty <= itemplayerqty)
                    {
                        if (invreciever.CheckWeightInventory(item.Details, qty))
                        {
                            invplayer.RemoveItemFromInventory(item.Details, qty);
                            invreciever.AddItemToInventory(item.Details, qty);

                            API.sendNotificationToPlayer(sender, "Vous avez donner " + qty.ToString() + " " + item.Details.Name + " à " + (API.getEntitySyncedData(reciever, "Nom_Prenom")).ToString());
                            API.sendNotificationToPlayer(reciever, "Vous avez reçu " + qty.ToString() + " " + item.Details.Name + " de " + (API.getEntitySyncedData(sender, "Nom_Prenom")).ToString());
                            UpdatePlayerInfo(sender);
                            UpdatePlayerInfo(reciever);
                            API.resetEntityData(sender, "LastSelectedItem");
                            API.resetEntityData(sender, "NearbyList");
                        }
                        else
                        {
                            API.sendNotificationToPlayer(sender, (API.getEntitySyncedData(reciever, "Nom_Prenom")).ToString() + " n'a pas la place dans sont inventaire");
                        }
                    }
                    else
                    {
                        API.sendNotificationToPlayer(sender, "Vous en avez pas autant sur vous");
                    }
                }
                // Mettre en coffre VALIDATION
                if ((int)arguments[0] == 137)
                {
                    try
                    {
                        InventoryItem item     = API.getEntityData(sender, "LastSelectedItem");
                        NetHandle     reciever = Vehicles.Vehicle.GetVehicleInRange(sender, 3f);

                        if (Vehicles.Vehicle.LockVehicleState(reciever))
                        {
                            API.sendNotificationToPlayer(sender, "Le véhicule est fermer!");
                            return;
                        }

                        if (item == null || reciever == null)
                        {
                            API.sendNotificationToPlayer(sender, "~r~[ERROR]"); return;
                        }
                        if (API.getEntitySyncedData(reciever, "Locked") == true)
                        {
                            API.sendNotificationToPlayer(sender, "Le véhicule est fermer!");
                        }
                        else
                        {
                            Items.Items.InventoryHolder invplayer   = API.getEntityData(sender, "InventoryHolder");
                            Items.Items.InventoryHolder invreciever = API.getEntityData(reciever, "InventoryHolder");
                            string plate = API.getEntitySyncedData(reciever, "Plate");
                            qty = Convert.ToInt32(arguments[1]);
                            if (qty <= 0)
                            {
                                API.sendNotificationToPlayer(sender, "ERREUR!"); return;
                            }
                            var itemplayerqty = item.Quantity;
                            if (qty <= itemplayerqty)
                            {
                                if (invreciever.CheckWeightInventory(item.Details, qty))
                                {
                                    invplayer.RemoveItemFromInventory(item.Details, qty);
                                    invreciever.AddItemToInventory(item.Details, qty);

                                    API.sendNotificationToPlayer(sender, "Vous avez mis  ~r~" + qty.ToString() + " " + item.Details.Name + " ~s~dans le coffre du véhicule: " + plate);
                                }
                                else
                                {
                                    API.sendNotificationToPlayer(sender, plate + " n'a pas la place dans le coffre.");
                                }
                            }
                            else
                            {
                                API.sendNotificationToPlayer(sender, "Vous en avez pas autant sur vous");
                            }
                            API.resetEntityData(sender, "LastSelectedItem");
                            API.resetEntityData(sender, "NearbyList");
                            UpdatePlayerInfo(sender);
                        }
                    }
                    catch (FormatException)
                    {
                        API.sendNotificationToPlayer(sender, "ERREUR!");
                    }
                }
            }
        }
Example #8
0
        private void OnClientEventTrigger(Client sender, string eventName, object[] arguments)
        {
            if (eventName == "menu_handler_select_item")
            {
                if ((int)arguments[0] == 34)
                {
                    if (Players.Money.TakeMoney(sender, 500))
                    {
                        API.setPlayerHealth(sender, 100);
                        API.sendNotificationToPlayer(sender, "Vous avez été soigné.");
                    }
                    else
                    {
                        API.sendNotificationToPlayer(sender, "Vous n'avez pas assez d'argent sur vous.");
                    }
                }

                else if ((int)arguments[0] == 450 && (int)arguments[1] == 0)
                {
                    if (!IsMedic(sender))
                    {
                        API.shared.setEntitySyncedData(sender, "IsMedic", true);
                        API.sendNotificationToPlayer(sender, "Vous avez pris votre service.");
                        PriseServiceEMS(sender);
                    }
                    else
                    {
                        API.shared.setEntitySyncedData(sender, "IsMedic", false);
                        API.sendNotificationToPlayer(sender, "Vous avez quitté votre service.");
                        QuitterServiceEMS(sender);
                    }
                }
                else if ((int)arguments[0] == 450 && (int)arguments[1] == 1)
                {
                    if (!IsMedic(sender))
                    {
                        return;
                    }
                    Vehicle EMS = API.createVehicle(VehicleHash.Ambulance, new Vector3(331.3084, -1478.712, 29.77438), new Vector3(0, 0, -59.07445), 0, 0, 0);
                    API.setVehicleNumberPlate(EMS, "LS-EMS");
                    API.setEntitySyncedData(EMS, "Owner", "EMS");
                    Items.Items.InventoryHolder ih = new Items.Items.InventoryHolder();
                    ih.Owner = EMS.handle;
                    API.setEntityData(EMS, "InventoryHolder", ih);
                    API.setEntitySyncedData(EMS, "VEHICLE_FUEL", 100);
                    API.setEntitySyncedData(EMS, "VEHICLE_FUEL_MAX", 100);
                    API.setEntityData(EMS, "weight", 0);
                    API.setEntityData(EMS, "weight_max", 0);
                    API.setVehicleLocked(EMS, true);
                    API.setEntitySyncedData(EMS, "Locked", true);
                }
                else if ((int)arguments[0] == 450 && (int)arguments[1] == 2)
                {
                    List <string> Actions = new List <string>();
                    List <string> label   = new List <string>();
                    foreach (KeyValuePair <int, int> entry in products)
                    {
                        Item item = ItemByID(entry.Key);
                        Actions.Add(item.Name);
                        label.Add("Prix: $" + entry.Value);
                    }
                    API.shared.triggerClientEvent(sender, "bettermenuManager", 454, "Pharmacie", "Sélectionner un item:", false, Actions, label);
                    API.shared.setEntityData(sender, "ProductsOfUsingShop", products);
                }
                else if ((int)arguments[0] == 450 && (int)arguments[1] == 3)
                {
                    List <string> Actions = new List <string>();
                    List <string> label   = new List <string>();
                    foreach (KeyValuePair <int, int> entry in superetteProducts)
                    {
                        Item item = ItemByID(entry.Key);
                        Actions.Add(item.Name);
                        label.Add("Prix: $" + entry.Value);
                    }
                    API.shared.triggerClientEvent(sender, "bettermenuManager", 454, "Supérette EMS", "Sélectionner un item:", false, Actions, label);

                    API.shared.setEntityData(sender, "ProductsOfUsingShop", superetteProducts);
                }

                else if ((int)arguments[0] == 451 && (int)arguments[1] == 0)
                {
                    if (sender.vehicle == null)
                    {
                        return;
                    }
                    API.deleteEntity(sender.vehicle);
                    API.sendNotificationToPlayer(sender, "Vous avez ranger votre véhicule.");
                }

                else if ((int)arguments[0] == 454)
                {
                    var Products = API.getEntityData(sender, "ProductsOfUsingShop");
                    var item     = ItemByID(Products[(int)arguments[1]].Key);
                    API.resetEntityData(sender, "ProductsOfUsingShop");
                    InventoryHolder ih = API.getEntityData(sender, "InventoryHolder");
                    if (ih.CheckWeightInventory(item, 1))
                    {
                        ih.AddItemToInventory(item, 1);
                        API.triggerClientEvent(sender, "display_subtitle", "Item ajouté à votre inventaire", 3000);
                    }
                    else
                    {
                        API.triggerClientEvent(sender, "display_subtitle", "Désolé, vous n'avez pas assez de place dans votre inventaire.", 3000);
                    }
                }
            }
        }
Example #9
0
        private void PlayerConnection(Client player)
        {
            DataTable result = GetPlayerInfo(player);

            if (result.Rows.Count != 0)
            {
                foreach (DataRow row in result.Rows)
                {
                    API.setEntitySyncedData(player.handle, "Money", Convert.ToInt32(row["money"]));
                    API.setEntitySyncedData(player.handle, "adminRank", Convert.ToInt32(row["adminRank"]));
                    API.setEntitySyncedData(player.handle, "LSPDrank", Convert.ToInt32(row["LSPDrank"]));
                    API.setEntitySyncedData(player.handle, "EMSrank", Convert.ToInt32(row["EMSrank"]));
                    API.setEntitySyncedData(player.handle, "BankMoney", Convert.ToInt32(row["bank"]));
                    API.setEntityData(player.handle, "Jailed", Convert.ToBoolean(row["jailed"]));
                    InventoryHolder ih = new InventoryHolder();
                    ih.Owner = player.handle;
                    API.setEntityData(player, "InventoryHolder", ih);
                    API.setEntityData(player.handle, "weight", 0);
                    API.setEntityData(player.handle, "weight_max", 25);
                    API.setEntitySyncedData(player.handle, "IS_DEATH", false);

                    if (!((row["inventory"]).Equals("[]")))
                    {
                        var inventairerow = Convert.ToString(row["inventory"]);
                        var inventaire    = inventairerow.Split(new[] { "],[" }, StringSplitOptions.None);
                        foreach (var I in inventaire)
                        {
                            var  I2   = I.ToString().Replace("[", "").Replace("]", "");
                            var  I3   = I2.Split(new[] { "," }, StringSplitOptions.None);
                            Item item = ItemByID(Convert.ToInt16(I3[0]));
                            ih.AddItemToInventory(item, Convert.ToInt16(I3[1]));
                        }
                    }
                    if (!(row["characters"]).Equals("[]"))
                    {
                        var characters  = Convert.ToString(row["characters"]);
                        var characters1 = characters.Split(new[] { "],[" }, StringSplitOptions.None);

                        var SexeChar      = characters1[0].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var VisageMere    = characters1[1].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var VisagePere    = characters1[2].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var CheveuxChar   = characters1[3].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var ColCheveux    = characters1[4].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var ColYeux       = characters1[5].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var VisageColor   = characters1[6].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var EyeBrown      = characters1[7].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var EyeBrownColor = characters1[8].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");

                        var Nom    = characters1[9].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var Prenom = characters1[10].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                        var Age    = characters1[11].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");

                        string Nom1    = Convert.ToString(Nom);
                        string Prenom1 = Convert.ToString(Prenom);
                        string Age1    = Convert.ToString(Age);
                        nomprenom = "" + Nom1 + " " + Prenom1;

                        API.setEntitySyncedData(player, "VisageMere1", Convert.ToInt32(VisageMere));
                        API.setEntitySyncedData(player, "VisagePere1", Convert.ToInt32(VisagePere));
                        API.setEntitySyncedData(player, "CheveuxChar1", Convert.ToInt32(CheveuxChar));
                        API.setEntitySyncedData(player, "ColCheveux1", Convert.ToInt32(ColCheveux));
                        API.setEntitySyncedData(player, "ColYeux1", Convert.ToInt32(ColYeux));
                        API.setEntitySyncedData(player, "VisageColor1", Convert.ToInt32(VisageColor));
                        API.setEntitySyncedData(player, "EyeBrown1", Convert.ToInt32(CheveuxChar));
                        API.setEntitySyncedData(player, "EyeBrownColor1", Convert.ToInt32(ColCheveux));

                        if (Convert.ToInt32(SexeChar) == 1885233650) // FreeModeMale01
                        {
                            player.setSyncedData("Sexe", "Homme");
                        }
                        else if (Convert.ToInt32(SexeChar) == -1667301416) // FreemodeFemale01
                        {
                            player.setSyncedData("Sexe", "Femme");
                        }

                        // Skin
                        API.setPlayerSkin(player, (PedHash)Convert.ToInt32(SexeChar));
                        API.triggerClientEvent(player, "setplayerskin", player.handle);


                        API.setEntitySyncedData(player.handle, "Nom", Nom1);
                        API.setEntitySyncedData(player.handle, "Prenom", Prenom1);
                        API.setEntitySyncedData(player.handle, "Nom_Prenom", Nom1 + " " + Prenom1);
                        API.setEntitySyncedData(player.handle, "Age", Age1);

                        var vetements1 = Convert.ToString(row["clothing"]).Split(new[] { "],[" }, StringSplitOptions.None);
                        player.setData("Pants", Convert.ToInt32(vetements1[0].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "")));
                        player.setData("Chemise", Convert.ToInt32(vetements1[1].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "")));
                        player.setData("Survet", Convert.ToInt32(vetements1[2].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "")));
                        player.setData("Chaussures", Convert.ToInt32(vetements1[3].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "")));
                        player.setData("Bras", Convert.ToInt32(vetements1[4].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "")));
                        API.setPlayerClothes(player, 4, player.getData("Pants"), 0);
                        API.setPlayerClothes(player, 8, player.getData("Chemise"), 0);
                        API.setPlayerClothes(player, 11, player.getData("Survet"), 0);
                        API.setPlayerClothes(player, 6, player.getData("Chaussures"), 0);
                        API.setPlayerClothes(player, 3, player.getData("Bras"), 0);
                        API.setEntityData(player.handle, "Pants", 0);
                    }

                    if (!(row["position"]).Equals("[]"))
                    {
                        var position1 = Convert.ToString(row["position"]).Split(new[] { "],[" }, StringSplitOptions.None);

                        float posX1 = Convert.ToSingle(position1[0].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", ""));
                        float posY1 = Convert.ToSingle(position1[1].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", ""));
                        float posZ1 = Convert.ToSingle(position1[2].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", ""));
                        API.setEntityPosition(player, new Vector3(posX1, posY1, posZ1 + 1f));
                    }
                    else
                    {
                        API.setEntityPosition(player.handle, new Vector3(-1033.028, -2732.261, 14));
                        API.setEntityRotation(player.handle, new Vector3(0, 0, -37.83434));
                    }

                    API.setEntitySyncedData(player, "PLAYER_HUNGRY", Convert.ToInt32(row["hunger"]));
                    API.setEntitySyncedData(player, "PLAYER_THIRSTY", Convert.ToInt32(row["thirst"]));
                    API.setPlayerHealth(player, Convert.ToInt32(row["health"]));
                    API.setEntitySyncedData(player, "VOICE_RANGE", "Parler");
                    API.setPlayerNametagVisible(player, false);
                    API.setEntitySyncedData(player.handle, "Jobs", false);
                    API.setEntitySyncedData(player.handle, "InProgress", false);
                    API.setEntityData(player.handle, "weight_max", 25);
                    API.setEntityDimension(player, 0);
                    API.setEntitySyncedData(player, "Police", false);
                    API.setEntitySyncedData(player, "IsMedic", false);
                    API.setEntitySyncedData(player, "Arrested", false);
                    LoadLicence(player);
                    API.setEntitySyncedData(player, "IsOnComa", false);
                    API.triggerClientEvent(player, "Teamspeak_Connect", nomprenom);
                    API.triggerClientEvent(player, "StartStatus");
                    API.setEntitySyncedData(player, "LOGGED_IN", true);
                    player.freeze(false);
                    API.sendNativeToPlayer(player, Hash.DO_SCREEN_FADE_IN, 750);
                }
            }
        }
        public static void GetCarSpawn()
        {
            try
            {
                API.shared.consoleOutput("[VEHICLE] Spawn des véhicules sur la map");
                Vector3   spawncarPos;
                Vector3   spawncarRot;
                DataTable result = GetQuery("SELECT classname, pid, plate, inventory ,position, rotation, color, fuel FROM vehicles WHERE active='1'");
                if (result.Rows.Count != 0)
                {
                    foreach (DataRow row in result.Rows)
                    {
                        if (!(row["position"]).Equals("[]") || !(row["position"]).Equals(0))
                        {
                            var position0 = Convert.ToString(row["position"]);
                            var position1 = position0.Split(new[] { "],[" }, StringSplitOptions.None);

                            var posX0 = position1[0].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                            var posY0 = position1[1].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                            var posZ0 = position1[2].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");

                            float posX1 = Convert.ToSingle(posX0);
                            float posY1 = Convert.ToSingle(posY0);
                            float posZ1 = Convert.ToSingle(posZ0);
                            spawncarPos = new Vector3(posX1, posY1, posZ1 + 0.5f);
                        }
                        else
                        {
                            spawncarPos = new Vector3(408, -1636, 28);
                        }

                        if (!(row["rotation"]).Equals("[]") || !(row["rotation"]).Equals(0))
                        {
                            var rot0 = Convert.ToString(row["rotation"]);
                            var rot1 = rot0.Split(new[] { "],[" }, StringSplitOptions.None);

                            var rotX0 = rot1[0].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                            var rotY0 = rot1[1].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");
                            var rotZ0 = rot1[2].ToString().Replace("[", "").Replace("]", "").Replace("\"", "").Replace(" ", "");

                            float rotX1 = Convert.ToSingle(rotX0);
                            float rotY1 = Convert.ToSingle(rotY0);
                            float rotZ1 = Convert.ToSingle(rotZ0);
                            spawncarRot = new Vector3(rotX1, rotY1, rotZ1);
                        }
                        else
                        {
                            spawncarRot = new Vector3(0, 0, 0);
                        }

                        VehicleHash     vehicleHash = API.shared.vehicleNameToModel(row["classname"].ToString());
                        var             spawncar    = API.shared.createVehicle(vehicleHash, spawncarPos, spawncarRot, 111, 111);
                        InventoryHolder ivh         = new InventoryHolder();
                        ivh.Owner = spawncar.handle;
                        API.shared.setEntityData(spawncar, "InventoryHolder", ivh);
                        API.shared.setEntityData(spawncar, "weight", 0);
                        API.shared.setEntityData(spawncar, "weight_max", Vehicles.Vehicle.GetVehicleWeight(vehicleHash));
                        if (!((row["inventory"]).Equals("[]")))
                        {
                            var inventairerow = Convert.ToString(row["inventory"]);
                            var inventaire    = inventairerow.Split(new[] { "],[" }, StringSplitOptions.None);
                            foreach (var I in inventaire)
                            {
                                var  I2   = I.ToString().Replace("[", "").Replace("]", "");
                                var  I3   = I2.Split(new[] { "," }, StringSplitOptions.None);
                                Item item = ItemByID(Convert.ToInt16(I3[0]));
                                ivh.AddItemToInventory(item, Convert.ToInt16(I3[1]));
                            }
                        }

                        int color = Convert.ToInt32(row["color"]);
                        API.shared.setVehiclePrimaryColor(spawncar, color);
                        string plate = (row["plate"]).ToString();
                        API.shared.setVehicleNumberPlate(spawncar, plate);
                        API.shared.setEntitySyncedData(spawncar, "Plate", plate);
                        API.shared.setEntitySyncedData(spawncar, "Owner", (row["pid"]).ToString());

                        API.shared.setVehicleLocked(spawncar, true);
                        API.shared.setEntitySyncedData(spawncar, "Locked", true);
                        API.shared.setEntitySyncedData(spawncar, "VEHICLE_FUEL", Convert.ToInt32(row["fuel"]));
                        API.shared.setEntitySyncedData(spawncar, "VEHICLE_FUEL_MAX", 100);
                        API.shared.setVehicleEngineStatus(spawncar, false);
                    }
                }
            }
            catch (Exception e)
            {
                API.shared.consoleOutput("~r~[ERROR] : ~s~" + e.ToString());
            }
        }
Example #11
0
        private void ScriptEvent(Client sender, string eventName, object[] arg)
        {
            try
            {
                if (eventName == "menu_handler_select_item")
                {
                    if ((int)arg[0] == 220)
                    {
                        SaveVehicle(sender);
                    }
                    else if ((int)arg[0] == 221)
                    {
                        if (Players.Money.TakeMoney(sender, 250))
                        {
                            API.sendNotificationToPlayer(sender, "Vous avez rangé votre véhicule dans le garage.");
                            UpdatePlayerMoney(sender);
                            string plate = (String)API.getEntitySyncedData(sender.vehicle, "Plate");
                            Mysql.DBVehicles.SetNotActiveCar(plate);
                            API.deleteEntity(sender.vehicle);
                        }
                        else
                        {
                            API.sendNotificationToPlayer(sender, "Vous n'avez pas assez d'argent sur vous.");
                        }
                    }
                    else if ((int)arg[0] == 222)
                    {
                        DataTable result = Mysql.DBVehicles.GetVehicleInfo(sender);
                        if (result.Rows.Count != 0)
                        {
                            List <string> Actions = new List <string>();
                            List <string> label   = new List <string>();
                            foreach (DataRow row in result.Rows)
                            {
                                Actions.Add(row["classname"].ToString());
                                label.Add((row["plate"]).ToString());
                            }
                            API.triggerClientEvent(sender, "bettermenuManager", 223, "Parking", "Menu parking: ", result, Actions, label);
                        }
                        else
                        {
                            API.sendNotificationToPlayer(sender, "Vous n'avez aucun véhicule dans le garage");
                        }
                    }
                    else if ((int)arg[0] == 223)
                    {
                        DataTable result = Mysql.DBVehicles.GetVehicleInfo(sender);
                        for (int i = 0; i < result.Rows.Count; i++)
                        {
                            if (i == (int)arg[1])
                            {
                                if (Players.Money.TakeMoney(sender, 250))
                                {
                                    DataRow     myRow       = result.Rows[i];
                                    VehicleHash vehicleHash = API.vehicleNameToModel(myRow["classname"].ToString());
                                    Vector3     playerpos   = sender.position;
                                    var         spawncar    = API.createVehicle(vehicleHash, new Vector3(playerpos.X, playerpos.Y + 4f, playerpos.Z), new Vector3(0, 0, 0), 111, 111);

                                    InventoryHolder ivh = new InventoryHolder();
                                    ivh.Owner = spawncar.handle;
                                    API.shared.setEntityData(spawncar, "InventoryHolder", ivh);
                                    API.setEntityData(spawncar, "weight", 0);
                                    API.setEntityData(spawncar, "weight_max", Vehicles.Vehicle.GetVehicleWeight(vehicleHash));

                                    if (!((myRow["inventory"]).Equals("[]")))
                                    {
                                        var inventairerow = Convert.ToString(myRow["inventory"]);
                                        var inventaire    = inventairerow.Split(new[] { "],[" }, StringSplitOptions.None);
                                        foreach (var I in inventaire)
                                        {
                                            var  I2   = I.ToString().Replace("[", "").Replace("]", "");
                                            var  I3   = I2.Split(new[] { "," }, StringSplitOptions.None);
                                            Item item = ItemByID(Convert.ToInt16(I3[0]));
                                            ivh.AddItemToInventory(item, Convert.ToInt16(I3[1]));
                                        }
                                    }

                                    string plate = (myRow["plate"]).ToString();
                                    API.setEntitySyncedData(spawncar, "VEHICLE_FUEL", Convert.ToDecimal(myRow["fuel"]));
                                    API.setVehicleNumberPlate(spawncar, plate);
                                    API.setEntitySyncedData(spawncar, "Plate", plate);
                                    API.setEntitySyncedData(spawncar, "Owner", (myRow["pid"]).ToString());
                                    API.setVehicleLocked(spawncar, true);
                                    API.setEntitySyncedData(spawncar, "Locked", true);
                                    API.setEntitySyncedData(spawncar, "VEHICLE_FUEL", 100);
                                    API.setEntitySyncedData(spawncar, "VEHICLE_FUEL_MAX", 100);
                                    int color = Convert.ToInt32(myRow["color"]);
                                    API.setVehiclePrimaryColor(spawncar, color);
                                    Mysql.DBVehicles.SetActiveCar(plate);
                                    UpdatePlayerMoney(sender);
                                    API.setVehicleEngineStatus(spawncar, false);
                                }
                                else
                                {
                                    API.sendNotificationToPlayer(sender, "Vous n'avez pas assez d'argent sur vous.");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                API.consoleOutput("~r~[ERROR][EVENT] : ~s~" + e.ToString());
            }
        }