RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Complete Messaging System

Status
Not open for further replies.

smoke42

Wanderer
Fury said:
[code:1]if ( pm.AccessLevel == AccessLevel.Player )
pm.Onshow = true;
else
pm.Onshow = false;[/code:1]

this way when people log in players will be visible staff will be hidden by default and you wont have to save anything.

So is that in addition to all of the other changes to playermoble.cs?
 

Fury

Wanderer
you would add that to onlogin instead of serializing/deserializing Onshow... the rest you have to add still
 

Dian

Sorceror
I thought I would share my small mod to this wonderfull script here:

PlayerMobile.cs
[code:1]public bool Onshow;
public bool LocShow;[/code:1]
[code:1]private static void OnLogin( LoginEventArgs e )
{

if( pm.AccessLevel == AccessLevel.Player )
pm.Onshow = true;
pm.LocShow = false;[/code:1]

Adition of the bool LocShow along with the OnShow.

MsgGump.cs

[code:1]using System;
using System.Collections;
using Server.Network;
using Server.Mobiles;

namespace Server.Gumps
{
public class MsgGump : Gump
{
public static void Initialize()
{
EventSink.Speech += new SpeechEventHandler( EventSink_Speech );
}

private static void EventSink_Speech( SpeechEventArgs args )
{

if ( !args.Handled && Insensitive.Equals( args.Speech, "online" )
|| Insensitive.Equals( args.Speech, "players" ) )
{
args.Mobile.CloseGump( typeof(MsgGump) );
args.Mobile.CloseGump( typeof(MsgClientGump) );
args.Mobile.SendGump( new MsgGump( args.Mobile ) );

args.Handled = true;
}
}

public static bool OldStyle = PropsConfig.OldStyle;

public const int GumpOffsetX = PropsConfig.GumpOffsetX;
public const int GumpOffsetY = PropsConfig.GumpOffsetY;

public const int TextHue = PropsConfig.TextHue;
public const int TextOffsetX = PropsConfig.TextOffsetX;

public const int OffsetGumpID = PropsConfig.OffsetGumpID;
public const int HeaderGumpID = PropsConfig.HeaderGumpID;
public const int EntryGumpID = PropsConfig.EntryGumpID;
public const int BackGumpID = PropsConfig.BackGumpID;
public const int SetGumpID = PropsConfig.SetGumpID;

public const int SetWidth = PropsConfig.SetWidth;
public const int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public const int SetButtonID1 = PropsConfig.SetButtonID1;
public const int SetButtonID2 = PropsConfig.SetButtonID2;

public const int PrevWidth = PropsConfig.PrevWidth;
public const int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public const int PrevButtonID1 = PropsConfig.PrevButtonID1;
public const int PrevButtonID2 = PropsConfig.PrevButtonID2;

public const int NextWidth = PropsConfig.NextWidth;
public const int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public const int NextButtonID1 = PropsConfig.NextButtonID1;
public const int NextButtonID2 = PropsConfig.NextButtonID2;

public const int OffsetSize = PropsConfig.OffsetSize;

public const int EntryHeight = PropsConfig.EntryHeight;
public const int BorderSize = PropsConfig.BorderSize;

private static bool PrevLabel = false, NextLabel = false;

private const int PrevLabelOffsetX = PrevWidth + 1;
private const int PrevLabelOffsetY = 0;

private const int NextLabelOffsetX = -29;
private const int NextLabelOffsetY = 0;

private const int EntryWidth = 350;
private const int EntryCount = 15;

private const int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private const int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));

private const int BackWidth = BorderSize + TotalWidth + BorderSize;
private const int BackHeight = BorderSize + TotalHeight + BorderSize;

private Mobile m_Owner;
private PlayerMobile m;
private ArrayList m_Mobiles;
private int m_Page;

private class InternalComparer : IComparer
{
public static readonly IComparer Instance = new InternalComparer();

public InternalComparer()
{
}

public int Compare( object x, object y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;

Mobile a = x as Mobile;
Mobile b = y as Mobile;

if ( a == null || b == null )
throw new ArgumentException();

if ( a.AccessLevel > b.AccessLevel )
return -1;
else if ( a.AccessLevel < b.AccessLevel )
return 1;
else
return CaseInsensitiveComparer.Default.Compare( a.Name, b.Name );
}
}

public MsgGump( Mobile owner ) : this( owner, BuildList( owner ), 0 )
{
}

public MsgGump( Mobile owner, ArrayList list, int page ) : base( GumpOffsetX, GumpOffsetY )
{
owner.CloseGump( typeof( MsgGump ) );

m_Owner = owner;
m_Mobiles = list;
m = m_Owner as PlayerMobile;

Initialize( page, m );
}

public static ArrayList BuildList( Mobile owner )
{
ArrayList list = new ArrayList();
ArrayList states = NetState.Instances;

for ( int i = 0; i < states.Count; ++i )
{
Mobile m = ((NetState)states).Mobile;

if ( m != null && (m == owner || ((PlayerMobile)m).Onshow || m.AccessLevel < owner.AccessLevel ))
list.Add( m );
}

list.Sort( InternalComparer.Instance );

return list;
}

public void Initialize( int page, PlayerMobile whopm )
{
m_Page = page;
PlayerMobile who = whopm;

int count = m_Mobiles.Count - (page * EntryCount);

if ( count < 0 )
count = 0;
else if ( count > EntryCount )
count = EntryCount;

int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));

