1. So one user, actually 2 but we'll focus on one user, who has used my plugin "KillFeed" has reported the following, regarding the RPC Error: addui:
    Basically the plugin seems to kick everyone with the reason: RPC Error: addui
    Since RPC Error: addui doesn't really tell you anything specific and it only seems to happen after an hour or two, I'm really struggling to fix this.

    The user above also said that it does happen less often on version 1.6.0 than on version 1.6.1, though the only significant difference between those two is the following:

    « version 1.6.0 »
    Code:
    private static IEnumerator WaitForRequest(string shortname, string url)
                {
                    WWW www = new WWW(url);                yield return www;                string fileID = FileStorage.server.Store(www.bytes, FileStorage.Type.png, uint.MaxValue).ToString();                if (!fileIDs.ContainsKey(shortname))
                    {
                        fileIDs.Add(shortname, fileID);
                    }
                    else
                    {
                        fileIDs[shortname] = fileID;
                    }
                }
    « version 1.6.1 »
    Code:
    private static IEnumerator WaitForRequest(string shortname, string url)
                {
                    WWW www = new WWW(url);                yield return www;                if (string.IsNullOrEmpty(www.error))
                    {
                        string fileID = FileStorage.server.Store(www.bytes, FileStorage.Type.png, CommunityEntity.ServerInstance.net.ID).ToString();                    if (!fileIDs.ContainsKey(shortname))
                        {
                            fileIDs.Add(shortname, fileID);
                        }
                        else
                        {
                            fileIDs[shortname] = fileID;
                        }
                    }
                }
    I'm mainly referring to the third parameter that is passed into the FileStorage.server.Store(...) function

    So basically I don't know what the issue is, the problem described by the user never occurs on my local server, so I have a hard time reproducing anything. Furthermore, though this might be unrelated, I don't even know what I should pass into the third parameter of the FileStorage.server.Store(...) function.

    I know it's asking much that someone takes some time to look over my plugin, but if someone knows how to fix this and could tell me, I would be more than happy. :(

    « version 1.6.0 »
    http://oxidemod.org/plugins/kill-feed.1433/download?version=7516

    « version 1.6.0 »
    http://oxidemod.org/plugins/kill-feed.1433/download?version=7519
     
  2. Calytic

    Calytic Community Admin Community Mod

    An addui rpc error will happen if the JSON sent over the wire is not valid JSON. Try exporting the json and validating it using JSONLint - The JSON Validator.
     
  3. The JSON that is sent over the wire is valid according to the link you provided, so that can't be an issue, especially because it only happens after an hour or two and I yet have to experience that error myself.

    The only thing I can think of is that at some point shit get's fucked up and the JSON contains a component with a name that is already drawn and hence it throws the RPC Error: addui, but then again why would this only happen after an hour or two...
     
  4. Wulf

    Wulf Community Admin

    It may be valid JSON, but it may not meet the format that the Rust CUI wants.
     
  5. So here's the JSON template:

    Code:
    [
        {
            "name": "{0} feedEntry",
            "parent": "HUD",
            "fadeOut": {fadeOut value},
            "components": [
                                {
                                    "sprite": "assets/content/textures/generic/fulltransparent.tga",
                                    "type": "UnityEngine.UI.RawImage"
                                },
                                {
                                    "anchormin": "%%",
                                    "anchormax": "%%",
                                    "type": "RectTransform"
                                }
                            ]
        },
        {
            "name": "{0} initiator",
            "parent": "{0} feedEntry",
            "fadeOut": {fadeOut value},
            "components": [
                                {
                                    "color": "0.0 0.0 0.0 1.0",
                                    "distance": "1.0 1.0",
                                    "type": "UnityEngine.UI.Outline"
                                },
                                {
                                    "text": "{initiator}",
                                    "fontSize": {fontSize},
                                    "font": "{font}",
                                    "align": "MiddleLeft",
                                    "color": "{initiator color}",
                                    "fadeIn": {fadeIn value},
                                    "type": "UnityEngine.UI.Text"
                                },
                                {
                                    "type": "RectTransform"
                                }
                            ]
        },
        {
            "name": "{0} hitBone",
            "parent": "{0} feedEntry",
            "fadeOut": {fadeOut value},
            "components": [
                                {
                                    "color": "0.0 0.0 0.0 1.0",
                                    "distance": "1.0 1.0",
                                    "type": "UnityEngine.UI.Outline"
                                },
                                {
                                    "text": "{hitBone}",
                                    "fontSize": {fontSize},
                                    "font": "{font}",
                                    "align": "MiddleRight",
                                    "color": "1.0 1.0 0.0 1.0",
                                    "fadeIn": {fadeIn value},
                                    "type": "UnityEngine.UI.Text"
                                },
                                {
                                    "anchormin": "0.0 0.0",
                                    "anchormax": "{bone anchormax}",
                                    "type": "RectTransform"
                                }
                            ]
        },
        {
            "name": "{0} weapon",
            "parent": "{0} feedEntry",
            "fadeOut": {fadeOut value},
            "components": [
                                {
                                    "sprite": "assets/content/textures/generic/fulltransparent.tga",
                                    "png": "{weaponID}",
                                    "fadeIn": {fadeIn value},
                                    "type": "UnityEngine.UI.RawImage"
                                },
                                {
                                    "anchormin": "{weapon anchormin}",
                                    "anchormax": "{weapon anchormax}",
                                    "type": "RectTransform"
                                }
                            ]
        },
        {
            "name": "{0} distance",
            "parent": "{0} feedEntry",
            "fadeOut": {fadeOut value},
            "components": [
                                {
                                    "color": "0.0 0.0 0.0 1.0",
                                    "distance": "1.0 1.0",
                                    "type": "UnityEngine.UI.Outline"
                                },
                                {
                                    "text": "{distance}",
                                    "fontSize": {fontSize},
                                    "font": "{font}",
                                    "align": "MiddleLeft",
                                    "color": "1.0 1.0 0.0 1.0",
                                    "fadeIn": {fadeIn value},
                                    "type": "UnityEngine.UI.Text"
                                },
                                {
                                    "anchormin": "{distance anchormin}",
                                    "anchormax": "1.0 1.0",
                                    "type": "RectTransform"
                                }
                            ]
        },
        {
            "name": "{0} hitEntity",
            "parent": "{0} feedEntry",
            "fadeOut": {fadeOut value},
            "components": [
                                {
                                    "color": "0.0 0.0 0.0 1.0",
                                    "distance": "1.0 1.0",
                                    "type": "UnityEngine.UI.Outline"
                                },
                                {
                                    "text": "{hitEntity}",
                                    "fontSize": {fontSize},
                                    "font": "{font}",
                                    "align": "MiddleRight",
                                    "color": "{hitEntity color}",
                                    "fadeIn": {fadeIn value},
                                    "type": "UnityEngine.UI.Text"
                                },
                                {
                                    "type": "RectTransform"
                                }
                            ]
        }
    ]
    Obviously this wouldn't be a valid JSON but that's no big deal, because it's a template and things like {fadeOut value}, {fadeIn value}, {hitEntity}, etc. will all be replaced with their proper values and it does work. It never kicked me on my local server because of RPC Error: addui. But for some reason that user report that my plugin does throw that error after an hour or two.

    The process of replacing all those values above doesn't change over time, but apparently the resulting JSONs change over time. So either some special cases cause the JSON to become invalid or, well, I don't know.
     
    Last edited by a moderator: Nov 28, 2015
  6. Wulf

    Wulf Community Admin

    I don't know about that, I use the RustCui helper from Oxide.
     
  7. Okay I switched over to RustCui helper to create my template:
    Code:
    internal static string GetDefaultKillFeedEntry()
                {
                    CuiElementContainer container = new CuiElementContainer();                container.Add(new CuiElement
                    {
                        Name = "{0} feedEntry",
                        Parent = "HUD/Overlay",
                        FadeOut = fadeOut,
                        Components =
                        {
                            new CuiRawImageComponent
                            {
                                Sprite = "assets/content/textures/generic/fulltransparent.tga"
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = "%{anchormin}%",
                                AnchorMax = "%{anchormax}%"
                            }
                        }
                    });
                    container.Add(new CuiElement
                    {
                        Name = "{0} initiator",
                        Parent = "{0} feedEntry",
                        FadeOut = fadeOut,
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Text = "{initiator}",
                                Font = font,
                                FontSize = fontSize,
                                Align = TextAnchor.MiddleLeft,
                                Color = "{initiator color}",
                                FadeIn = fadeIn,
                            },
                            new CuiOutlineComponent
                            {
                                Distance = "1.0 1.0",
                                Color = "0.0 0.0 0.0 1.0"
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = "0.0 0.0",
                                AnchorMax = "1.0 1.0"
                            }
                        }
                    });
                    container.Add(new CuiElement
                    {
                        Name = "{0} hitBone",
                        Parent = "{0} feedEntry",
                        FadeOut = fadeOut,
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Text = "{hitBone}",
                                Font = font,
                                FontSize = fontSize,
                                Align = TextAnchor.MiddleRight,
                                Color = "1.0 1.0 0.0 1.0",
                                FadeIn = fadeIn,
                            },
                            new CuiOutlineComponent
                            {
                                Distance = "1.0 1.0",
                                Color = "0.0 0.0 0.0 1.0"
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = "0.0 0.0",
                                AnchorMax = 0.5f - iconHalfWidth + " 1.0"
                            }
                        }
                    });
                    container.Add(new CuiElement
                    {
                        Name = "{0} weapon",
                        Parent = "{0} feedEntry",
                        FadeOut = fadeOut,
                        Components =
                        {
                            new CuiRawImageComponent
                            {
                                Sprite = "assets/content/textures/generic/fulltransparent.tga",
                                Png = "{weaponID}",
                                FadeIn = fadeIn
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = 0.5f - iconHalfWidth + " " + (0.5f - iconHalfHeight),
                                AnchorMax = 0.5f + iconHalfWidth + " " + (0.5f + iconHalfHeight),
                            }
                        }
                    });
                    container.Add(new CuiElement
                    {
                        Name = "{0} distance",
                        Parent = "{0} feedEntry",
                        FadeOut = fadeOut,
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Text = "{distance}",
                                Font = font,
                                FontSize = fontSize,
                                Align = TextAnchor.MiddleLeft,
                                Color = "1.0 1.0 0.0 1.0",
                                FadeIn = fadeIn,
                            },
                            new CuiOutlineComponent
                            {
                                Distance = "1.0 1.0",
                                Color = "0.0 0.0 0.0 1.0"
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = 0.5f + iconHalfWidth + " 0.0",
                                AnchorMax = "1.0 1.0",
                            }
                        }
                    });
                    container.Add(new CuiElement
                    {
                        Name = "{0} hitEntity",
                        Parent = "{0} feedEntry",
                        FadeOut = fadeOut,
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Text = "{hitEntity}",
                                Font = font,
                                FontSize = fontSize,
                                Align = TextAnchor.MiddleRight,
                                Color = "{hitEntity color}",
                                FadeIn = fadeIn,
                            },
                            new CuiOutlineComponent
                            {
                                Distance = "1.0 1.0",
                                Color = "0.0 0.0 0.0 1.0"
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = "0.0 0.0",
                                AnchorMax = "1.0 1.0"
                            }
                        }
                    });
                    return container.ToJson();
                }
    Is there an easy way of manipulating a specific component contained in a CuiElementContainer, such as the CuiRectTransformComponent? Keeping a reference from the start isn't going to work in my case (i think?) because I want the user to define the number of containers (=entries).

    Edit: I'm still manipulating the JSON string to move each container (=entry) down. So it didn't actually solve my initial problem (i think?). Heck, I don't even know WTF the problem is exactly... :D
     
  8. The CuiHelper is not meant to generate the template for you. It should completely replace the usage of json. So in your case you havn't changed anything by using the helper.
    Rpc error sounds like an invalid value otherwise it wouldn't create an error at client side which disconnects the user.
     
  9. I'm aware that I didn't really change anything, but then again as far as I can see CuiHelper doesn't check if the values of each CuiElement are valid before it converts them to JSON and sends it to the server. So even if I would completely switch to CuiHelper I could still plug in wrong string values here and there that would result in a RPC Error: addui or am I missing something?
    [DOUBLEPOST=1448824166,1448816579][/DOUBLEPOST]Not sure if I should make a new thread for this or not, but why is the string reason provided by the Hook OnPlayerDisconnected(BasePlayer player, string reason) just saying "Disconnected" when a player gets disconnected because of RPC Error: addui? That's rather non-descriptive.
     
  10. Wulf

    Wulf Community Admin

    The reason is provided by either plugins or Rust's default. If it's just saying "Disconnected", then that's the reason Rust has setup.
     
  11. Hmm, the server console does show "... disconnecting: RPC Error: addui" if you get disconnected because of RPC Error: addui. So it does seem like the server knows the reason. Is there any way to check if a disconnect was caused by RPC Error: addui, then?
     
  12. Wulf

    Wulf Community Admin

    I'm not sure, probably not since the server is just sending the RPC and the client interprets it.
     
  13. I think the following function in the BasePlayer class handles the RPC Error: addui:
    Code:
    public void Kick(string reason)
        {
            if (!this.IsConnected())
            {
                return;
            }
            Net.sv.Kick(this.net.connection, reason);
        }
    Just a guess, but if it does, then maybe a hook for that function would be a nice!

    Thanks to you and the other users who answered my question, btw.
     
  14. the reason in your case is "RPC Error: addui" which you got from client...you could check the client logs for the full stacktrace to know what is going on...or log your json to verify what is wrong in the case someone disconnected...
    And after a short look at your plugin i'd recommend to call AddUI RPC with an json array instead of every single element you want to add...and yeah since you are creating your json string by hand there can go alot of stuff wrong...
     
  15. How would I go about calling AdddUI RPC with a JSON array? I'm kind of lost...