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());
            }
        }
Exemple #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);
             }
         }
     }
 }
Exemple #3
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());
     }
 }
Exemple #4
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!");
                    }
                }
            }
        }
Exemple #5
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);
                    }
                }
            }
        }