AddPage( 0 );

AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );

int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;

int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);

if ( !OldStyle )
AddAlphaRegion( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight );

if ( who.LocShow == false )
{
AddLabel( 12, 12, 36, "location" );
AddButton( 60, 12, 0xD3, 0xD2, 5, GumpButtonType.Reply, 0 );
}
else if(who.LocShow == true)
{
AddLabel( 12, 12, 61, "location" );
AddButton( 60, 12, 0xD2, 0xD3, 5, GumpButtonType.Reply, 0 );
}

x += emptyWidth + OffsetSize;

if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );

if ( page > 0 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );

if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, 1153, "Previous" );
}

x += PrevWidth + OffsetSize;

if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );

if ( (page + 1) * EntryCount < m_Mobiles.Count )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1 );

if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, 1153, "Next" );
}

for ( int i = 0, index = page * EntryCount; i < EntryCount && index < m_Mobiles.Count; ++i, ++index )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;

Mobile m = (Mobile)m_Mobiles[index];
string map = m.Map.ToString();
string region = m.Region.ToString();

AddAlphaRegion( x, y, EntryWidth, EntryHeight );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, GetHueFor( m ), m.Deleted ? "(deleted)" : m.Name );

if(region == "")
{
AddLabelCropped( (int)((x + TextOffsetX) + (m.Name.Length * 7.5)), y, EntryWidth - TextOffsetX, EntryHeight, 1153, ((PlayerMobile)m).LocShow ? String.Format( "[Unknown]") : "" );
AddLabelCropped( (int)((x + TextOffsetX) + (m.Name.Length * 7.5) + 60 ), y, EntryWidth - TextOffsetX, EntryHeight, 1153, ((PlayerMobile)m).LocShow ? String.Format( "[{0}]",map) : "" );
}
else
{
AddLabelCropped( (int)((x + TextOffsetX) + (m.Name.Length * 7.5)), y, EntryWidth - TextOffsetX, EntryHeight, 1153, ((PlayerMobile)m).LocShow ? String.Format( "[{0}]",region) : "" );
AddLabelCropped( (int)((x + TextOffsetX) + (m.Name.Length * 7.5) + (region.Length * 7.5)), y, EntryWidth - TextOffsetX, EntryHeight, 1153, ((PlayerMobile)m).LocShow ? String.Format( "[{0}]",map) : "" );
}

x += EntryWidth + OffsetSize;

if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );

if (( m.NetState != null && !m.Deleted && m != who && !((PlayerMobile)m).IgnoreList.Contains ( who ) ) || ( who.AccessLevel > m.AccessLevel ))
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 6, GumpButtonType.Reply, 0 );

if ( who.IgnoreList.Contains ( m ) )
{
if( who == m )
AddLabelCropped( 290, y, EntryWidth - TextOffsetX, EntryHeight, 32, m.Deleted ? "(deleted)" : String.Format("Guild Msg Off") );
else
AddLabelCropped( 290, y, EntryWidth - TextOffsetX, EntryHeight, 32, m.Deleted ? "(deleted)" : String.Format("- Ignored -") );
}
}

AddLabel( 150, 12, 43, "Msg Guild" );
AddButton( 210, 13, 0x15e1, 0x15e5, 4, GumpButtonType.Reply, 0 );

