UO-Orion

Member
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
I know the VIP access level is not really a thing anymore, which is exactly why I want to use it as a "reward" for certain players in the game so that they can have certain special perks. I can easily go into [props on a character and change the account AccessLevel to VIP, however that only changes it for that character, not the whole account. Interestingly, the Account List account information screen shows Player as the Access Level, but if you view the Client List, it shows VIP as the Access Level (if the player is on the char that you manually adjusted it for)

SO, what I've done is modified AdminGump.cs to add in a button for VIP when you click Change Access Level from the account information screen. I bumped the other buttons down and gave it a button ID of 5, 99 since it appeared that most other values were taken.
AdminGump.cs:
case AdminGumpPage.AccountDetails_ChangeAccess:
                    {
                        Account a = state as Account;

                        if (a == null)
                            break;

                        this.AddHtml(10, 125, 400, 20, this.Color(this.Center("Change Access Level"), LabelColor32), false, false);

                        this.AddLabel(20, 150, LabelHue, "Username:");
                        this.AddLabel(200, 150, LabelHue, a.Username);

                        this.AddLabel(20, 170, LabelHue, "Current Level:");
                        this.AddLabel(200, 170, LabelHue, FormatAccessLevel(a.AccessLevel));

                        this.AddButtonLabeled(20, 200, this.GetButtonID(5, 20), "Player");
                        this.AddButtonLabeled(20, 220, this.GetButtonID(5, 99), "VIP");
                        this.AddButtonLabeled(20, 240, this.GetButtonID(5, 21), "Counselor");
                        this.AddButtonLabeled(20, 260, this.GetButtonID(5, 22), "Game Master");
                        this.AddButtonLabeled(20, 280, this.GetButtonID(5, 23), "Seer");

                        if (from.AccessLevel > AccessLevel.Administrator)
                        {
                            this.AddButtonLabeled(20, 300, this.GetButtonID(5, 24), "Administrator");

                            if (from.AccessLevel > AccessLevel.Developer)
                            {
                                this.AddButtonLabeled(20, 320, this.GetButtonID(5, 33), "Developer");

                                if (from.AccessLevel >= AccessLevel.Owner)
                                    this.AddButtonLabeled(20, 340, this.GetButtonID(5, 34), "Owner");
                            }
                        }

                        goto case AdminGumpPage.AccountDetails;
                    }

Now I just needed to figure out how to make the button actually DO something (this is my first time playing around with gumps). I believe that in the OnResponse method, there's a gigantic switch/case block with the code below. It appeared to me that the case values were the button ID index values perhaps? so I added my 99 index and added the code for newLevel=AccessLevel.VIP. However, this doesn't appear to do anything. After a restart, it compiled fine, but when you click the VIP button on the Change Access Level screen, it just makes the Admin gump disappear so my guess is something "bad" is happening.

AdminGump.cs:
case 20: // Change access level
                            case 21:
                            case 22:
                            case 23:
                            case 24:
                                {
                                    Account a = this.m_State as Account;

                                    if (a == null)
                                        break;

                                    AccessLevel newLevel;

                                    switch ( index )
                                    {
                                        default:
                                        case 20:
                                            newLevel = AccessLevel.Player;
                                            break;
                                        
                                        case 21:
                                            newLevel = AccessLevel.Counselor;
                                            break;
                                        case 22:
                                            newLevel = AccessLevel.GameMaster;
                                            break;
                                        case 23:
                                            newLevel = AccessLevel.Seer;
                                            break;
                                        case 24:
                                            newLevel = AccessLevel.Administrator;
                                            break;
                                        case 33:
                                            newLevel = AccessLevel.Developer;
                                            break;
                                        case 34:
                                            newLevel = AccessLevel.Owner;
                                            break;
                                        case 99:
                                            newLevel = AccessLevel.VIP;
                                            break;
                                    }

                                    if (newLevel < from.AccessLevel || from.AccessLevel == AccessLevel.Owner)
                                    {
                                        a.AccessLevel = newLevel;

                                        CommandLogging.WriteLine(from, "{0} {1} changing access level of account {2} to {3}", from.AccessLevel, CommandLogging.Format(from), a.Username, a.AccessLevel);
                                        from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, "The access level has been changed.", this.m_State));
                                    }

                                    break;
                                }

Any and all help would be greatly appreciated! Thanks!
Well...I managed to figure it out!

In that second part, where case 20 (through case 24) all drop down into a subroutine, you need to scroll down to the end of that section where you get to case 36 (at least as of right now) that related to the //Clear login addresses comment. I added:

AdminGump.cs:
                            case 36: // Clear login addresses
                                {
                                    Account a = this.m_State as Account;

                                    if (a == null)
                                        break;

                                    IPAddress[] ips = a.LoginIPs;

                                    if (ips.Length == 0)
                                        from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, "This account has not yet been accessed.", this.m_State));
                                    else
                                        from.SendGump(new WarningGump(1060635, 30720, String.Format("You are about to clear the address list for account {0} containing {1} {2}. Do you wish to continue?", a, ips.Length, (ips.Length == 1) ? "entry" : "entries"), 0xFFC000, 420, 280, new WarningGumpCallback(RemoveLoginIPs_Callback), a));

                                    break;
                                }
                            case 99: //VIP
                                goto case 20;
                            default:
                                {
                                    index -= 50;

                                    Account a = this.m_State as Account;

                                    if (a != null && index >= 0 && index < a.Length)
                                    {
                                        Mobile m = a[index];

                                        if (m != null)
                                            from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, null, m));
                                    }
                                    else
                                    {
                                        index -= 6;

                                        if (this.m_List != null && index >= 0 && index < this.m_List.Count)
                                        {
                                            if (this.m_List[index] is Account)
                                                from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, null, this.m_List[index]));
                                            else if (this.m_List[index] is DictionaryEntry)
                                                from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, (ArrayList)(((DictionaryEntry)this.m_List[index]).Value), null, new ArrayList()));
                                        }
                                    }

                                    break;
                                }
 
Last edited:
You are correct in thinking button reply = case #

You overthought the layout of the switch, you only need to add the case equal to button reply, so if there is a case # not being used, you can use it, so in this situation, 25 is the first empty, not 99!

remove
Code:
                   case 99: //VIP
                   goto case 20;

change the button reply to 25

use case 25
Code:
                                        case 24:
                                            newLevel = AccessLevel.Administrator;
                                            break;
                                        case 25:
                                            newLevel = AccessLevel.VIP;
                                            break;


If this doesn't fix it, then we need to look into the method that follows the access level setting, it is where the access level is applied and gump recall is handled!

Code:
                                    if (newLevel < from.AccessLevel || from.AccessLevel == AccessLevel.Owner)
                                    {
                                        a.AccessLevel = newLevel;

                                        CommandLogging.WriteLine(from, "{0} {1} changing access level of account {2} to {3}", from.AccessLevel, CommandLogging.Format(from), a.Username, a.AccessLevel);
                                        from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, "The access level has been changed.", this.m_State));
                                    }
 
I did figure it out (it merged my post above so my "Fix" starts where I say "Well...I managed to figure it out"). 36 was actually the highest case, but I made it 99 since it was custom code so that it'll make it easier to merge with future updates to ServUO. I appreciate the help though!
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back