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!

guild chat system

abramelin

Wanderer
guild chat system

here is the script
Code:
using System; 
using System.Text; 
using System.Collections; 
using Server; 
using Server.Network; 
using Server.Guilds; 
using Server.Mobiles; 

namespace Server.Scripts.Commands 
{ 
public class GC 
{ 
private static int usercount; 

public static void Initialize() 
{ 
Server.Commands.Register( GC, AccessLevel.Player, new CommandEventHandler( GC_OnCommand ) ); 
} 

[Usage( GC [text>|list] )] 
[Description( Broadcasts a message to all online members of your guild. )] 
private static void GC_OnCommand( CommandEventArgs e ) 
{ 
switch( e.ArgString.ToLower() ) 
{ 
case list: 
List ( e.Mobile ); 
break; 
default: 
Msg ( e ); 
break; 
} 
} 

private static void List( Mobile g ) 
{ 
usercount = 0; 
Guild GuildC = g.Guild; 
if ( GuildC == null ) 
{ 
g.SendMessage( You are not in a guild! ); 
} 
else 
{ 
foreach ( NetState state in NetState.Instances ) 
{ 
Mobile m = state.Mobile; 
if ( m != null GuildC.IsMember( m ) ) 
{ 
usercount++; 
}
} 
if (usercount == 1)
{
g.SendMessage( There is 1 member of your guild online. );
}
else
{
g.SendMessage( There are {0} members of your guild online., usercount );
}
g.SendMessage (Online list: );
foreach ( NetState state in NetState.Instances ) 
{ 
Mobile m = state.Mobile; 
if ( m != null GuildC.IsMember( m ) ) 
{ 
string region = m.Region.ToString(); 
if (region == ) 
{ 
region = Britannia;
} 
g.SendMessage( {0} ({1}), m.Name, region ); 
}
} 

} 
} 

private static void Msg( CommandEventArgs e ) 
{ 
Mobile from = e.Mobile; 

Guild GuildC = from.Guild; 
if ( GuildC == null ) 
{ 
from.SendMessage( You are not in a guild! ); 
} 
else 
{ 
foreach ( NetState state in NetState.Instances ) 
{ 
Mobile m = state.Mobile; 
if ( m != null GuildC.IsMember( m ) )
{
m.SendMessage( 0x2C, String.Format( Guild[{0}]: {1}, from.Name, e.ArgString ) );
}
} 
} 
} 
} 
}
here is the error:
RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed (9 errors, 0 warnings)
- Error: Scripts\guild_olayi.cs: CS1525: (line 20, column 18) Invalid expressio
n term '|'
- Error: Scripts\guild_olayi.cs: CS1003: (line 20, column 19) Syntax error, ']'
expected
- Error: Scripts\guild_olayi.cs: CS1519: (line 20, column 23) Invalid token ']'
in class, struct, or interface member declaration
- Error: Scripts\guild_olayi.cs: CS1026: (line 21, column 26) ) expected
- Error: Scripts\guild_olayi.cs: CS1002: (line 21, column 36) ; expected
- Error: Scripts\guild_olayi.cs: CS1002: (line 21, column 43) ; expected
- Error: Scripts\guild_olayi.cs: CS1002: (line 21, column 58) ; expected
- Error: Scripts\guild_olayi.cs: CS1002: (line 21, column 66) ; expected
- Error: Scripts\guild_olayi.cs: CS1001: (line 21, column 73) Identifier expect
ed
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

what am i doing wrong ?
 

Seanchen.net

Wanderer
The follow code is not correct:

Code:
switch( e.ArgString.ToLower() ) 
{ 
case list: 
List ( e.Mobile ); 
break; 
default: 
Msg ( e ); 
break; 
}

http://msdn.microsoft.com

Look for documentation on whats called a "switch case" statment, once you do this, why that code is not allowed will make more sense.
 

abramelin