if ( wh:confused:nshow == false )
{
AddLabel( 270, 12, 36, "Invis" );
AddButton( 310, 12, 0xD3, 0xD2, 3, GumpButtonType.Reply, 0 );
}
else if(wh:confused:nshow == true)
{
AddLabel( 270, 12, 61, "Online" );
AddButton( 310, 12, 0xD2, 0xD3, 3, GumpButtonType.Reply, 0 );
}
}

private static int GetHueFor( Mobile m )
{
switch ( m.AccessLevel )
{
case AccessLevel.Administrator: return 0x516;
case AccessLevel.Seer: return 0x144;
case AccessLevel.GameMaster: return 0x21;
case AccessLevel.Counselor: return 0x2;
case AccessLevel.Player: default:
{
if (m.NameHue != -1)
return m.NameHue;
else if ( m.Kills >= 5 )
return 0x21;
else if ( m.Criminal )
return 0x3B1;

return 0x58;
}
}
}

public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;

switch ( info.ButtonID )
{
case 0: // Closed
{
return;
}
case 1: // Previous
{
if ( m_Page > 0 )
from.SendGump( new MsgGump( from, m_Mobiles, m_Page - 1 ) );

break;
}
case 2: // Next
{
if ( (m_Page + 1) * EntryCount < m_Mobiles.Count )
from.SendGump( new MsgGump( from, m_Mobiles, m_Page + 1 ) );

break;
}
case 3: // Msg on/off
{
if ( m.Onshow == true )
{
m.Onshow = false;
from.SendMessage( "You are now invisible to other players" );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
else if ( m.Onshow == false )
{
m.Onshow = true;
from.SendMessage( "You are now visible to other players" );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
break;
}

case 4: // GuildChat
{
if ( from.Guild == null )
{
from.SendMessage( "You are not a member of any guild!" );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
else
{
Mobile m = from;
if( m.NetState == null || from == null )
{
from.CloseGump( typeof(MsgClientGump) );
from.CloseGump( typeof(MsgGump) );
}
else
{
from.CloseGump( typeof(MsgClientGump) );
from.CloseGump( typeof(MsgGump) );
from.SendGump( new MsgClientGump( from, m.NetState ) );
}
}
break;
}

case 5: // Location show on/off
{
if ( m.LocShow == true )
{
m.LocShow = false;
from.SendMessage( "Your location is hidden to other players" );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
else if ( m.LocShow == false )
{
m.LocShow = true;
from.SendMessage( "Your location is now visible to other players" );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
break;
}

default:
{
int index = (m_Page * EntryCount) + (info.ButtonID - 6);

if ( index >= 0 && index < m_Mobiles.Count )
{
Mobile m = (Mobile)m_Mobiles[index];

if ( m.Deleted )
{
from.SendMessage( "That player has deleted their character." );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
else if ( m.NetState == null || m == null )
{
from.SendMessage( "That player is no longer online." );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
else if ( m == m_Owner || ((PlayerMobile)m).Onshow || m_Owner.AccessLevel > m.AccessLevel )
{
from.CloseGump( typeof(MsgClientGump) );
from.CloseGump( typeof(MsgGump) );
from.SendGump( new MsgClientGump( from, m.NetState ) );
}
else
{
from.SendMessage( "You cannot see them." );
from.SendGump( new MsgGump( from, m_Mobiles, m_Page ) );
}
}

break;
}
}
}
}
}[/code:1]

To sum it up, I basicly added the LocShow bool to PlayerMobile, and edited the MsgGump.cs, changing it from a command, to a simple on speech keyword(s). I really hate using commands for player characters. The real change though, was removing the page and mobile Count from the gump, and adding the "Location" button. This allows players to have the option of also hiding thier game locations if needed. Default is set false (Hidden).
When you have PvP going on, you dont want ppl to be able to see your location, and only having the option of being 'Invis" completly from everyone :)

Hope you like the mods.
 
S

Seven

Guest
Ok..i got kinda of a newb question. When i edit the playermobile.cs won't it make it so i have to WIPE all my accounts? I know you posted above and and the README how to go around the seralize...BUT...Your readme is kind of confusing...It includes that method + the seralize/desearlise. so...Im kinda confused now ;)
 
S

Seven

Guest
so if i leave the save/load out...i should not have to restart playerbase the right?
<-Edit->
I DONT see ANY commands for this...where are they?
like
[online ect?
 

Dian

Sorceror
If you serialize / deserialize your addition to PlayerMobile correctly, there is no need to have to wipe player characters. This is of course you only use the PlayerMobile, and not some DovMobile or whatever other sub PlayerMobile class's are out there.
 
S

Seven

Guest
Dian said:
If you serialize / deserialize your addition to PlayerMobile correctly, there is no need to have to wipe player characters. This is of course you only use the PlayerMobile, and not some DovMobile or whatever other sub PlayerMobile class's are out there.

Then old playermobiles will not have THIS :<
I don't see a point to seralize it anyways..so i didn't
even if you searlize it correctly it probably won't add it to the OLD mobiles anyways
 

Fury

Wanderer
Seven said:
Dian said:
If you serialize / deserialize your addition to PlayerMobile correctly, there is no need to have to wipe player characters. This is of course you only use the PlayerMobile, and not some DovMobile or whatever other sub PlayerMobile class's are out there.

Then old playermobiles will not have THIS :<
I don't see a point to seralize it anyways..so i didn't
even if you searlize it correctly it probably won't add it to the OLD mobiles anyways

you should go reread tutorals on serialize deserialize, you are lacking basic understanding of this.
 

tristemfire

Wanderer
OK everytime I add your msg system it works fine until I do a world save and restart my server then I get a player mobile error on world load. It askes me if I want to delete the object and weath I say yes or no it creates an fatal excption. I tracked the mobile back to the char and account and tried deleting it and that fixed the error on that mobile but then give me the same error with another player mob. I have continued to do the same a systematicly deleted chars and accounts and still contiued to get the same error with each player mob (of course I backed up everything before i just started deleting accounts). I have tryed all of the above fore metioned impemtaions but still the same result. If I revert it a previous save and remove the system and restore my player mobile it fixes the problem. Any suggestions would be great.
 
S

Seven

Guest
tristemfire said:
OK everytime I add your msg system it works fine until I do a world save and restart my server then I get a player mobile error on world load. It askes me if I want to delete the object and weath I say yes or no it creates an fatal excption. I tracked the mobile back to the char and account and tried deleting it and that fixed the error on that mobile but then give me the same error with another player mob. I have continued to do the same a systematicly deleted chars and accounts and still contiued to get the same error with each player mob (of course I backed up everything before i just started deleting accounts). I have tryed all of the above fore metioned impemtaions but still the same result. If I revert it a previous save and remove the system and restore my player mobile it fixes the problem. Any suggestions would be great.
Look @ Furys post AFTER mine ;)
 

Fury

Wanderer
aye to use this you really need some understanding of serialize/deserialize.. if you used the playermobile i included that wouldnt happen.. if you want post your serialize/deserialize methods and ill try and help.. please dont post whole playermobile.
 
S

Seven

Guest
Fury said:
aye to use this you really need some understanding of serialize/deserialize.. if you used the playermobile i included that wouldnt happen.. if you want post your serialize/deserialize methods and ill try and help.. please dont post whole playermobile.
??...Well, i know how to desleraize it and seralize it...for example the point system...When i did that perfectly i still had to restart my accounts. Do i have to configure it somewhere else to?
 

Fury

Wanderer
Seven said:
Fury said:
aye to use this you really need some understanding of serialize/deserialize.. if you used the playermobile i included that wouldnt happen.. if you want post your serialize/deserialize methods and ill try and help.. please dont post whole playermobile.
??...Well, i know how to desleraize it and seralize it...for example the point system...When i did that perfectly i still had to restart my accounts. Do i have to configure it somewhere else to?

If that is the case you do not understand it and did not do it perfectly. i have done quite a bit of serialize/deserialize to playermobile.cs on a live shard and have never wiped players.
 

lordomega

Wanderer
Fury said:
If that is the case you do not understand it and did not do it perfectly. i have done quite a bit of serialize/deserialize to playermobile.cs on a live shard and have never wiped players.

Same, I have done quite a bit myself, and have never had to wipe my playerbase. I suggest looking over your code again, the same thing recently happened to me, because I looked over a simple mistake (on my part).
 
S

Seven

Guest
Ok...I'm currently wanting to make it so that onstart *when player logs in* that he is Visible to all other players. Right now when you log on your invis. Just point me to what script that lies in...
 

Dian

Sorceror
In the PlayerMobile, where you put the code:

[code:1]pm.Onshow = false;[/code:1]

just change that to:

[code:1]pm.Onshow = true;[/code:1]

that is under the
[code:1]private static void OnLogin( LoginEventArgs e )[/code:1]

that will make all players visible on login.

This was already mentioned though, in last page..
 
Status
Not open for further replies.
Top