Full Version : flood in emote system
xmlspawner >>Scripting Support >>flood in emote system


<< Prev | Next >>

darkwinters- 02-02-2006
this is my custom emote script
CODE

using System;
using System.Collections;
using System.IO;
using System.Text;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Gumps;

namespace Server.Scripts.Commands
{
public enum EmotePage
{
 P1,
 P2,
 P3,
 P4,
}
public class Emote
{
 public static void Initialize()
 {
  Server.Commands.Register( "emote", AccessLevel.Player, new CommandEventHandler( Emote_OnCommand ) );
  Server.Commands.Register( "e", AccessLevel.Player, new CommandEventHandler( Emote_OnCommand ) );
 }

   [Usage( "<sound>" )]
       [Description( "Emote with sounds, words, and possibly an animation with one command!")]
 public static void Emote_OnCommand( CommandEventArgs e )
 {
  Mobile pm = e.Mobile;
          string em = e.ArgString.Trim();
  int SoundInt;
  switch( em )
  {
   case "ah":
    SoundInt = 1;
    break;
   case "ahha":
    SoundInt = 2;
    break;    
   case "applaud":
    SoundInt = 3;
    break;    
   case "blownose":
    SoundInt = 4;
    break;    
   case "bow":
    SoundInt = 5;
    break;
   case "bscough":
    SoundInt = 6;
    break;
   case "burp":
    SoundInt = 7;
    break;
   case "clearthroat":
    SoundInt = 8;
    break;
   case "cough":
    SoundInt = 9;
    break;
   case "cry":
    SoundInt = 10;
    break;
   case "faint":    
    SoundInt = 11;
    break;
   case "fart":
    SoundInt = 12;
    break;
   case "gasp":
    SoundInt = 13;
    break;
   case "giggle":
    SoundInt = 14;
    break;
   case "groan":
    SoundInt = 15;
    break;
   case "growl":
    SoundInt = 16;
    break;
   case "hey":
    SoundInt = 17;
    break;
   case "hiccup":
    SoundInt = 18;
    break;
   case "huh":
    SoundInt = 19;
    break;
   case "kiss":
    SoundInt = 20;
    break;
   case "laugh":
    SoundInt = 21;
    break;
   case "no":
    SoundInt = 22;
    break;
   case "oh":
    SoundInt = 23;
    break;
   case "oooh":
    SoundInt = 24;
    break;
   case "oops":
    SoundInt = 25;
    break;
   case "puke":
    SoundInt = 26;
    break;
   case "punch":      
    SoundInt = 27;
    break;
   case "scream":
    SoundInt = 28;
    break;
   case "shush":
    SoundInt = 29;
    break;
   case "sigh":
    SoundInt = 30;
    break;
   case "slap":
    SoundInt = 31;
    break;
   case "sneeze":
    SoundInt = 32;
    break;
   case "sniff":
    SoundInt = 33;
    break;
   case "snore":
    SoundInt = 34;
    break;
   case "spit":
    SoundInt = 35;
    break;
   case "stickouttongue":
    SoundInt = 36;
    break;
   case "tapfoot":
    SoundInt = 37;
    break;
   case "wistle":
    SoundInt = 38;
    break;
   case "woohoo":
    SoundInt = 39;
    break;
   case "yawn":
    SoundInt = 40;
    break;
   case "yea":
    SoundInt = 41;
    break;
   case "yell":
    SoundInt = 42;
    break;    
   default:
    SoundInt = 0;
    e.Mobile.SendGump( new EmoteGump( e.Mobile, EmotePage.P1) );
    break;
  }
  if ( SoundInt > 0 )
   new ESound( pm, SoundInt );
 }
}
public class EmoteGump : Gump
{
 private Mobile m_From;
 private EmotePage m_Page;
 private const int Blanco = 0xFFFFFF;
 private const int Azul = 0x8080FF;
 public void AddPageButton( int x, int y, int buttonID, string text, EmotePage page, params EmotePage[] subpage )
 {
  bool seleccionado = ( m_Page == page );
  for ( int i = 0; !seleccionado && i < subpage.Length; ++i )
  seleccionado = ( m_Page == subpage[i] );
  AddButton( x, y - 1, seleccionado ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
  AddHtml( x + 35, y, 200, 20, Color( text, seleccionado ? Azul : Blanco ), false, false );
 }
 public void AddButtonLabeled( int x, int y, int buttonID, string text )
 {
  AddButton( x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
  AddHtml( x + 35, y, 240, 20, Color( text, Blanco ), false, false );
 }
 public int GetButtonID( int type, int index )
 {
  return 1 + (index * 15) + type;
 }
 public string Color( string text, int color )
 {
  return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
 }
 public EmoteGump ( Mobile from, EmotePage page) : base ( 600, 50 )
 {
  from.CloseGump( typeof( EmoteGump ) );
  m_From = from;
  m_Page = page;
  Closable = true;
  Dragable = true;
  AddPage( 0 );
  AddBackground( 0, 65, 130, 360, 5054);
  AddAlphaRegion( 10, 70, 110, 350 );
  AddImageTiled( 10, 70, 110, 20, 9354);
  AddLabel( 13, 70, 200, "Emote Listesi");
  AddImage( 100, 0, 10410);
  AddImage( 100, 305, 10412);
  AddImage( 100, 150, 10411);
  switch ( page )
  {
   case EmotePage.P1:
   {
    AddButtonLabeled( 10, 90, GetButtonID( 1, 1 ), "Ah");
    AddButtonLabeled( 10, 115, GetButtonID( 1, 2 ), "Ah-ha");
    AddButtonLabeled( 10, 140, GetButtonID( 1, 3 ), "Alkis");
    AddButtonLabeled( 10, 165, GetButtonID( 1, 4 ), "Sümkür");
    AddButtonLabeled( 10, 190, GetButtonID( 1, 5 ), "Egil");
    AddButtonLabeled( 10, 215, GetButtonID( 1, 6 ), "Tikan");
    AddButtonLabeled( 10, 240, GetButtonID( 1, 7 ), "Gegir");
    AddButtonLabeled( 10, 265, GetButtonID( 1, 8 ), "Bogaz Temizle");
    AddButtonLabeled( 10, 290, GetButtonID( 1, 9 ), "Öksür");
    AddButtonLabeled( 10, 315, GetButtonID( 1, 10 ), "Agla");
    AddButtonLabeled( 10, 340, GetButtonID( 1, 11 ), "Bayil");
    AddButtonLabeled( 10, 365, GetButtonID( 1, 12 ), "Osur");
    AddButton( 70, 380, 4502, 0504, GetButtonID( 0,2 ), GumpButtonType.Reply, 0 );
    break;
   }
   case EmotePage.P2:
   {
    AddButtonLabeled( 10, 90, GetButtonID( 1, 13 ), "Solu");
    AddButtonLabeled( 10, 115, GetButtonID( 1, 14 ), "Kikirda");
    AddButtonLabeled( 10, 140, GetButtonID( 1, 15 ), "Inle");
    AddButtonLabeled( 10, 165, GetButtonID( 1, 16 ), "Gürle");
    AddButtonLabeled( 10, 190, GetButtonID( 1, 17 ), "Hey");
    AddButtonLabeled( 10, 215, GetButtonID( 1, 18 ), "Hiçkir");
    AddButtonLabeled( 10, 240, GetButtonID( 1, 19 ), "Huh");
    AddButtonLabeled( 10, 265, GetButtonID( 1, 20 ), "Öpücük");
    AddButtonLabeled( 10, 290, GetButtonID( 1, 21 ), "Kahkaha");
    AddButtonLabeled( 10, 315, GetButtonID( 1, 22 ), "Hayir");
    AddButtonLabeled( 10, 340, GetButtonID( 1, 23 ), "Sasir");
    AddButtonLabeled( 10, 365, GetButtonID( 1, 24 ), "Oooh");
    AddButton( 10, 380, 4506, 4508, GetButtonID( 0,1 ), GumpButtonType.Reply, 0 );
    AddButton( 70, 380, 4502, 0504, GetButtonID( 0,3 ), GumpButtonType.Reply, 0 );
    break;
   }
   case EmotePage.P3:
   {
    AddButtonLabeled( 10, 90, GetButtonID( 1, 25 ), "Özür");
    AddButtonLabeled( 10, 115, GetButtonID( 1, 26 ), "Kus");
    AddButtonLabeled( 10, 140, GetButtonID( 1, 27 ), "Yumruk");
    AddButtonLabeled( 10, 165, GetButtonID( 1, 28 ), "Çiglik");
    AddButtonLabeled( 10, 190, GetButtonID( 1, 29 ), "SUS!");
    AddButtonLabeled( 10, 215, GetButtonID( 1, 30 ), "Iç çek");
    AddButtonLabeled( 10, 240, GetButtonID( 1, 31 ), "Tokat");
    AddButtonLabeled( 10, 265, GetButtonID( 1, 32 ), "Hapsur");
    AddButtonLabeled( 10, 290, GetButtonID( 1, 33 ), "Burun çek");
    AddButtonLabeled( 10, 315, GetButtonID( 1, 34 ), "Horla");
    AddButtonLabeled( 10, 340, GetButtonID( 1, 35 ), "Tükür");
    AddButtonLabeled( 10, 365, GetButtonID( 1, 36 ), "Yapis");
    AddButton( 10, 380, 4506, 4508, GetButtonID( 0,2 ), GumpButtonType.Reply, 0 );
    AddButton( 70, 380, 4502, 0504, GetButtonID( 0,4 ), GumpButtonType.Reply, 0 );
    break;
   }
   case EmotePage.P4:
   {
    AddButtonLabeled( 10, 90, GetButtonID( 1, 37 ), "Çelme tak");
    AddButtonLabeled( 10, 115, GetButtonID( 1, 38 ), "Islik çal");
    AddButtonLabeled( 10, 140, GetButtonID( 1, 39 ), "Woohoo");
    AddButtonLabeled( 10, 165, GetButtonID( 1, 40 ), "Esne");
    AddButtonLabeled( 10, 190, GetButtonID( 1, 41 ), "Yea");
    AddButtonLabeled( 10, 215, GetButtonID( 1, 42 ), "Haykir");
    AddButton( 10, 380, 4506, 4508, GetButtonID( 0,3 ), GumpButtonType.Reply, 0 );
    break;
   }
  }
 }
 public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
 {
  int val = info.ButtonID - 1;
  if ( val < 0 )
  return;

  Mobile from = m_From;
  int type = val % 15;
  int index = val / 15;

  switch ( type )
  {
   case 0:
   {
    EmotePage page;
     switch ( index )
    {
     case 1: page = EmotePage.P1; break;
     case 2: page = EmotePage.P2; break;
     case 3: page = EmotePage.P3; break;
     case 4: page = EmotePage.P4; break;
     default: return;
    }

    from.SendGump( new EmoteGump( from, page) );
    break;
   }
   case 1:
   {
    if ( index > 0 && index < 13 )
    {
     from.SendGump( new EmoteGump( from, EmotePage.P1) );
    }
    else if ( index > 12 && index < 25 )
    {
     from.SendGump( new EmoteGump( from, EmotePage.P2) );
    }
    else if ( index > 24 && index < 37 )
    {
     from.SendGump( new EmoteGump( from, EmotePage.P3) );
    }
    else if ( index > 36 && index < 43 )
    {
     from.SendGump( new EmoteGump( from, EmotePage.P4) );
    }
    new ESound( from, index );
    break;
   }
  }
 }
}
public class ItemRemovalTimer : Timer
{
 private Item i_item;
 public ItemRemovalTimer( Item item ) : base( TimeSpan.FromSeconds( 10.0 ) )
 {
  Priority = TimerPriority.OneSecond;
  i_item = item;
 }

 protected override void OnTick()
 {
         if (( i_item != null ) && ( !i_item.Deleted ))
          i_item.Delete();
 }
}

public class Puke : Item
{
 [Constructable]
 public Puke() : base( Utility.RandomList( 0xf3b, 0xf3c ) )
 {
  Name = "kusmuk";
  Hue = 0x557;
  Movable = false;

  ItemRemovalTimer thisTimer = new ItemRemovalTimer( this );
  thisTimer.Start();

 }

 public override void OnSingleClick( Mobile from )
 {
  this.LabelTo( from, this.Name );
 }
 
 public Puke( Serial serial ) : base( serial )
 {
 }

 public override void Serialize(GenericWriter writer)
 {
  base.Serialize( writer );
  writer.Write( (int) 0 );
 }

 public override void Deserialize(GenericReader reader)
 {
  base.Deserialize( reader );
  int version = reader.ReadInt();

  this.Delete(); // none when the world starts
 }
}

public class ESound
{
 public ESound( Mobile pm, int SoundMade )
 {
  switch( SoundMade )
  {
   case 1:
    pm.PlaySound( pm.Female ? 778 : 1049 );
    pm.Say( "*ahh*" );
    break;
   case 2:
    pm.PlaySound( pm.Female ? 779 : 1050 );
    pm.Say( "*birseyi kesfeder*" );
    break;
   case 3:
    pm.PlaySound( pm.Female ? 780 : 1051 );
    pm.Say( "*alkislar*" );
    break;
   case 4:
    pm.PlaySound( pm.Female ? 781 : 1052 );
    pm.Say( "*sümkürür*" );    
    if ( !pm.Mounted )
     pm.Animate( 34, 5, 1, true, false, 0 );
    break;
   case 5:
    pm.Say( "*saygiyla egilir*" );
    if ( !pm.Mounted )
     pm.Animate( 32, 5, 1, true, false, 0 );
    break;
   case 6:
    pm.PlaySound( pm.Female ? 786 : 1057 );
    pm.Say( "*bogazi tikanir*" );
    break;
   case 7:
    pm.PlaySound( pm.Female ? 782 : 1053 );
    pm.Say( "*gegirir*" );
    if ( !pm.Mounted )
     pm.Animate( 33, 5, 1, true, false, 0 );
    break;
   case 8:
    pm.PlaySound( pm.Female ? 748 : 1055 );
    pm.Say( "*bogazini temizler*" );
    if ( !pm.Mounted )
     pm.Animate( 33, 5, 1, true, false, 0 );
    break;
   case 9:
    pm.PlaySound( pm.Female ? 785 : 1056 );
    pm.Say( "*öksürür*" );    
    if ( !pm.Mounted )
     pm.Animate( 33, 5, 1, true, false, 0 );
    break;
   case 10:
    pm.PlaySound( pm.Female ? 787 : 1058 );
    pm.Say( "*hüngür hüngür aglar*" );
    break;
   case 11:
    pm.PlaySound( pm.Female ? 791 : 1063 );
    pm.Say( "*bayilir*" );
    if ( !pm.Mounted )
     pm.Animate( 22, 5, 1, true, false, 0 );
    break;
   case 12:
    pm.PlaySound( pm.Female ? 792 : 1064 );
    pm.Say( "*çok pis osurur*" );
    break;
   case 13:
    pm.PlaySound( pm.Female ? 793 : 1065 );
    pm.Say( "*nefesi kesilir*" );
    break;
   case 14:
    pm.PlaySound( pm.Female ? 794 : 1066 );
    pm.Say( "*kikir kikir güler*" );
    break;
   case 15:
    pm.PlaySound( pm.Female ? 795 : 1067 );
    pm.Say( "*inler*" );
    break;
   case 16:
    pm.PlaySound( pm.Female ? 796 : 1068 );
    pm.Say( "*ayi gibi gürler*" );
    break;
   case 17:
    pm.PlaySound( pm.Female ? 797 : 1069 );
    pm.Say( "*hey!*" );
    break;
   case 18:
    pm.PlaySound( pm.Female ? 798 : 1070 );
    pm.Say( "*hiçkirik tutar*" );
    break;
   case 19:
    pm.PlaySound( pm.Female ? 799 : 1071 );
    pm.Say( "*söyleneni anlamaz*" );
    break;
   case 20:
    pm.PlaySound( pm.Female ? 800 : 1072 );
    pm.Say( "*öpücük yollar*" );
    break;
   case 21:
    pm.PlaySound( pm.Female ? 801 : 1073 );
    pm.Say( "*kahkahalarla güler*" );
    break;
   case 22:
    pm.PlaySound( pm.Female ? 802 : 1074 );
    pm.Say( "*kabul etmez*" );
    break;
   case 23:
    pm.PlaySound( pm.Female ? 803 : 1075 );
    pm.Say( "*sasirir*" );
    break;
   case 24:
    pm.PlaySound( pm.Female ? 811 : 1085 );
    pm.Say( "*oooh*" );
    break;
   case 25:
    pm.PlaySound( pm.Female ? 812 : 1086 );
    pm.Say( "*özür diler*" );
    break;
   case 26:
    pm.PlaySound( pm.Female ? 813 : 1087 );
    pm.Say( "*kusar*" );
    break;
   case 27:
    pm.PlaySound( 315 );
    pm.Say( "*yumruk atar*" );
    if ( !pm.Mounted )
     pm.Animate( 31, 5, 1, true, false, 0 );
    break;
   case 28:
    pm.PlaySound( pm.Female ? 814 : 1088 );
    pm.Say( "*çiglik atar*" );
    break;
   case 29:
    pm.PlaySound( pm.Female ? 815 : 1089 );
    pm.Say( "*susturur*" );
    break;
   case 30:
    pm.PlaySound( pm.Female ? 816 : 1090 );
    pm.Say( "*iç çeker*" );
    break;
   case 31:
    pm.PlaySound( 948 );
    pm.Say( "*tokatlar*" );
    if ( !pm.Mounted )
     pm.Animate( 11, 5, 1, true, false, 0 );
    break;
   case 32:
    pm.PlaySound( pm.Female ? 817 : 1091 );
    pm.Say( "*hapsurur!*" );
    if ( !pm.Mounted )
     pm.Animate( 32, 5, 1, true, false, 0 );
    break;
   case 33:
    pm.PlaySound( pm.Female ? 818 : 1092 );
    pm.Say( "*burnunu çeker*" );
    if( !pm.Mounted )
     pm.Animate( 34, 5, 1, true, false, 0 );
    break;
   case 34:
    pm.PlaySound( pm.Female ? 819 : 1093 );
    pm.Say( "*horlar*" );
    break;
   case 35:
    pm.PlaySound( pm.Female ? 820 : 1094 );
    pm.Say( "*tükürür*" );
    if ( !pm.Mounted )
     pm.Animate( 6, 5, 1, true, false, 0 );
    break;
   case 36:
    pm.PlaySound( 792 );
    pm.Say( "*bogazina birsey takilir*" );
    break;
   case 37:
    pm.PlaySound( 874 );
    pm.Say( "*çelme takar*" );
    if ( !pm.Mounted )
     pm.Animate( 38, 5, 1, true, false, 0 );
    break;
   case 38:
    pm.PlaySound( pm.Female ? 821 : 1095 );
    pm.Say( "*islik çalar*" );
    if ( !pm.Mounted )
     pm.Animate( 5, 5, 1, true, false, 0 );
    break;
   case 39:
    pm.PlaySound( pm.Female ? 783 : 1054 );
    pm.Say( "*sevinçten dört köse olur*" );
    break;
   case 40:
    pm.PlaySound( pm.Female ? 822 : 1096 );
    pm.Say( "*esner*" );
    if ( !pm.Mounted )
     pm.Animate( 17, 5, 1, true, false, 0 );
    break;
   case 41:
    pm.PlaySound( pm.Female ? 823 : 1097 );
    pm.Say( "*kabul eder*" );
    break;
   case 42:
    pm.PlaySound( pm.Female ? 823 : 1098 );
    pm.Say( "*haykirir*" );
    break;
  }
 }
}
}

what i want to make is a time delay between emotes to prevent flooding.for example if a player use emote very quickly he will be warned "you must wait 30 second to use another emote" like a message.

ArteGordon- 02-02-2006
The principle is the same as in this earlier post http://xmlspawner.15.forumer.com/index.php?showtopic=206

you will need to add a variable to your playermobile to keep track of the last time you performed an emote.

Then you can check that time before opening a new one.

Add this to your PlayerMobile class

CODE


