For some reason it dont let me access the CompletedBy property inside the OnThink method


C#:
 private Mobile m_Player;
  // public Mobile m_CompletedBy;
            public override void OnThink()
            {

base.OnThink();


Map mapa = this.Map;
             if (mapa != null)
            {
         m_Player = this;
Point3D location = this.Location;
                    List<Item> itemsFound = new List<Item>();
                    foreach (Item item in m_Player.Map.GetItemsInRange(location, 0))
                    {
                        if (item is TreasureMap )
                        {        
                         itemsFound.Add(item);

if (item != null && item is TreasureMap && item.m_CompletedBy != null)  //line 1290
{
    Console.WriteLine("item is completedby {0}",item.m_CompletedBy);  //line 1292
 
 

}

                         }
                    }                


            }
            }

Errors



CS1061: Line 1290: 'Server.Item' does not contain a definition for 'Complete
dBy' and no extension method 'CompletedBy' accepting a first argument of type 'S
erver.Item' could be found (are you missing a using directive or an assembly ref
erence?)
CS1061: Line 1292: 'Server.Item' does not contain a definition for 'Complete
dBy' and no extension method 'CompletedBy' accepting a first argument of type 'S
erver.Item' could be found (are you missing a using directive or an assembly ref




inside that npc script, onbeforedeath i got the next method and it let me access completedby property,why?


C#:
objetotreasure ps = new objetotreasure();
objetotreasure.CompletedBy = m;  Console.WriteLine(".CompletedBy {0}  - ",m.Name);
ps.MoveToWorld(this.Location, this.Map);
 
because
C#:
m_CompletedBy

is a private variable, it is locked so to say.
and in your other line where it works, it is using
C#:
CompletedBy

wich is the accessible property
 
because
C#:
m_CompletedBy

is a private variable, it is locked so to say.
and in your other line where it works, it is using
C#:
CompletedBy

wich is the accessible property
hey thanks im still getting some error

C#:
TreasureMap.CompletedBy == m_Player


m_Player refers as ''this'' inside the onthink method not sure if thats the problem, i want to check if the map was completed by that NPC

CS0120: Line 1348: An object reference is required for the non-static field,
method, or property 'Server.Items.TreasureMap.CompletedBy.get'
 
Last edited:
because as the error states, TreasureMap is just the class not a reference to it.

in your first example the reference there was still called item
 
Back