|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Guest
Posts: n/a
|
Exception:
System.NullReferenceException: Object reference not set to an instance of an object. just when i thought the code was working perfectly, i got the above error from the preceeding crash log :? and here's the code where it originates from. [code:1]public override void OnRemoved( object o ) { m_mob.SendMessage( "The power vanishes..." ); m_mob.EndAction( typeof( InternalTimer ) ); }[/code:1] |
|
|
|
#2 (permalink) |
|
Forum Expert
Join Date: Oct 2003
Location: Spokane Valley, WA
Age: 24
Posts: 1,528
|
Okay your trying to do something to when they equip the item a timer starts and then when they remove it the timer stops?
__________________
Creator of Genesis :: genesisworlds.com -- Genesis is the next replacement program for UO Landscaper & Dragon |
|
|
|
|
|
#4 (permalink) |
|
Forum Expert
Join Date: Oct 2003
Location: Spokane Valley, WA
Age: 24
Posts: 1,528
|
hmm let me think for a min umm try this m_mob.Stop();
if that fails then umm let me think again!
__________________
Creator of Genesis :: genesisworlds.com -- Genesis is the next replacement program for UO Landscaper & Dragon |
|
|
|
|
|
#5 (permalink) |
|
Forum Expert
Join Date: Oct 2003
Location: Spokane Valley, WA
Age: 24
Posts: 1,528
|
Hey post me the whole script and let me see if i can figure it out!
__________________
Creator of Genesis :: genesisworlds.com -- Genesis is the next replacement program for UO Landscaper & Dragon |
|
|
|
|
|
#7 (permalink) | |
|
Account Terminated
|
Quote:
If you don't post the script, don't post in this thread again K? |
|
|
|
|
|
|
#11 (permalink) |
|
just taking a stab at this, I'm a real newbie but...
m_mob doesnt refer to anything in that function, does it? o is the object, so wouldn't you have to refer to it as ((Mobile)parent) ? that is if a mobile is the parent of the item. that would explain why you're getting a null reference exception error, because you're not using the parameter. just guessing. really, don't think I actually know what I'm saying. lol. |
|
|
|
|
|
|
#12 (permalink) |
|
Guest
Posts: n/a
|
[code:1]using Server;
using System; using System.Collections; using Server.Mobiles; namespace Server.Items { public class AntiGravityBoots : Boots { public Mobile m_mob; [Constructable] public AntiGravityBoots() : base( 0x170b ) { Name = "Anti-Gravity Boots"; Hue = 2029; } public override bool OnEquip( Mobile from ) { m_mob = from; from.SendMessage( "You feel a powerful force begin to lift you from the ground!" ); new InternalTimer( from ).Start(); return true; } public override void OnRemoved( object o ) { base.OnRemoved( o ); m_mob.SendMessage( "The power vanishes..." ); InternalTimer( m_mob ).Stop(); } private class InternalTimer : Timer { private Mobile mfrom; private int adr = 0; public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 0.2 ), TimeSpan.FromSeconds( 0.2 ) ) { mfrom = from; } protected override void OnTick() { mfrom.Z++; adr++; if( adr == 30 ) { Stop(); } } } public AntiGravityBoots( 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(); } } }[/code:1] There. that's the entire script, i hope it helps. |
|
|
|
#13 (permalink) |
|
Master of the Internet
Join Date: Aug 2003
Posts: 5,688
|
when you create your timer you need to assign it to a variable like this
[code:1] if(m_internaltimer != null) m_internaltimer.Delete(); m_internaltimer = new InternalTimer( from ); m_internaltimer.Start(); [/code:1] then in your OnRemoved you can do [code:1] if(m_internaltimer != null) m_internaltimer.Stop();[/code:1] and, of course you have to define m_internaltimer up by your m_mob definition. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|