 public DateTime LastEmoteTime = DateTime.MinValue;


and then add this check to your emote command
QUOTE

public static void Emote_OnCommand( CommandEventArgs e )
{
  Mobile pm = e.Mobile;

  if (pm is PlayerMobile)
      {
              if(DateTime.Now < ((PlayerMobile)pm).LastEmoteTime + TimeSpan.FromSeconds(30.0))
              {
                    pm.SendMessage("You must wait at least 30 seconds between emotes");
                    return;
              }

              ((PlayerMobile)pm).LastEmoteTime = DateTime.Now;
      }

          string em = e.ArgString.Trim();
  int SoundInt;

darkwinters- 02-02-2006
ohh i got it thanks arte gordon but where to put this in playermobile?
public DateTime LastEmoteTime = DateTime.MinValue;

ArteGordon- 02-02-2006
you can put it anywhere in the class definition, just dont put it inside any methods. Look around to see where other similar properties are defined, like the Command Properties.

If it compiles then you got it right. If it complains then you got it wrong smile.gif

darkwinters- 02-02-2006
eheh ok i make it and it works great but arte i think you didnt look the my emote script clearly smile.gif because when they type [e a gump that contains emotes appears and then they choose what emote to use and the gump doesnt close its self.it always remains open unless they dont close it.so they can make quickliy emotes with the gump is always open :)what do you suggest now?add a check to the gump or close the gump when the first emote used?

ArteGordon- 02-02-2006
you can just put the same test in your ESound constructor, or move it there from the command method if you want them to be able to execute the command but not send emotes from the gump too quickly.

CODE

 public ESound( Mobile pm, int SoundMade )
{
// add the test here

darkwinters- 02-02-2006
ok i make it
CODE

public class ESound
{
public ESound( Mobile pm, int SoundMade )
{
  if (pm is PlayerMobile)
     {
             if(DateTime.Now < ((PlayerMobile)pm).LastEmoteTime + TimeSpan.FromSeconds(30.0))
             {
                   pm.SendMessage("You must wait at least 30 seconds between emotes");
                   return;
             }

             ((PlayerMobile)pm).LastEmoteTime = DateTime.Now;
     }

 switch( SoundMade )

and now it always says "you must wait" when they click any emote button tongue.gif

ArteGordon- 02-02-2006
have you waited 30 seconds between clicking?

darkwinters- 02-02-2006
no because it doesnt allow to use emotes smile.gif it always says you must wait .. smile.gif

ArteGordon- 02-02-2006
when you execute the

[emote

command. It should pop up a gump. When you press a button it should allow you to emote. If you press it again before 30 seconds has expired, it should deliver a message and no emote.

If you execute the command with an argument

[emote ah

then you will get no gump, and if there has been no emote executed in the last 30 seconds, you will get the emote. If not, you will get a message and no emote.

If it is not doing that, then you should post the code again with the modifications, because with what you have up and the mod I described, that is what will happen.

Also, post what you put in the PlayerMobile.

darkwinters- 02-02-2006
here is the whole code with the modifications that you gave
CODE

using System;
using System.Collections;
using System.IO;
using System.Text;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Gumps;

namespace Server.Scripts.Commands
{
public enum EmotePage
{
P1,
P2,
P3,
P4,
}
public class Emote
{
public static void Initialize()
{
 Server.Commands.Register( "emote", AccessLevel.Player, new CommandEventHandler( Emote_OnCommand ) );
 Server.Commands.Register( "e", AccessLevel.Player, new CommandEventHandler( Emote_OnCommand ) );
}

  [Usage( "<sound>" )]
      [Description( "Emote with sounds, words, and possibly an animation with one command!")]
public static void Emote_OnCommand( CommandEventArgs e )
{
 Mobile pm = e.Mobile;
   if (pm is PlayerMobile)
     {
             if(DateTime.Now < ((PlayerMobile)pm).LastEmoteTime + TimeSpan.FromSeconds(30.0))
             {
                   pm.SendMessage("You must wait at least 30 seconds between emotes");
                   return;
             }

             ((PlayerMobile)pm).LastEmoteTime = DateTime.Now;
     }

         string em = e.ArgString.Trim();
 int SoundInt;
 switch( em )
 {
  case "ah":
   SoundInt = 1;
   break;
  case "ahha":
   SoundInt = 2;
   break;    
  case "applaud":
   SoundInt = 3;
   break;    
  case "blownose":
   SoundInt = 4;
   break;    
  case "bow":
   SoundInt = 5;
   break;
  case "bscough":
   SoundInt = 6;
   break;
  case "burp":
   SoundInt = 7;
   break;
  case "clearthroat":
   SoundInt = 8;
   break;
  case "cough":
   SoundInt = 9;
   break;
  case "cry":
   SoundInt = 10;
   break;
  case "faint":    
   SoundInt = 11;
   break;
  case "fart":
   SoundInt = 12;
   break;
  case "gasp":
   SoundInt = 13;
   break;
  case "giggle":
   SoundInt = 14;
   break;
  case "groan":
   SoundInt = 15;
   break;
  case "growl":
   SoundInt = 16;
   break;
  case "hey":
   SoundInt = 17;
   break;
  case "hiccup":
   SoundInt = 18;
   break;
  case "huh":
   SoundInt = 19;
   break;
  case "kiss":
   SoundInt = 20;
   break;
  case "laugh":
   SoundInt = 21;
   break;
  case "no":
   SoundInt = 22;
   break;
  case "oh":
   SoundInt = 23;
   break;
  case "oooh":
   SoundInt = 24;
   break;
  case "oops":
   SoundInt = 25;
   break;
  case "puke":
   SoundInt = 26;
   break;
  case "punch":      
   SoundInt = 27;
   break;
  case "scream":
   SoundInt = 28;
   break;
  case "shush":
   SoundInt = 29;
   break;
  case "sigh":
   SoundInt = 30;
   break;
  case "slap":
   SoundInt = 31;
   break;
  case "sneeze":
   SoundInt = 32;
   break;
  case "sniff":
   SoundInt = 33;
   break;
  case "snore":
   SoundInt = 34;
   break;
  case "spit":
   SoundInt = 35;
   break;
  case "stickouttongue":
   SoundInt = 36;
   break;
  case "tapfoot":
   SoundInt = 37;
   break;
  case "wistle":
   SoundInt = 38;
   break;
  case "woohoo":
   SoundInt = 39;
   break;
  case "yawn":
   SoundInt = 40;
   break;
  case "yea":
   SoundInt = 41;
   break;
  case "yell":
   SoundInt = 42;
   break;    
  default:
   SoundInt = 0;
   e.Mobile.SendGump( new EmoteGump( e.Mobile, EmotePage.P1) );
   break;
 }
 if ( SoundInt > 0 )
  new ESound( pm, SoundInt );
}
}
public class EmoteGump : Gump
{
private Mobile m_From;
private EmotePage m_Page;
private const int Blanco = 0xFFFFFF;
private const int Azul = 0x8080FF;
public void AddPageButton( int x, int y, int buttonID, string text, EmotePage page, params EmotePage[] subpage )
{
 bool seleccionado = ( m_Page == page );
 for ( int i = 0; !seleccionado && i < subpage.Length; ++i )
 seleccionado = ( m_Page == subpage[i] );
 AddButton( x, y - 1, seleccionado ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
 AddHtml( x + 35, y, 200, 20, Color( text, seleccionado ? Azul : Blanco ), false, false );
}
public void AddButtonLabeled( int x, int y, int buttonID, string text )
{
 AddButton( x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
 AddHtml( x + 35, y, 240, 20, Color( text, Blanco ), false, false );
}
public int GetButtonID( int type, int index )
{
 return 1 + (index * 15) + type;
}
public string Color( string text, int color )
{
 return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
public EmoteGump ( Mobile from, EmotePage page) : base ( 600, 50 )
{
 from.CloseGump( typeof( EmoteGump ) );
 m_From = from;
 m_Page = page;
 Closable = true;
 Dragable = true;
 AddPage( 0 );
 AddBackground( 0, 65, 130, 360, 5054);
 AddAlphaRegion( 10, 70, 110, 350 );
 AddImageTiled( 10, 70, 110, 20, 9354);
 AddLabel( 13, 70, 200, "Emote Listesi");
 AddImage( 100, 0, 10410);
 AddImage( 100, 305, 10412);
 AddImage( 100, 150, 10411);
 switch ( page )
 {
  case EmotePage.P1:
  {
   AddButtonLabeled( 10, 90, GetButtonID( 1, 1 ), "Ah");
   AddButtonLabeled( 10, 115, GetButtonID( 1, 2 ), "Ah-ha");
   AddButtonLabeled( 10, 140, GetButtonID( 1, 3 ), "Alkis");
   AddButtonLabeled( 10, 165, GetButtonID( 1, 4 ), "Sümkür");
   AddButtonLabeled( 10, 190, GetButtonID( 1, 5 ), "Egil");
   AddButtonLabeled( 10, 215, GetButtonID( 1, 6 ), "Tikan");
   AddButtonLabeled( 10, 240, GetButtonID( 1, 7 ), "Gegir");
   AddButtonLabeled( 10, 265, GetButtonID( 1, 8 ), "Bogaz Temizle");
   AddButtonLabeled( 10, 290, GetButtonID( 1, 9 ), "Öksür");
   AddButtonLabeled( 10, 315, GetButtonID( 1, 10 ), "Agla");
   AddButtonLabeled( 10, 340, GetButtonID( 1, 11 ), "Bayil");
   AddButtonLabeled( 10, 365, GetButtonID( 1, 12 ), "Osur");
   AddButton( 70, 380, 4502, 0504, GetButtonID( 0,2 ), GumpButtonType.Reply, 0 );
   break;
  }
  case EmotePage.P2:
  {
   AddButtonLabeled( 10, 90, GetButtonID( 1, 13 ), "Solu");
   AddButtonLabeled( 10, 115, GetButtonID( 1, 14 ), "Kikirda");
   AddButtonLabeled( 10, 140, GetButtonID( 1, 15 ), "Inle");
   AddButtonLabeled( 10, 165, GetButtonID( 1, 16 ), "Gürle");
   AddButtonLabeled( 10, 190, GetButtonID( 1, 17 ), "Hey");
   AddButtonLabeled( 10, 215, GetButtonID( 1, 18 ), "Hiçkir");
   AddButtonLabeled( 10, 240, GetButtonID( 1, 19 ), "Huh");
   AddButtonLabeled( 10, 265, GetButtonID( 1, 20 ), "Öpücük");
   AddButtonLabeled( 10, 290, GetButtonID( 1, 21 ), "Kahkaha");
   AddButtonLabeled( 10, 315, GetButtonID( 1, 22 ), "Hayir");
   AddButtonLabeled( 10, 340, GetButtonID( 1, 23 ), "Sasir");
   AddButtonLabeled( 10, 365, GetButtonID( 1, 24 ), "Oooh");
   AddButton( 10, 380, 4506, 4508, GetButtonID( 0,1 ), GumpButtonType.Reply, 0 );
   AddButton( 70, 380, 4502, 0504, GetButtonID( 0,3 ), GumpButtonType.Reply, 0 );
   break;
  }
  case EmotePage.P3:
  {
   AddButtonLabeled( 10, 90, GetButtonID( 1, 25 ), "Özür");
   AddButtonLabeled( 10, 115, GetButtonID( 1, 26 ), "Kus");
   AddButtonLabeled( 10, 140, GetButtonID( 1, 27 ), "Yumruk");
   AddButtonLabeled( 10, 165, GetButtonID( 1, 28 ), "Çiglik");
   AddButtonLabeled( 10, 190, GetButtonID( 1, 29 ), "SUS!");
   AddButtonLabeled( 10, 215, GetButtonID( 1, 30 ), "Iç çek");
   AddButtonLabeled( 10, 240, GetButtonID( 1, 31 ), "Tokat");
   AddButtonLabeled( 10, 265, GetButtonID( 1, 32 ), "Hapsur");
   AddButtonLabeled( 10, 290, GetButtonID( 1, 33 ), "Burun çek");
   AddButtonLabeled( 10, 315, GetButtonID( 1, 34 ), "Horla");
   AddButtonLabeled( 10, 340, GetButtonID( 1, 35 ), "Tükür");
   AddButtonLabeled( 10, 365, GetButtonID( 1, 36 ), "Yapis");
   AddButton( 10, 380, 4506, 4508, GetButtonID( 0,2 ), GumpButtonType.Reply, 0 );
   AddButton( 70, 380, 4502, 0504, GetButtonID( 0,4 ), GumpButtonType.Reply, 0 );
   break;
  }
  case EmotePage.P4:
  {
   AddButtonLabeled( 10, 90, GetButtonID( 1, 37 ), "Çelme tak");
   AddButtonLabeled( 10, 115, GetButtonID( 1, 38 ), "Islik çal");
   AddButtonLabeled( 10, 140, GetButtonID( 1, 39 ), "Woohoo");
   AddButtonLabeled( 10, 165, GetButtonID( 1, 40 ), "Esne");
   AddButtonLabeled( 10, 190, GetButtonID( 1, 41 ), "Yea");
   AddButtonLabeled( 10, 215, GetButtonID( 1, 42 ), "Haykir");
   AddButton( 10, 380, 4506, 4508, GetButtonID( 0,3 ), GumpButtonType.Reply, 0 );
   break;
  }
 }
}
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
 int val = info.ButtonID - 1;
 if ( val < 0 )
 return;

 Mobile from = m_From;
 int type = val % 15;
 int index = val / 15;

 switch ( type )
 {
  case 0:
  {
   EmotePage page;
    switch ( index )
   {
    case 1: page = EmotePage.P1; break;
    case 2: page = EmotePage.P2; break;
    case 3: page = EmotePage.P3; break;
    case 4: page = EmotePage.P4; break;
    default: return;
   }

   from.SendGump( new EmoteGump( from, page) );
   break;
  }
  case 1:
  {
   if ( index > 0 && index < 13 )
   {
    from.SendGump( new EmoteGump( from, EmotePage.P1) );
   }
   else if ( index > 12 && index < 25 )
   {
    from.SendGump( new EmoteGump( from, EmotePage.P2) );
   }
   else if ( index > 24 && index < 37 )
   {
    from.SendGump( new EmoteGump( from, EmotePage.P3) );
   }
   else if ( index > 36 && index < 43 )
   {
    from.SendGump( new EmoteGump( from, EmotePage.P4) );
   }
   new ESound( from, index );
   break;
  }
 }
}
}
public class ItemRemovalTimer : Timer
{
private Item i_item;
public ItemRemovalTimer( Item item ) : base( TimeSpan.FromSeconds( 10.0 ) )
{
 Priority = TimerPriority.OneSecond;
 i_item = item;
}

protected override void OnTick()
{
        if (( i_item != null ) && ( !i_item.Deleted ))
         i_item.Delete();
}
}

public class Puke : Item
{
[Constructable]
public Puke() : base( Utility.RandomList( 0xf3b, 0xf3c ) )
{
 Name = "kusmuk";
 Hue = 0x557;
 Movable = false;

 ItemRemovalTimer thisTimer = new ItemRemovalTimer( this );
 thisTimer.Start();

}

public override void OnSingleClick( Mobile from )
{
 this.LabelTo( from, this.Name );
}

public Puke( Serial serial ) : base( serial )
{
}

public override void Serialize(GenericWriter writer)
{
 base.Serialize( writer );
 writer.Write( (int) 0 );
}

public override void Deserialize(GenericReader reader)
{
 base.Deserialize( reader );
 int version = reader.ReadInt();

 this.Delete(); // none when the world starts
}
}

public class ESound
{
public ESound( Mobile pm, int SoundMade )
{
  if (pm is PlayerMobile)
     {
             if(DateTime.Now < ((PlayerMobile)pm).LastEmoteTime + TimeSpan.FromSeconds(30.0))
             {
                   pm.SendMessage("You must wait at least 30 seconds between emotes");
                   return;
             }

             ((PlayerMobile)pm).LastEmoteTime = DateTime.Now;
     }

 switch( SoundMade )
 {
  case 1:
   pm.PlaySound( pm.Female ? 778 : 1049 );
   pm.Say( "*ahh*" );
   break;
  case 2:
   pm.PlaySound( pm.Female ? 779 : 1050 );
   pm.Say( "*birseyi kesfeder*" );
   break;
  case 3:
   pm.PlaySound( pm.Female ? 780 : 1051 );
   pm.Say( "*alkislar*" );
   break;
  case 4:
   pm.PlaySound( pm.Female ? 781 : 1052 );
   pm.Say( "*sümkürür*" );    
   if ( !pm.Mounted )
    pm.Animate( 34, 5, 1, true, false, 0 );
   break;
  case 5:
   pm.Say( "*saygiyla egilir*" );
   if ( !pm.Mounted )
    pm.Animate( 32, 5, 1, true, false, 0 );
   break;
  case 6:
   pm.PlaySound( pm.Female ? 786 : 1057 );
   pm.Say( "*bogazi tikanir*" );
   break;
  case 7:
   pm.PlaySound( pm.Female ? 782 : 1053 );
   pm.Say( "*gegirir*" );
   if ( !pm.Mounted )
    pm.Animate( 33, 5, 1, true, false, 0 );
   break;
  case 8:
   pm.PlaySound( pm.Female ? 748 : 1055 );
   pm.Say( "*bogazini temizler*" );
   if ( !pm.Mounted )
    pm.Animate( 33, 5, 1, true, false, 0 );
   break;
  case 9:
   pm.PlaySound( pm.Female ? 785 : 1056 );
   pm.Say( "*öksürür*" );    
   if ( !pm.Mounted )
    pm.Animate( 33, 5, 1, true, false, 0 );
   break;
  case 10:
   pm.PlaySound( pm.Female ? 787 : 1058 );
   pm.Say( "*hüngür hüngür aglar*" );
   break;
  case 11:
   pm.PlaySound( pm.Female ? 791 : 1063 );
   pm.Say( "*bayilir*" );
   if ( !pm.Mounted )
    pm.Animate( 22, 5, 1, true, false, 0 );
   break;
  case 12:
   pm.PlaySound( pm.Female ? 792 : 1064 );
   pm.Say( "*çok pis osurur*" );
   break;
  case 13:
   pm.PlaySound( pm.Female ? 793 : 1065 );
   pm.Say( "*nefesi kesilir*" );
   break;
  case 14:
   pm.PlaySound( pm.Female ? 794 : 1066 );
   pm.Say( "*kikir kikir güler*" );
   break;
  case 15:
   pm.PlaySound( pm.Female ? 795 : 1067 );
   pm.Say( "*inler*" );
   break;
  case 16:
   pm.PlaySound( pm.Female ? 796 : 1068 );
   pm.Say( "*ayi gibi gürler*" );
   break;
  case 17:
   pm.PlaySound( pm.Female ? 797 : 1069 );
   pm.Say( "*hey!*" );
   break;
  case 18:
   pm.PlaySound( pm.Female ? 798 : 1070 );
   pm.Say( "*hiçkirik tutar*" );
   break;
  case 19:
   pm.PlaySound( pm.Female ? 799 : 1071 );
   pm.Say( "*söyleneni anlamaz*" );
   break;
  case 20:
   pm.PlaySound( pm.Female ? 800 : 1072 );
   pm.Say( "*öpücük yollar*" );
   break;
  case 21:
   pm.PlaySound( pm.Female ? 801 : 1073 );
   pm.Say( "*kahkahalarla güler*" );
   break;
  case 22:
   pm.PlaySound( pm.Female ? 802 : 1074 );
   pm.Say( "*kabul etmez*" );
   break;
  case 23:
   pm.PlaySound( pm.Female ? 803 : 1075 );
   pm.Say( "*sasirir*" );
   break;
  case 24:
   pm.PlaySound( pm.Female ? 811 : 1085 );
   pm.Say( "*oooh*" );
   break;
  case 25:
   pm.PlaySound( pm.Female ? 812 : 1086 );
   pm.Say( "*özür diler*" );
   break;
  case 26:
   pm.PlaySound( pm.Female ? 813 : 1087 );
   pm.Say( "*kusar*" );
   break;
  case 27:
   pm.PlaySound( 315 );
   pm.Say( "*yumruk atar*" );
   if ( !pm.Mounted )
    pm.Animate( 31, 5, 1, true, false, 0 );
   break;
  case 28:
   pm.PlaySound( pm.Female ? 814 : 1088 );
   pm.Say( "*çiglik atar*" );
   break;
  case 29:
   pm.PlaySound( pm.Female ? 815 : 1089 );
   pm.Say( "*susturur*" );
   break;
  case 30:
   pm.PlaySound( pm.Female ? 816 : 1090 );
   pm.Say( "*iç çeker*" );
   break;
  case 31:
   pm.PlaySound( 948 );
   pm.Say( "*tokatlar*" );
   if ( !pm.Mounted )
    pm.Animate( 11, 5, 1, true, false, 0 );
   break;
  case 32:
   pm.PlaySound( pm.Female ? 817 : 1091 );
   pm.Say( "*hapsurur!*" );
   if ( !pm.Mounted )
    pm.Animate( 32, 5, 1, true, false, 0 );
   break;
  case 33:
   pm.PlaySound( pm.Female ? 818 : 1092 );
   pm.Say( "*burnunu çeker*" );
   if( !pm.Mounted )
    pm.Animate( 34, 5, 1, true, false, 0 );
   break;
  case 34:
   pm.PlaySound( pm.Female ? 819 : 1093 );
   pm.Say( "*horlar*" );
   break;
  case 35:
   pm.PlaySound( pm.Female ? 820 : 1094 );
   pm.Say( "*tükürür*" );
   if ( !pm.Mounted )
    pm.Animate( 6, 5, 1, true, false, 0 );
   break;
  case 36:
   pm.PlaySound( 792 );
   pm.Say( "*bogazina birsey takilir*" );
   break;
  case 37:
   pm.PlaySound( 874 );
   pm.Say( "*çelme takar*" );
   if ( !pm.Mounted )
    pm.Animate( 38, 5, 1, true, false, 0 );
   break;
  case 38:
   pm.PlaySound( pm.Female ? 821 : 1095 );
   pm.Say( "*islik çalar*" );
   if ( !pm.Mounted )
    pm.Animate( 5, 5, 1, true, false, 0 );
   break;
  case 39:
   pm.PlaySound( pm.Female ? 783 : 1054 );
   pm.Say( "*sevinçten dört köse olur*" );
   break;
  case 40:
   pm.PlaySound( pm.Female ? 822 : 1096 );
   pm.Say( "*esner*" );
   if ( !pm.Mounted )
    pm.Animate( 17, 5, 1, true, false, 0 );
   break;
  case 41:
   pm.PlaySound( pm.Female ? 823 : 1097 );
   pm.Say( "*kabul eder*" );
   break;
  case 42:
   pm.PlaySound( pm.Female ? 823 : 1098 );
   pm.Say( "*haykirir*" );
   break;
 }
}
}
}

and with this modif script when they type [e a gump appears and when they click an emote button it always says you must wait..

ArteGordon- 02-02-2006
you can delete this check now since you have added it to the Esound constructor, it is not necessary unless you really want to prevent them from opening the gump again for 30 seconds after they used an emote and closed the gump.

QUOTE

public static void Emote_OnCommand( CommandEventArgs e )
{
Mobile pm = e.Mobile;

  if (pm is PlayerMobile)
    {
            if(DateTime.Now < ((PlayerMobile)pm).LastEmoteTime + TimeSpan.FromSeconds(30.0))
            {
                  pm.SendMessage("You must wait at least 30 seconds between emotes");
                  return;
            }

            ((PlayerMobile)pm).LastEmoteTime = DateTime.Now;
    }

        string em = e.ArgString.Trim();
int SoundInt;


How did you add the LastEmoteTime to the PlayerMobile. Post the actual code that you added.

darkwinters- 02-02-2006
CODE

[CommandProperty( AccessLevel.GameMaster )]
 public bool PublicMyRunUO
 {
  get{ return GetFlag( PlayerFlag.PublicMyRunUO ); }
  set{ SetFlag( PlayerFlag.PublicMyRunUO, value ); InvalidateMyRunUO(); }
 }
 public DateTime LastEmoteTime = DateTime.MinValue;

 public static Direction GetDirection4( Point3D from, Point3D to )
.............

ArteGordon- 02-02-2006
just remove that check in the command method that I mentioned in the previous post. That will add a mandatory 30 second delay between executing the command, and using the gump. Just take out that check and you will be fine.
Leave the check in the ESound constructor.

ArteGordon- 02-03-2006
I have split this into separate threads because it contained multiple topics.