Results 1 to 3 of 3
  1. #1
    deavis's Avatar
    Join Date
    Sep 2012
    Gender
    male
    Posts
    11
    Reputation
    10
    Thanks
    59

    Question Question regarding IDs/names and editing them

    Hi all,

    I was wondering if you have any better solution other than the one I'm currently using for comparing IDs to names.

    I used to code in C# long time ago, and coming back to it from JS is rather strange for me, i have following code for comparing names with it's actual ID
    Code:
                    List<dynamic> list = new List<dynamic>();
                    foreach (System.Reflection.FieldInfo prop in typeof(NPCID).GetFields()) {
                        if (prop.Name.Contains(parameter)) {
                            dynamic expando = new System.Dynamic.ExpandoObject();
                            expando.name = prop.Name;
                            expando.id = prop.GetValue(prop);
                            list.Add(expando);
                        }
                    }
                    if(lis*****unt() > 1) { 
                        Main.NewText("Found many monsters under that name, could not spawn.");
                        foreach (var i in list) {
                            Main.NewText(string.Format("{0}: {1}", i.id, i.name));
                        }
                    } else if ( lis*****unt() == 1){
                        NPC.NewNPC((int)player.position.X, (int)player.position.Y, list[0].id);
                        Main.NewText(string.Format("Successfully spawned npc"));
                    }
    Second question I have - If i remember correctly, there was an option in old terraria versions to spawn NPCs client side on the server, so everybody could see & attack them, but now if i spawn anything it dissappears. Same goes for item editing, when i drop my custom edited item, eg. i set sword's damage to 1000, the item goes back to it's original state. I assume it's because these items have a function SetDefaults set when it's picked up, but not sure.

    Third question - Didn't actually test that, but when i want to edit my items, to get the actual item held, the function is Main.player[Main.myPlayer].HeldItem. Is it possible to set Main.myPlayer to other player ID so i can view/edit their items as well? Is it possible from the client side or do I need to edit the server and add custom commands?

  2. #2
    DARTH WANKSTAIN's Avatar
    Join Date
    May 2019
    Gender
    male
    Posts
    42
    Reputation
    10
    Thanks
    210
    Quote Originally Posted by deavis View Post
    Hi all,

    I was wondering if you have any better solution other than the one I'm currently using for comparing IDs to names.

    I used to code in C# long time ago, and coming back to it from JS is rather strange for me, i have following code for comparing names with it's actual ID
    Code:
                    List<dynamic> list = new List<dynamic>();
                    foreach (System.Reflection.FieldInfo prop in typeof(NPCID).GetFields()) {
                        if (prop.Name.Contains(parameter)) {
                            dynamic expando = new System.Dynamic.ExpandoObject();
                            expando.name = prop.Name;
                            expando.id = prop.GetValue(prop);
                            list.Add(expando);
                        }
                    }
                    if(lis*****unt() > 1) { 
                        Main.NewText("Found many monsters under that name, could not spawn.");
                        foreach (var i in list) {
                            Main.NewText(string.Format("{0}: {1}", i.id, i.name));
                        }
                    } else if ( lis*****unt() == 1){
                        NPC.NewNPC((int)player.position.X, (int)player.position.Y, list[0].id);
                        Main.NewText(string.Format("Successfully spawned npc"));
                    }
    Second question I have - If i remember correctly, there was an option in old terraria versions to spawn NPCs client side on the server, so everybody could see & attack them, but now if i spawn anything it dissappears. Same goes for item editing, when i drop my custom edited item, eg. i set sword's damage to 1000, the item goes back to it's original state. I assume it's because these items have a function SetDefaults set when it's picked up, but not sure.

    Third question - Didn't actually test that, but when i want to edit my items, to get the actual item held, the function is Main.player[Main.myPlayer].HeldItem. Is it possible to set Main.myPlayer to other player ID so i can view/edit their items as well? Is it possible from the client side or do I need to edit the server and add custom commands?
    Main.player has every player object, loop through those to edit their items, but note it has no affect for them, only you can see it.
    Spawning client sided npcs is most likely still a thing, but you can't make other people see them unless you're smart with it, like spawning beehive projectiles to spawn bees.

  3. #3
    fozgod's Avatar
    Join Date
    Oct 2018
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    My Mood
    Angelic
    Quote Originally Posted by deavis View Post
    Hi all,

    I was wondering if you have any better solution other than the one I'm currently using for comparing IDs to names.

    I used to code in C# long time ago, and coming back to it from JS is rather strange for me, i have following code for comparing names with it's actual ID
    Code:
                    List<dynamic> list = new List<dynamic>();
                    foreach (System.Reflection.FieldInfo prop in typeof(NPCID).GetFields()) {
                        if (prop.Name.Contains(parameter)) {
                            dynamic expando = new System.Dynamic.ExpandoObject();
                            expando.name = prop.Name;
                            expando.id = prop.GetValue(prop);
                            list.Add(expando);
                        }
                    }
                    if(lis*****unt() > 1) { 
                        Main.NewText("Found many monsters under that name, could not spawn.");
                        foreach (var i in list) {
                            Main.NewText(string.Format("{0}: {1}", i.id, i.name));
                        }
                    } else if ( lis*****unt() == 1){
                        NPC.NewNPC((int)player.position.X, (int)player.position.Y, list[0].id);
                        Main.NewText(string.Format("Successfully spawned npc"));
                    }
    Second question I have - If i remember correctly, there was an option in old terraria versions to spawn NPCs client side on the server, so everybody could see & attack them, but now if i spawn anything it dissappears. Same goes for item editing, when i drop my custom edited item, eg. i set sword's damage to 1000, the item goes back to it's original state. I assume it's because these items have a function SetDefaults set when it's picked up, but not sure.

    Third question - Didn't actually test that, but when i want to edit my items, to get the actual item held, the function is Main.player[Main.myPlayer].HeldItem. Is it possible to set Main.myPlayer to other player ID so i can view/edit their items as well? Is it possible from the client side or do I need to edit the server and add custom commands?
    To answer the custom item spawning thing ur trying to do it is possible because the server can spawn custom items but if ur trying to do it from ur client to the server for other players its a no go cause the server will check to see if ur host or just a client if ur a client it returns also btw if u sync the item to the server it will like update it like 7 times it seems like cause i can spawn a item with a invalid prefix but the server will shuffle through prefixes till its valid

Similar Threads

  1. [Help Request] looking for some assistance in regards to assets and updating them
    By willfuttbuck in forum Realm of the Mad God Help & Requests
    Replies: 6
    Last Post: 12-01-2017, 04:43 AM
  2. For questions regarding social engineering and refunding
    By Psychotic in forum Marketplace Talk
    Replies: 0
    Last Post: 02-29-2016, 09:31 PM
  3. A few questions regarding MW2 Liberation and VAC
    By vanFail in forum Call of Duty Modern Warfare 2 Help
    Replies: 6
    Last Post: 04-06-2014, 08:27 AM
  4. [Help Request] Some questions regarding RE's and menus in general
    By jeppeake in forum DayZ Help & Requests
    Replies: 7
    Last Post: 04-04-2013, 06:31 AM
  5. Replies: 4
    Last Post: 07-30-2010, 04:18 PM