Wanderer
i ve no programming skills :(
if you help me to work this script i ll never write any question here cause this my last work .i done everything.this is the final subject.i promise.
please help seanchen:(
 

Seanchen.net

Wanderer
abramelin said:
i ve no programming skills :(
if you help me to work this script i ll never write any question here cause this my last work .i done everything.this is the final subject.i promise.
please help seanchen:(

Attempt to fix it yourself, documentation on how to use a switch case statment in C# is on msdn, its not like I am not providing you a direction.

I want you to ask questions, why would I answer this one so you don't ask questions?
 

brodock

Sorceror
as you asked me, this is my old guild chat with "list" option...

be carefull as i don't use it anymore, so i don't know if it's gonna work...

i also suggest you use Knives Chat, that is Infinitively Better than this... (also this code is not mine i just used and made some changes to it).

Code:
using System; 
using System.Text; 
using System.Collections; 
using Server; 
using Server.Network; 
using Server.Guilds; 
using Server.Mobiles; 

namespace Server.Scripts.Commands 
{ 
   public class GUILDC 
      { 
      private static int usercount; 

      public static void Initialize() 
      { 
         Server.Commands.Register( "GDC", AccessLevel.Player, new CommandEventHandler( GUILDC_OnCommand ) ); 
            } 

      [Usage( "GDC [<text>|list]" )] 
      [Description( "Envia mensagem para membros da guilda e lista onlines." )] 
      private static void GUILDC_OnCommand( CommandEventArgs e ) 
      { 
         switch( e.ArgString.ToLower() ) 
         { 
            case "list": 
               List ( e.Mobile ); 
               break; 
            default: 
               Msg ( e ); 
               break; 
         } 
      } 

      private static void List( Mobile g ) 
      { 
         usercount = 0; 
         Guild GuildC = (Guild)(g.Guild); 
         if ( GuildC == null ) 
         { 
            g.SendMessage( "Voce nao esta em uma guilda!" ); 
         } 
         else 
         { 
            foreach ( NetState state in NetState.Instances ) 
            { 
               Mobile m = state.Mobile; 
               if ( m != null && GuildC.IsMember( m ) ) 
               { 
                  usercount++; 
               } 
            } 
            if (usercount == 0) 
            { 
               g.SendMessage( "Nenhum membro da guilda esta online." ); 
            } 
            else 
            { 
               g.SendMessage( "{0} membro{0} da guilda esta online.", usercount, usercount == 1 ? "" : "s"); 
            } 
            g.SendMessage ("Online List:" ); 
            foreach ( NetState state in NetState.Instances ) 
            { 
               Mobile m = state.Mobile; 
               if ( m != null && GuildC.IsMember( m ) ) 
               { 
                  string region = m.Region.ToString(); 
                  if (region == "") 
                  { 
                     region = "Sosaria"; 
                  }                
                  g.SendMessage( "{0} ({1})", m.Name, region ); 
               } 
            }       

         } 
      } 

      private static void Msg( CommandEventArgs e  ) 
      { 
         Mobile from = e.Mobile; 

         Guild GuildC = (Guild)(from.Guild); 
         if ( GuildC == null ) 
         { 
            from.SendMessage( "Voce nao esta em uma guilda!" ); 
         } 
         else 
         { 
            foreach ( NetState state in NetState.Instances ) 
            { 
               Mobile m = state.Mobile; 
               if ( m != null && GuildC.IsMember( m ) ) 
               { 
                  m.SendMessage( 0x2C, String.Format( "Guilda[{0}]: {1}", from.Name, e.ArgString ) ); 
               } 
            } 
         } 
      } 
   } 
}
 

abramelin

Wanderer
knives chat has lots of features that i dont want
like pm messaging,filtering,banning,away mode,friendlist,staff msg etc...
i only and only what guild list and guild chat :( :( :(
 

Seanchen.net

Wanderer
abramelin said:
knives chat has lots of features that i dont want
like pm messaging,filtering,banning,away mode,friendlist,staff msg etc...
i only and only what guild list and guild chat :( :( :(

So remove those features?

If you want help, all you have to do is ask, and post what you have tried.

I know you might be upset with all the work, people are making you do, but your a shard admin so you shouldn't complain.

If you can't do a few hours of programming to make something work, then you shouldn't run a shard, so I don't feel bad making you work. Infact I would be up for several days, coding almost every minute, if I were in your shoes.
 

Seanchen.net

Wanderer
abramelin said:
how can i remove this features sanch?

Who is sanch?

Anyways find the code you wish to remove, select and delete it?

I mean what do you want me to say, besides telling you what you need to do, unless I know what your confused about I can't help you.

Please don't give me that, "you don't know how to program", because you can learn how the script works by looking at it. You can try different things and find what happens when you remove this and that.

You don't have to understand why it does what it does, because you can ask that and we will tell you. Of course if you don't want to do this, then you should hire somebody who will, because everything on your shard will require knowlege of how to program.

So either learn by playing with the code, or hire somebody to do it, its your shard so I will let you decided.
 

Joeku

Lord
I can't believe nobody has yet mentioned to this guy that he posted in the wrong board. If you need help with a script, post in the Script Support board.
 

abramelin

Wanderer
ok i am goint to try to edit knives chat one by one
so lets start
i only want guildchat
so guildchat.cs this is my file
i opened it
Code:
using System;
using Server;
using Server.Guilds;
using Knives.Utils;

namespace Knives.Chat
{
	public class GuildChat
	{
		public static void Initialize()
		{
			Server.Commands.Register( "Guild", AccessLevel.Player, new CommandEventHandler( OnChat ) );
			Server.Commands.Register( "G", AccessLevel.Player, new CommandEventHandler( OnChat ) );
		}

		public static bool CanChat( ChatInfo info ){ return CanChat( info, false ); }

		public static bool CanChat( ChatInfo info, bool action )
		{
			if ( info.Mobile.Guild == null )
			{
				if ( action )
					info.Mobile.SendMessage( info.SystemColor, "You are not in a guild." );

				return false;
			}

			if ( info.Banned )
			{
				if ( action )
					info.Mobile.SendMessage( info.SystemColor, "You are banned from chat." );

				return false;
			}

			return true;
		}

		public static void OnChat( CommandEventArgs e )
		{
			OnChat( e, true );
		}

		private static void Queued( object obj )
		{
			if ( !(obj is CommandEventArgs) )
				return;

			OnChat( (CommandEventArgs)obj, false );
		}

		private static void OnChat( CommandEventArgs e, bool spammsg )
		{try{

			ChatInfo info = ChatInfo.GetInfo( e.Mobile );

			if ( !CanChat( info, true ) )
				return;

			if ( e.ArgString == null || e.ArgString == "" )
				ListGump.SendTo( e.Mobile, Listing.Guild );
			else if ( !TrackSpam.LogSpam( e.Mobile, "chat", ChatInfo.SpamLimiter ) )
			{
				Timer.DelayCall( TrackSpam.NextAllowedIn( e.Mobile, "chat", ChatInfo.SpamLimiter ), new TimerStateCallback( Queued ), e );
				if ( spammsg )
					e.Mobile.SendMessage( info.SystemColor, "Message queued.  Please wait {0} seconds between messages.", ChatInfo.SpamLimiter );
			}
			else
			{
				foreach( ChatInfo ci in ChatInfo.ChatInfos.Values )
				{
					if ( ci.Mobile.NetState == null )
						continue;

					if ( CanChat( ci ) && info.Mobile.Guild == ci.Mobile.Guild && !ci.Ignoring( info.Mobile ) )
						ci.Mobile.SendMessage( ci.GuildColor, "<{0}> {1}: {2}", e.Mobile.Guild.Abbreviation, e.Mobile.Name, e.ArgString );
					else if ( ChatInfo.AllianceChat && CanChat( ci ) && ((Guild)info.Mobile.Guild).Allies.Contains( ci.Mobile.Guild ) && !ci.Ignoring( info.Mobile ) )
						ci.Mobile.SendMessage( ci.GuildColor, "<{0}> {1}: {2}", e.Mobile.Guild.Abbreviation, e.Mobile.Name, e.ArgString );
					else if ( ci.GlobalGuild )
						ci.Mobile.SendMessage( ci.GuildColor, "<{0}> {1}: {2}", e.Mobile.Guild.Abbreviation, e.Mobile.Name, e.ArgString );
				}
			}

		}catch{ Errors.Report( String.Format( "GuildChat-> OnChat-> |{0}|", e.Mobile ) ); } }
	}
}
but when i only put this file to scripts
it cannot load lots of stuff :(
 

Joeku

Lord
It's sad that some people could really care less about something, and don't want it unless someone else gives it to them.
 

X-SirSly-X

Sorceror
This is not hard, just read the post for knives chat system, and use the command to bring up the options gump, and disable what you want turned off. I've said this before already on another forum.
 
Top