Lena80

Citizen
ServUO Version
Publish Unknown
Ultima Expansion
None
Where is this handled? my friend and i were playing with Names and NameMod we end up with names such as "" (no name at all) both characters deleted on login and some error in console

saying WriteAsciiFixed null or something like that

we are using Runuo 2.2
 
Last edited:

Thagoras

Citizen
This is going to sound a bit odd....but did they actually delete or are you simply not seeing them on the login screen because they don't have a name? This isn't your owner account is it? Login with the account with the highest accesslevel and [global interface where playermobile. The mobiles might still exist on the internal map. If so, you can access their props and give them a proper name and login.
Otherwise, I'm still looking around for what might have caused them to delete.
 

Lena80

Citizen
HELLO, the character creation screen shows up, so they are deleted i think, im not on my computer right now, iw ill try what you said, later, thanks for your help
 

Lena80

Citizen
This is going to sound a bit odd....but did they actually delete or are you simply not seeing them on the login screen because they don't have a name? This isn't your owner account is it? Login with the account with the highest accesslevel and [global interface where playermobile. The mobiles might still exist on the internal map. If so, you can access their props and give them a proper name and login.
Otherwise, I'm still looking around for what might have caused them to delete.
Its the owner account wich gets deleted, after a world save + server restart whats the reason?
 

Thagoras

Citizen
Well, I was able to get my RunUO 2.1 shard to do what yours did (as near as I can imagine from your description). I messed around with both the name and namemod. It was with my owner account. Eventually changed them both to null and logged out. That character disappeared from the character select screen. I then logged in with another character of that account and used the command [global interface where playermobile. Saw a mobile on the list with no name and went to the properties tab and gave it a proper name. Logged out and when I got to the character select screen, the other character was back.
AccessLevel shouldn't make a huge difference. As long as you're GameMaster or above, you should have access to name changes.
I don't know how messing around with name and namemod would cause the system to delete the character. There's nothing in the code to do that. I mean it could be a glitch (and I am still looking for a reason for this).
 

Lena80

Citizen
Seems like a glitch in the Core ?
You are right characters have null name, ''Seee'' is the one i had to create, did the same thing you did, gave the name back and could log in again, very weird

owneracc.png
tried to add the next code onlogin method inside PlayerMobile.cs, it does nothing

C#:
if (from.Name == null)
                        from.Name = "?";
                    else if (from.RawName == null)
                        from.Name = "?";


Inside packet.cs in the core the word WriteAsciiFixed appears around 37 times, inside CharacterList method also inside AccountLoginAck

Since it throws an error on console (check post #6) looks like this is what brings the issues m_Stream.WriteAsciiFixed( si.Name, 32 );
 
Last edited:

Thagoras

Citizen
I think for the OnLogin to activate, the character needs to actually login. I'm looking for something in the character selection gump that would check the characters associated with the account. That might be where to have the name check.
 

GoldDraco13

Squire
try this script, it should find and mark the players with the name Bad Player #

use when your logged in by typing the command [MarkPlayers true
Code:
using System.Collections.Generic;
using Server.Commands;
using Server.Mobiles;

namespace Server
{
    class MarkPlayers
    {
        public static void Initialize()
        {
            CommandSystem.Register("MarkPlayers", AccessLevel.Administrator, new CommandEventHandler(Fix_OnCommand));
        }

        [Usage("MarkPlayers <Command>")]
        [Description("Mark Players Command")]
        private static void Fix_OnCommand(CommandEventArgs e)
        {
            if (e.Arguments.Length < 1)
            {
                e.Mobile.SendMessage(32, "Usage: MarkPlayers <Command>");
                return;
            }

            if (e.Arguments.Length > 0)
            {
                string command = e.Arguments[0].ToLower();

                if (command.Equals("true"))
                {
                    List<PlayerMobile> badPlayerList = new List<PlayerMobile>();

                    foreach (var mobile in World.Mobiles.Values)
                    {
                        if (mobile is PlayerMobile player)
                        {
                            if (player.Name == null)
                            {
                                badPlayerList.Add(player);
                            }
                        }
                    }

                    if (badPlayerList.Count > 0)
                    {
                        for (int i = 0; i < badPlayerList.Count; i++)
                        {
                            badPlayerList[i].Name = $"Bad Player{i}";
                        }
                    }

                    e.Mobile.SendMessage($"Marked {badPlayerList.Count} null players!");
                }
                else
                {
                    e.Mobile.SendMessage(32, "Usage: MarkPlayers <Command>");
                }
            }
        }
    }
}
 

Lena80

Citizen
thanks for your help, it crash, null reference, line 36
if (pm.Name == null):
if (pm.Name == null)

, i had to modify few lines because it was giving me errors
C#:
  List<PlayerMobile> badPlayerList = new List<PlayerMobile>();
                     foreach (var mobile in World.Mobiles.Values)
                      {
                           PlayerMobile pm = mobile as PlayerMobile;
            
                            if (pm.Name == null)  //Line 36
                            {
                                badPlayerList.Add(pm);
                            }
                        }


so i run the command, players are back in the list, hmm at least thats something, but yeah characters still glitched, i did a worldsave, restarted and the problem was back again

1642377601972.png

im far from an expert, but i think the issue is in the packets like i said in previous posts
 
Last edited:

GoldDraco13

Squire
Ah, my bad, I should have looked closer, your on a older server!

casting to a pm is fine as long as the mobile is a playermobile, the crash you received was because when a basecreature comes up or a vendor etc etc, it'll cast them to pm and then the crash as I suspect there is a mobile without a Name field! You need to filter out and make sure you are casting the right objects to there type, ie, casting a list of int's to a int good, casting a mixed list of string's and int's to a int, bad, as the int's will work but the string's will throw a exception! I hope that helps for the error in the casting edit!

Anyways, if this is just your test shard and your admin account, I would just delete the saves folder and start a fresh! Because even if you get the names back, chances are there were other issues caused from the change or the attempts to fix it!
Code:
if (mobile is PlayerMobile) //filter out for playermobiles only before cast
{
          PlayerMobile pm = mobile as PlayerMobile;
            
                            if (pm.Name == null)  //Line 36
                            {
                                badPlayerList.Add(pm);
                            }
}
 
Last edited:

Lena80

Citizen
maybe the only work around is to use some kind of persistance just like disguise kit? because namemod seems to end up bugged
 

GoldDraco13

Squire
My understanding of the Mods for characters are that they are to be used for temp effects to the character, to change stats/name etc etc temporarily while still retaining the actual values in the main fields! Otherwise it would always be a issue of retaining the field, and holding its value elsewhere until the value is needed to go back to!

My advice, never change the main fields, use the mods for temp changes that revert back to original values! I've never set them to "" or null so I don't think I know off hand if that could be a potential fix as the fields should be protected from bad values being passed!
I was curious and decided to take a look at Incognito.cs (a fifth level spell) it temp changes the character name and such to disguise them, as expected we see the NameMod being used, no direct changing of Name.

Here we set random name for player while incognito,
Code:
Caster.NameMod = Caster.Female ? NameList.RandomName("female") : NameList.RandomName("male");
side note : this code can be simplified,
Code:
Caster.NameMod =  NameList.RandomName(Caster.Female ? "female" : "male");
And if you still don't understand the ?, it means if true do this ( or : ) do that if false
here is a long form of writing this same code,
Code:
if (Caster.Female == true)
{
     Caster.NameMod = NameList.RandomName("female");
}
else
{
     Caster.NameMod = NameList.RandomName("male");
}

Then once the timer(spell) ends we revert it back by nulling out the mod.
Code:
m_Owner.NameMod = null;

So without digging further I can tell from looking at this, the NameMod when set to anything but null, overrides the Name Field.

Seeing this I would add the following line to the script I provided above to clear the NameMod as well as setting the Name!
Code:
                    if (badPlayerList.Count > 0)
                    {
                        for (int i = 0; i < badPlayerList.Count; i++)
                        {
                            badPlayerList[i].Name = "Bad Player" + i;
                            badPlayerList[i].NameMod = null; //Add this line to also reset the NameMod to default value!
                        }
                    }
Another side note for anyone that runs into a string using $, if you get a error, it is because you are not using the latest c# code, $ was added to the string for us to do inline values in the string, so if you have int VALUE = 5; string TEST= $"some text = {VALUE}"; the output would be, some text = 5. But remove the $ and the output will be, some text = {VALUE} .... so make sure when fixing these strings if they are issues due to the coding version, that you unpack the string to an older format, like string TEST = "some text = " + VALUE; or use string format. But don't overlook the value being past as it could effect the result you expect! I convert the Bad Payer string above for you as I saw that you overlooked the importance of the $. Which caused the players all getting the same name Bad Player{i}, when they should be Bad Player0, Bad Player1, Bad Player 2 and Bad Player3.
 
Last edited:

GoldDraco13

Squire
When it comes to the mod being saved, it saves by default and expects the system that was taking care of the revert would be started again after the world restarted and continue the check to revert the name, I think the issue is when the NameMod is set without a means to revert it, in coding, opening the door is only half the battle, making sure you close the door is usually where issues arise, hopefully my dumb analogy helps clear that up!

As for not saving a NameMod, by doing a blanket [DO Not Save NameMod] will most likely mess up all the systems that rely on the NameMod to persist! So the correct answer would be, if your going to use NameMod, make sure you have code to handle the NameMod Revert, either on a timer, event or trigger, this can all be done without modding the core methods.

My Rule About Modding,
I have tried over the years to program as best as I can without changing/adding/taking away from the base distro server!