示例#1
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!");
                    }
                }
            }
        }
        private void OnClientEventTrigger(Client sender, string eventName, object[] arguments)
        {
            if (eventName == "menu_handler_select_item")
            {
                var car = API.getEntityData(sender, "NearbyList");
                if (car == null)
                {
                    return;
                }
                // Menu Vehicule
                if ((int)arguments[0] == 143 && (int)arguments[1] == 0)
                {
                    if (Vehicles.Vehicle.LockVehicleState(car))
                    {
                        API.sendNotificationToPlayer(sender, "Le véhicule est vérrouillé."); return;
                    }
                    List <String> Actions          = new List <string>();
                    Items.Items.InventoryHolder ih = API.getEntityData(car, "InventoryHolder");
                    foreach (Items.Items.InventoryItem item in ih.Inventory)
                    {
                        Actions.Add(item.Details.Name + " :  " + item.Quantity);
                    }
                    API.triggerClientEvent(sender, "bettermenuManager", 144, "Inventaire Véhicule", "Selectionner l'item :               Poids : " + API.shared.getEntityData(car, "weight") + " / " + API.shared.getEntityData(car, "weight_max"), false, Actions);
                }

                // QUANTITE à Récupérer du coffre
                if ((int)arguments[0] == 144 && (int)arguments[1] == 0)
                {
                    if (Vehicles.Vehicle.LockVehicleState(car))
                    {
                        API.sendNotificationToPlayer(sender, "Le coffre du véhicule est vérrouillé."); return;
                    }
                    InventoryHolder ih   = API.getEntityData(car, "InventoryHolder");
                    var             item = ih.Inventory[(int)arguments[1]];
                    API.setEntityData(sender, "LastSelectedItem", item);
                    API.shared.triggerClientEvent(sender, "get_user_input", 145, "", 3, null);
                }
                if ((int)arguments[0] == 143 && (int)arguments[1] == 1)
                {
                    API.call("Vehicle", "GetVehicleInfo", sender);
                }

                if ((int)arguments[0] == 143 && (int)arguments[1] == 2)
                {
                    Jobs.Fourriere.CallFourriere(sender);
                }

                if ((int)arguments[0] == 143 && (int)arguments[1] == 3)
                {
                    API.call("Vehicle", "CrocheteVehicle", sender);
                }
            }
            else if (eventName == "menu_handler_user_input")
            {
                // VALIDATION SORTIR DU COFFRE
                if ((int)arguments[0] == 145)
                {
                    try
                    {
                        var item     = API.getEntityData(sender, "LastSelectedItem");
                        var reciever = API.getEntityData(sender, "NearbyList");
                        int qty      = Convert.ToInt32(arguments[1]);
                        Items.Items.InventoryHolder invplayer   = API.getEntityData(reciever, "InventoryHolder");
                        Items.Items.InventoryHolder invreciever = API.getEntityData(sender, "InventoryHolder");

                        int 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 récupéré " + qty.ToString() + " " + item.Details.Name + " du coffre du véhicule");
                                UpdatePlayerInfo(sender);
                                API.resetEntityData(sender, "LastSelectedItem");
                                API.resetEntityData(sender, "NearbyList");
                            }
                            else
                            {
                                API.sendNotificationToPlayer(sender, "Vous n'avez pas la place dans votre inventaire!");
                            }
                        }
                        else
                        {
                            API.sendNotificationToPlayer(sender, "Vous en avez pas autant sur vous");
                        }
                    }
                    catch (FormatException)
                    {
                        API.sendNotificationToPlayer(sender, "ERREUR!");
                    }
                }
            }
        }
        private void OnClientEventTrigger(Client sender, string eventName, object[] arguments)
        {
            if (eventName == "menu_handler_select_item")
            {
                if ((int)arguments[0] == 50)
                {
                    int ID = sender.getData("Housing_ID");
                    //sender.resetData("Housing_ID"); // A reset seulement quand la personne quitte l'appart
                    var HousingColshape = OutcolshapeList.Find(x => x.getData("Housing_ID") == ID);
                    int Place           = HousingColshape.getData("Housing_Place");
                    int Price           = HousingColshape.getData("Housing_Price");

                    /****************************************************************************/
                    /*                                  ACHETER                                 */
                    /****************************************************************************/

                    if ((int)arguments[1] == 0)
                    {
                        if (CheckNumberRentHousing(ID, Place))
                        {
                            if (GetHousePlayer(ID, sender.socialClubName).Rows.Count != 0)
                            {
                                API.sendNotificationToPlayer(sender, "Vous avez déjà une maison / appartement ici.");
                            }
                            else
                            {
                                if (Money.TakeBankMoney(sender, Price))
                                {
                                    AddHouseOwner(sender, ID, RandomHouseDimension());
                                    API.sendNotificationToPlayer(sender, "Vous avez acheté une maison / appartement pour la somme de $" + Price.ToString());
                                }
                                else
                                {
                                    API.sendNotificationToPlayer(sender, "Vous n'avez pas assez d'argent sur votre compte en banque.");
                                }
                            }
                        }
                        else
                        {
                            API.sendChatMessageToPlayer(sender, "Vous n'avez pas de maison / appartement de disponible ici.");
                        }
                    }
                    /****************************************************************************/
                    /*                                  VENDRE                                  */
                    /****************************************************************************/
                    else if ((int)arguments[1] == 1)
                    {
                        int SellPrice = CalculeSellHousePrice(Price);
                        if (GetHousePlayer(ID, sender.socialClubName).Rows.Count != 0)
                        {
                            SellHouseOwner(ID, sender.socialClubName);
                            Money.GiveMoney(sender, SellPrice);
                            API.sendNotificationToPlayer(sender, "Vous avez vendu une maison / appartement pour la somme de $" + SellPrice.ToString());
                        }
                        else
                        {
                            API.sendNotificationToPlayer(sender, "Vous n'avez pas de maison / appartement à vendre ici.");
                        }
                    }
                    else
                    {
                        /****************************************************************************/
                        /*                                  DEMANDE                                 */
                        /****************************************************************************/

                        Client HouseOwner = HouseOwnerList[(int)arguments[1] - 2];
                        if (HouseOwner == sender)
                        {
                            PutInMyHome(sender);
                        }
                        else
                        {
                            if (HouseOwner.hasData("InHouse") && HouseOwner.getData("InHouse") == ID)
                            {
                                HouseOwner.setData("Housing_Wait_Enter", sender.getSyncedData("Nom_Prenom"));
                                List <string> Actions = new List <string>();
                                Actions.Add("Ouvrir la porte");
                                Actions.Add("Refuser d'ouvrir");
                                API.triggerClientEvent(HouseOwner, "bettermenuManager", 51, "Immobilier", sender.getSyncedData("Nom_Prenom") + " Sonne à la porte", false, Actions);
                            }
                            else
                            {
                                API.sendNotificationToPlayer(sender, HouseOwner.getSyncedData("Nom_Prenom") + " n'est pas chez lui.");
                            }
                        }
                    }
                }
                /****************************************************************************/
                /*                                  RENTRER                                 */
                /****************************************************************************/
                else if ((int)arguments[0] == 51)
                {
                    string GetEnterClientName = sender.getData("Housing_Wait_Enter");
                    Client GetEnterClient     = EntityManager.GetClientName(GetEnterClientName);
                    int    ID = sender.getData("Housing_ID");
                    var    HousingColshape = OutcolshapeList.Find(x => x.getData("Housing_ID") == ID);


                    if ((int)arguments[1] == 0)
                    {
                        Vector3   IntPos = (Vector3)HousingColshape.getData("Housing_IntPos");
                        DataTable houseplayerinfotable = GetHousePlayer(ID, sender.socialClubName);
                        if (houseplayerinfotable.Rows.Count != 0)
                        {
                            foreach (DataRow row in houseplayerinfotable.Rows)
                            {
                                GetEnterClient.dimension = Convert.ToInt32(row["Dimension"]);
                                GetEnterClient.setData("Housing_Owner", sender.socialClubName);
                            }
                        }

                        GetEnterClient.position = IntPos;
                        GetEnterClient.setData("Housing_ID", ID);
                    }
                    else if ((int)arguments[1] == 1)
                    {
                        API.sendNotificationToPlayer(GetEnterClient, "Personne n'ouvre la porte.");
                    }
                }
                /****************************************************************************/
                /*                                  SORTIR                                  */
                /****************************************************************************/
                else if ((int)arguments[0] == 52)
                {
                    OnExitHouse(sender);
                }
                /****************************************************************************/
                /*                                  INVENTAIRE                              */
                /****************************************************************************/
                // OUVERTURE DU MENU
                else if ((int)arguments[0] == 53)
                {
                    OpenHouseInventory(sender);
                }
                // CHOIX DE LA QUANTITE
                else if ((int)arguments[0] == 54)
                {
                    InventoryHolder ih   = API.getEntityData(sender, "Home_InventoryHolder");
                    var             item = ih.Inventory[(int)arguments[1]];
                    API.setEntityData(sender, "LastSelectedItem", item);
                    API.shared.triggerClientEvent(sender, "get_user_input", 55, "", 3, null);
                }
            }
            else if (eventName == "menu_handler_user_input")
            {
                // COMFIRMATION
                if ((int)arguments[0] == 55)
                {
                    InventoryItem item = (InventoryItem)API.getEntityData(sender, "LastSelectedItem");
                    int           qty  = Convert.ToInt32(arguments[1]);
                    Items.Items.InventoryHolder invHome     = API.getEntityData(sender, "Home_InventoryHolder");
                    Items.Items.InventoryHolder invreciever = API.getEntityData(sender, "InventoryHolder");
                    API.consoleOutput(qty.ToString());
                    int itemplayerqty = item.Quantity;
                    if (qty <= itemplayerqty)
                    {
                        if (invreciever.CheckWeightInventory(item.Details, qty))
                        {
                            invHome.RemoveItemFromInventory(item.Details, qty);
                            invreciever.AddItemToInventory(item.Details, qty);
                            API.sendNotificationToPlayer(sender, "Vous avez récupéré " + qty.ToString() + " " + item.Details.Name + " de votre coffre.");
                            UpdatePlayerInfo(sender);

                            string OwnerHouseName = sender.getData("Housing_Owner"); // check à qui appartient l'appartement
                            int    ID             = sender.getData("Housing_ID");    // check de l'id de l'appartement
                            SaveHouseInventory(sender, ID, OwnerHouseName);

                            API.resetEntityData(sender, "LastSelectedItem");
                            API.resetEntityData(sender, "NearbyList");
                            API.resetEntityData(sender, "Home_InventoryHolder");
                        }
                        else
                        {
                            API.sendNotificationToPlayer(sender, "Vous n'avez pas la place dans votre inventaire!");
                        }
                    }
                    else
                    {
                        API.sendNotificationToPlayer(sender, "Vous en avez pas autant sur vous");
                    }
                }
            }
        }