Server.SpeechEventArgs.HasKeyword C# (CSharp) Method

HasKeyword() public method

public HasKeyword ( int keyword ) : bool
keyword int
return bool
		public bool HasKeyword( int keyword )
		{
			for ( int i = 0; i < m_Keywords.Length; ++i )
				if ( m_Keywords[i] == keyword )
					return true;

			return false;
		}

Usage Example

Ejemplo n.º 1
0
		public override void OnSpeech( SpeechEventArgs e )
		{
			Mobile from = e.Mobile;
            if (XmlScript.HasTrigger(this, TriggerName.onSpeech) && UberScriptTriggers.Trigger(this, e.Mobile, TriggerName.onSpeech, null, e.Speech))
            {
                return;
            }

			if ( !e.Handled && from is PlayerMobile && from.InRange( this.Location, 2 ) && WasNamed( e.Speech ) )
			{
				PlayerMobile pm = (PlayerMobile)from;

				if ( e.HasKeyword( 0x0004 ) ) // *join* | *member*
				{
					if ( pm.NpcGuild == this.NpcGuild )
						SayTo( from, 501047 ); // Thou art already a member of our guild.
					else if ( pm.NpcGuild != NpcGuild.None )
						SayTo( from, 501046 ); // Thou must resign from thy other guild first.
                    else if (pm.Young || pm.GameTime < JoinGameAge || (pm.CreationTime + JoinAge) > DateTime.UtcNow)
                    {
                        SayTo(from, 501048); // You are too young to join my guild...
                        if (pm.GameTime < JoinGameAge)
                        {
                            pm.LocalOverheadMessage(MessageType.Regular, 38, false, "Your gametime (" + pm.GameTime + ") must reach " + JoinGameAge + " before you can join.");
                        }
                        else if ((pm.CreationTime + JoinAge) > DateTime.UtcNow)
                        {
                            pm.LocalOverheadMessage(MessageType.Regular, 38, false, "You must wait 7 days after creating your character to join. That will be at " + (pm.CreationTime + JoinAge) + " server time." );
                        }
                    }
                    else if (CheckCustomReqs(pm))
                        SayPriceTo(from);

					e.Handled = true;
				}
				else if ( e.HasKeyword( 0x0005 ) ) // *resign* | *quit*
				{
					if ( pm.NpcGuild != this.NpcGuild )
					{
						SayTo( from, 501052 ); // Thou dost not belong to my guild!
					}
					else if ( (pm.NpcGuildJoinTime + QuitAge) > DateTime.UtcNow || (pm.NpcGuildGameTime + QuitGameAge) > pm.GameTime )
					{
						SayTo( from, 501053 ); // You just joined my guild! You must wait a week to resign.
					}
					else
					{
						SayTo( from, 501054 ); // I accept thy resignation.
						pm.NpcGuild = NpcGuild.None;
					}

					e.Handled = true;
				}
			}

			base.OnSpeech( e );
		}
All Usage Examples Of Server.SpeechEventArgs::HasKeyword