Sign in to follow this  
Faui

Clothes Support

Recommended Posts

Hello

I have following Code:

[RemoteEvent("clothesItemSelected")]
        public void ClothesItemSelectedEvent(Client player, int clothesId, int type, int slot)
        {
            int businessId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_BUSINESS_ENTERED);
            int sex = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_SEX);
            int products = GetClothesProductsPrice(clothesId, sex, type, slot);
            BusinessModel business = GetBusinessById(businessId);
            int price = (int)Math.Round(products * business.multiplier);

            // We check whether the player has enough money
            int playerMoney = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_MONEY);

            if (playerMoney >= price)
            {
                int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID);

                // Substracting paid money
                NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_MONEY, playerMoney - price);

                // We substract the product and add funds to the business
                if (business.owner != String.Empty)
                {
                    business.funds += price;
                    business.products -= products;

                    Task.Factory.StartNew(() => {
                        // Update the business
                        Database.UpdateBusiness(business);
                    });
                }

                // Undress previous clothes
                Globals.UndressClothes(playerId, type, slot);

                // We make the new clothes model
                ClothesModel clothesModel = new ClothesModel();
                clothesModel.player = playerId;
                clothesModel.type = type;
                clothesModel.slot = slot;
                clothesModel.drawable = clothesId;
                clothesModel.dressed = true;

                Task.Factory.StartNew(() => {
                    // Storing the clothes into database
                    clothesModel.id = Database.AddClothes(clothesModel);
                    Globals.clothesList.Add(clothesModel);

                    // Confirmation message sent to the player
                    String purchaseMessage = String.Format(Messages.INF_BUSINESS_ITEM_PURCHASED, price);
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + purchaseMessage);
                });
            }
            else
            {
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ENOUGH_MONEY);
            }
        }

---------------------------------

How is the best way to call this event clientside - can someone post me the right mp.trigger code?

Thanks

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.