Jump to content
RAGE Multiplayer Community

Compiling errors when using UIMenuItem in a "complicated" structure


Recommended Posts

Hey all,

 

I need some help to find out how to workaround or fix my code, since there are compilation errors ("Missing assembly x"). - The error output is down below.

 

Here is my code:

public static void AddClothsToMenu(UIMenu menu, JArray array, int componentID, JArray ownedClothes)
        {
            foreach (JObject element in array)
            {
                int drawable = int.Parse(element["drawable"].ToString());
                int texture = int.Parse(element["texture"].ToString());
                int price = int.Parse(element["price"].ToString());
                string itemName = element["name"].ToString();
                string RLText = "";
                UIMenuItem item = new UIMenuItem(itemName);
                JObject currentObject = new JObject() { new JProperty("texture", texture), new JProperty("drawable", drawable) };
                if (componentID == -1)
                    currentObject.Add(new JProperty("componentId", element["cid"]));
                if (ownedClothes.Contains(currentObject))
                {
                    //item.SetRightBadge(UIMenuItem.BadgeStyle.Clothes);
                    RLText = "Gekauft";
                }
                else
                {
                    RLText = $"{price},00$";
                }
                item.SetRightLabel(RLText);
                
                item.Activated += (UIMenu sender, UIMenuItem senderItem) => {
                    RAGE.Elements.Player p = RAGE.Elements.Player.LocalPlayer;
                    bool canDress = true;

                    // If Cloth is not bought yet, charge the player the price of the cloth
                    if (!(/*senderItem.RightLabel*/RLText == "Gekauft")) // Wenn nicht gekauft
                    {
                        canDress = false;
                        if (p.GetSharedData("Cash") != null)
                        {
                            if (int.Parse(p.GetSharedData("Cash").ToString()) > price)
                            {
                                canDress = true;
                            }
                        }
                    }

                    if (canDress & p.GetSharedData("OwnedClothes") != null)
                    {
                        Events.CallRemote("cash_reduce", (float) price);
                        JObject obj = new JObject();
                        if (componentID >= 0)
                        {
                            obj.Add(new JProperty("componentId", componentID));
                        }
                        else if (componentID == -1)
                        {
                            obj.Add(new JProperty("componentId", element["cid"]));
                        }
                        obj.Add(new JProperty("drawable", element["drawable"]));
                        obj.Add(new JProperty("texture", element["texture"]));
                        obj.Add(new JProperty("save", true));
                        obj.Add(new JProperty("sync", true));
                        Events.CallRemote("set_synced_outfit", obj.ToString());

                        // Updating OwnedClothes database row (Updating owned clothes list)
                        JObject AllClothData = JObject.Parse(p.GetSharedData("OwnedClothes").ToString());
                        JArray currentComponentArray = (JArray) AllClothData[componentID.ToString()];
                        JObject newItem = new JObject();
                        newItem.Add(new JProperty("drawable", element["drawable"]));
                        newItem.Add(new JProperty("texture", element["texture"]));
                        if (componentID == -1)
                            newItem.Add(new JProperty("componentId", element["cid"]));
                        currentComponentArray.Add(newItem);
                        AllClothData[componentID.ToString()] = currentComponentArray;
                        Events.CallRemote("UPDATE_OwnedClothes", AllClothData);

                        // Updating Clothes database row (Updating currently wearing clothes to be loaded on new logon)
                        if (componentID >= 0)
                        {
                            JObject currentClothes = JObject.Parse(p.GetSharedData("Clothes").ToString());

                            /* COMMENTED OUT DUE TO HARD TO READ */
                            //currentClothes[componentID] = new JObject() { new JProperty("drawable",element["drawable"]), new JProperty("texture", element["texture"]) };
                            
                            // Our current Component, that is gonna be changed
                            JObject currentComponent = (JObject)currentClothes[componentID];
                            currentComponent["drawable"] = element["drawable"];
                            currentComponent["texture"] = element["texture"];
                            currentClothes[componentID] = currentComponent;

                            Events.CallRemote("UPDATE_Clothes", currentClothes);
                        }
                        else
                        {
                            JObject currentClothes = JObject.Parse(p.GetSharedData("Clothes").ToString());

                            /* COMMENTED OUT DUE TO HARD TO READ */
                            //currentClothes[componentID] = new JObject() { new JProperty("drawable",element["drawable"]), new JProperty("texture", element["texture"]) };
                            
                            // Our current Component, that is gonna be changed
                            JObject currentComponent = (JObject)currentClothes[element["cid"]];
                            currentComponent["drawable"] = element["drawable"];
                            currentComponent["texture"] = element["texture"];
                            currentClothes[element["cid"]] = currentComponent;

                            Events.CallRemote("UPDATE_Clothes", currentClothes);
                        }
                    }
                    else
                    {
                        string message = "~r~Du hast nicht genug Geld dabei!";
                        if (p.GetSharedData("Cash") != null)
                        {
                            int cash = int.Parse(p.GetSharedData("Cash").ToString());
                            message += $"\nDir fehlen ~y~{(price - cash)},00$";
                        }
                        SendNotification(message);
                    }
                };
                menu.AddItem(item);
            }
        }

 

The errors started to occur when the Activated event got complicated.

 

The compilation errors:

C#: compiling scripts..

CS0012: Der Typ "ITypedList" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "System.ComponentModel.TypeConverter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" hinzu.
       -> D:\Programme\RageMP\client_resources\185.239.238.137_22005\cs_packages\Helper.cs:29

CS0012: Der Typ "IBindingList" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "System.ComponentModel.TypeConverter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" hinzu.
       -> D:\Programme\RageMP\client_resources\185.239.238.137_22005\cs_packages\Helper.cs:29

CS0012: Der Typ "INotifyCollectionChanged" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "System.ObjectModel, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" hinzu.
       -> D:\Programme\RageMP\client_resources\185.239.238.137_22005\cs_packages\Helper.cs:29

CS0012: Der Typ "INotifyPropertyChanged" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "System.ObjectModel, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" hinzu.
       -> D:\Programme\RageMP\client_resources\185.239.238.137_22005\cs_packages\Helper.cs:29

CS0012: Der Typ "ICustomTypeDescriptor" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "System.ComponentModel.TypeConverter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" hinzu.
       -> D:\Programme\RageMP\client_resources\185.239.238.137_22005\cs_packages\Helper.cs:29

CS0012: Der Typ "INotifyPropertyChanging" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "System.ObjectModel, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" hinzu.
       -> D:\Programme\RageMP\client_resources\185.239.238.137_22005\cs_packages\Helper.cs:29

TIP: Line 29 is the declaration - UIMenuItem item = new UIMenuItem(itemName);

Please help me as I can't continue to develop on this system for now, I tried a lot. 

Thanks in advance!

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...