Jump to content
RAGE Multiplayer Community

Clothes Support


Faui
 Share

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...