daat99 said:You too don't have OnThink method that accept a mobile as an argument:
Code:public virtual void OnThink()
Ok I'm going to tell you 1 last time and then if you ask again I'm just ignoring you.Galfaroth said:So backing to topic, is there way to make it work with basevendor?
Galfaroth said:OK Packer, your idea:
Code:public override void OnThink( Mobile from ) { if ( from is PlayerMobile ) { PlayerMobile pm = (PlayerMobile)from; if ( 0 < DateTime.Compare( DateTime.Now, m_NextSpeakTime && from.InRange( this, 4 ) ) { Say( m_Phrases[Utility.Random( m_Phrases.Length )] ); m_NextSpeakTime = DateTime.Now + ( TimeSpan.FromSeconds( 10 ) ); } } base.OnThink(); }
Cause the error:
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
- Error: Scripts\Mobiles\Vendors\BaseVendor.cs: CS0115: (line 241, column 24) '
Server.Mobiles.BaseVendor.OnThink(Server.Mobile)': no suitable method found to o
verride
It is the best, but not work correctly
Are you reading my messages at all???Galfaroth said:As you see OnThink in BaseVendor.cs doesn't compile, cause OnThink hasn't Mobile argument.
daat99 said:There's no OnThink method that accept a mobile as an argument.Code:public override void OnThink([COLOR="Blue"] Mobile from [/COLOR])
Either create a method that accept a mobile as an argument or use the method that is already there.
Galfaroth said:I know there is no, but OnThink is the best method that can be used here... Using method that is already there (to add lines to all vendors) will take ages (I have 122 vendors), so I want to use global (basevendor.cs) method, but as I can see it isn't posiible, is it?
Now you reading this or you just going to paste it again and ignore it???daat99 said:Either create a method that accept a mobile as an argument or use the method that is already there.
public virtual void OnThink()
{
foreach ( Mobile m in [COLOR="Red"]World.Mobiles[/COLOR] ) //[COLOR="Red"]<--- This part is suspect. May need to be reworded.[/COLOR]
{
if ( m is PlayerMobile )
{
PlayerMobile pm = (PlayerMobile)m;
if ( DateTime.Now >= m_NextSpeakTime && pm.InRange( this, 4 ) )
{
switch ( Utility.Random( 6 ) )
{
case 0: Say("Ludzie zawsze gadaja..."); break;
case 1: Say("Nie powinnismy o tym mowic."); break;
case 2: Say("Krol Rhobar jest chyba najlepszym wladca ktorego mielismy."); break;
case 3: Say("Nie, nie.."); break;
case 4: Say("No tak... to prawda."); break;
case 5: Say("Moze pogodzimy ich ze soba..."); break;
};
m_NextSpeakTime = (DateTime.Now + TimeSpan.FromSeconds( 10 ));
}
}
}
base.OnThink();
}
rsmiller21 said:Packer
Ok, here we are. This snippet will respond to vendors and players. You can add more sayings by changing the Random number and adding more cases. This has been tested and works. Just throw it into and vendor, not basevendor:
Code:private DateTime m_NextTalk; private string m_name; public DateTime NextTalk{ get{ return m_NextTalk; } set{ m_NextTalk = value; } } public override void OnMovement( Mobile m, Point3D oldLocation ) { if( m is BaseVendor ) { if ( DateTime.Now >= m_NextTalk && InRange( m, 4 ) && InLOS( m ) ) // check if it's time to talk & if mobile in range & in los. { m_name = m.Name; switch ( Utility.Random( 4 )) //the amount of lines you have it to choose from { [COLOR="Red"]case 0:[/COLOR] Say(m_name + ", how are you doing today?"); break; //line 1 [COLOR="Red"]case 1:[/COLOR] Say("I hate that guy don't you " + m_name + " ?"); break; //line 2 [COLOR="Red"]case 3:[/COLOR] Say("I wonder what I am going to have for dinner."); break; //line 3 }; m_NextTalk = (DateTime.Now + TimeSpan.FromSeconds( 10 )); //channge the number 10 to the min amount of seconds to wait between talks. } } if( m is PlayerMobile ) { if ( DateTime.Now >= m_NextTalk && InRange( m, 4 ) && InLOS( m ) ) // check if it's time to talk & if mobile in range & in los. { m_name = m.Name; switch ( Utility.Random( 4 )) //the amount of lines you have it to choose from { [COLOR="Red"]case 0:[/COLOR] Say(m_name + ", how are you doing today?"); break; //line 1 [COLOR="Red"]case 1:[/COLOR] Say("What can I do for you " + m_name + " ?"); break; //line 2 [COLOR="Red"]case 3:[/COLOR] Say("I wonder what I am going to have for dinner."); break; //line 3 }; m_NextTalk = (DateTime.Now + TimeSpan.FromSeconds( 10 )); //channge the number 10 to the min amount of seconds to wait between talks. } } }
This however, should work the way you want regardless if anyone is present. The only trigger is the movement. This code is tested and works as well:
}Code:private DateTime m_NextTalk; private string m_name; public DateTime NextTalk{ get{ return m_NextTalk; } set{ m_NextTalk = value; } } public override void OnMovement( Mobile m, Point3D oldLocation ) { if( m is BaseVendor ) { if ( DateTime.Now >= m_NextTalk && InRange( m, 500 ) ) // check if it's time to talk & if mobile in range & in los. { m_name = m.Name; switch ( Utility.Random( 8 )) //the amount of lines you have it to choose from { [COLOR="Red"]case 0:[/COLOR] Say(m_name + ", how are you doing today?"); break; //line 1 [COLOR="Red"]case 1:[/COLOR] Say("I hate that guy don't you " + m_name + " ?"); break; //line 2 [COLOR="Red"]case 3:[/COLOR] Say("I wonder what I am going to have for dinner."); break; //line 3 }; m_NextTalk = (DateTime.Now + TimeSpan.FromSeconds( 10 )); //channge the number 10 to the min amount of seconds to wait between talks. } }
switch ( Utility.Random( 8 ))
Aeolus first I like to say welcome to RunUO.Aeolus said:Very helpful- thank you!
World.Mobiles.ValuesPacker898 said:Might try this or something similiar. I dont think the line I marked is the right call there maybe someone else can clarify that =)-
Code:public virtual void OnThink() { foreach ( Mobile m in [COLOR=red]World.Mobiles[/COLOR] ) //[COLOR=red]<--- This part is suspect. May need to be reworded.[/COLOR] { if ( m is PlayerMobile ) { PlayerMobile pm = (PlayerMobile)m; if ( DateTime.Now >= m_NextSpeakTime && pm.InRange( this, 4 ) ) { switch ( Utility.Random( 6 ) ) { case 0: Say("Ludzie zawsze gadaja..."); break; case 1: Say("Nie powinnismy o tym mowic."); break; case 2: Say("Krol Rhobar jest chyba najlepszym wladca ktorego mielismy."); break; case 3: Say("Nie, nie.."); break; case 4: Say("No tak... to prawda."); break; case 5: Say("Moze pogodzimy ich ze soba..."); break; }; m_NextSpeakTime = (DateTime.Now + TimeSpan.FromSeconds( 10 )); } } } base.OnThink(); }