Hello heres the crashlog


System.NullReferenceException: Object reference not set to an instance of an object.
at Server.TimeSystem.Support.GetMapIndex(Object o) in c:\ScriptsSupport.cs:line 611

at Server.TimeSystem.TimeEngine.GetFacetAdjustment(Object o) in c:\Scripts\Engines\TimeEngine.cs:line 121

at Server.TimeSystem.TimeEngine.GetAdjustments(Object o, Boolean useTimeZoneScaling) in c:\Scripts\\Engines\TimeEngine.cs:line 111

at Server.TimeSystem.TimeEngine.CalculateLightLevel(Object o, EffectsObject eo) in c:\Scripts\\Engines\TimeEngine.cs:line 317

at Server.TimeSystem.TimeEngine.CalculateLightLevel(Object o) in c:\Scripts\\Engines\TimeEngine.cs:line 269

at Server.LightCycle.ComputeLevelFor(Mobile from) in c:\Scripts\Misc\LightCycle.cs:line 77
at Server.Mobiles.PlayerMobile.ComputeBaseLightLevels(Int32& global, Int32& personal) in c:\Scripts\Mobiles\PlayerMobile.cs:line 1293

at Server.Mobile.ComputeLightLevels(Int32& global, Int32& personal)
at Server.Mobiles.PlayerMobile.CheckLightLevels(Boolean forceResend) in c:\Scripts\Mobiles\PlayerMobile.cs:line 1333

at Server.TimeSystem.Engine.OnMasterTick() in c:c:\Scripts\\Engine.cs:line 164

at Server.TimeSystem.Engine.TimeSystemTimer.OnTick() in c:\Scripts\CUSTOM\2017\TIMESYSTEM\Engine.cs:line 252

at Server.Timer.Slice()
at Server.Core.Main(String[] args)



Support.cs

Code:
 public static int GetMapIndex(object o)
        {
            int index = -1;

            if (o is Mobile)
            {
                index = ((Mobile)o).Map.MapIndex; //Line 611
            }
            else if (o is Item)
            {
                index = ((Item)o).Map.MapIndex;
            }
            else if (o is Map)
            {
                index = ((Map)o).MapIndex;
            }

            return index;
        }

I post whole TimeEngine.cs sinc the line number may have been changed, i got the crash time ago and i remember i added some lines there

Code:
using System;
using Server;
using Server.Items;

namespace Server.TimeSystem
{
    public class TimeEngine
    {
        #region Get Methods

        private static int GetMinutesAfterNight(int minute, int hour)
        {
            if (hour >= Data.NightStartHour)
            {
                return (hour - Data.NightStartHour) * Data.MinutesPerHour + minute - Data.NightStartMinute;
            }
            else
            {
                return ((Data.HoursPerDay - Data.NightStartHour) + hour) * Data.MinutesPerHour + minute - Data.NightStartMinute;
            }
        }

        private static int GetMinutesAfterDay(int minute, int hour)
        {
            if (hour >= Data.DayStartHour)
            {
                return (hour - Data.DayStartHour) * Data.MinutesPerHour + minute - Data.DayStartMinute;
            }
            else
            {
                return ((Data.HoursPerDay - Data.DayStartHour) + hour) * Data.MinutesPerHour + minute - Data.DayStartMinute;
            }
        }

        private static bool IsNightTime(int minute, int hour)
        {
            if (hour == Data.NightStartHour && minute >= Data.NightStartMinute)
            {
                return true;
            }
            else if (hour > Data.NightStartHour || hour < Data.DayStartHour)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
/////////////BROADCASTS DARKESTHOUR///////////////
public static void Dn()  
         {
        //  World.Broadcast(258, false, "");
        //   World.Broadcast(258, false, "");
      //     World.Broadcast(258, false, "");
        //World.Broadcast(38, false, "");
        }


public static void Bc()  
         {
       //    World.Broadcast(258, false, "");
        //World.Broadcast(38, false, "");
        }


public static void Dia()  
         {
         //    World.Broadcast(258, false, "");
      //     World.Broadcast(258, false, "");
        //World.Broadcast(38, false, "");
        }

//////////////////////////////////////
        public static bool IsNightTime(object o)
        {
            int x = Support.GetXAxis(o);

            int minute, hour;

            GetTimeMinHour(o, x, out minute, out hour);

            return IsNightTime(minute, hour);
        }

        private static bool IsDarkestHour(int minute, int hour)
        {
            int minutesAfterNight = GetMinutesAfterNight(minute, hour);

            if (minutesAfterNight - Data.DarkestHourStartMinutes >= 0)
            {
                return ((minutesAfterNight - Data.DarkestHourStartMinutes) <= Data.DarkestHourTotalMinutes);
            }
            else
            {
                return false;
            }
        }

        private static bool IsDarkestHour(int minute, int hour, EffectsObject eo)
        {
            if (!Data.UseDarkestHour || eo == null || eo.EffectsMap == null || !eo.EffectsMap.UseDarkestHour)
            {
                return false;
            }

            return IsDarkestHour(minute, hour);
        }

        public static bool IsDarkestHour(object o, EffectsObject eo)
        {
            if (!Data.UseDarkestHour || eo == null || eo.EffectsMap == null || !eo.EffectsMap.UseDarkestHour)
            {
                return false;
            }

            int x = Support.GetXAxis(o);

            int minute, hour;

            GetTimeMinHour(o, x, out minute, out hour);

            return IsDarkestHour(minute, hour);
        }

        public static int GetAdjustments(object o, bool useTimeZoneScaling)
        {
            int x = Support.GetXAxis(o);

            if (x == -1)
            {
                x = 0;
            }

            return GetFacetAdjustment(o) + GetTimeZoneAdjustment(x, useTimeZoneScaling);
        }

        public static int GetAdjustments(object o, int x)
        {
            return GetFacetAdjustment(o) + GetTimeZoneAdjustment(x, Data.UseTimeZones);
        }

        public static int GetFacetAdjustment(object o)
        {
            int index = Support.GetMapIndex(o);

            if (index > -1)
            {
                FacetPropsObject fpo = Data.FacetArray[index];

                return fpo.Adjustment;
            }
            else
            {
                return 0;
            }
        }

        public static int GetTimeZoneAdjustment(int x, bool useTimeZoneScaling)
        {
            if (Data.UseTimeZones)
            {
                if (useTimeZoneScaling)
                {
                    return Support.GetWholeNumber(Support.GetWholeNumber(x, Data.TimeZoneXDivisor, true), Data.TimeZoneScaleMinutes, true) * Data.TimeZoneScaleMinutes;
                }
                else
                {
                    return Support.GetWholeNumber(x, Data.TimeZoneXDivisor, true);
                }
            }
            else
            {
                return 0;
            }
        }

        public static void GetTimeMinHour(object o, int x, out int minute, out int hour)
        {
            minute = Data.Minute + GetAdjustments(o, x);
            hour = Data.Hour;
            int day = Data.Day;
            int month = Data.Month;
            int year = Data.Year;

            CheckTime(ref minute, ref hour, ref day, ref month, ref year, false);
        }

        public static void GetTimeMonthDay(object o, int x, out int month, out int day)
        {
            int minute = Data.Minute + GetAdjustments(o, x);
            int hour = Data.Hour;
            day = Data.Day;
            month = Data.Month;
            int year = Data.Year;

            CheckTime(ref minute, ref hour, ref day, ref month, ref year, false);
        }

        #endregion

        #region Check Methods

        public static void CheckTime(ref int minute, ref int hour, ref int day, ref int month, ref int year, bool checkMoonPhaseDay)
        {
            int totalMonths = Data.MonthsArray.Count;

            MonthPropsObject mpo = Data.MonthsArray[month - 1];

            int totalDays = mpo.TotalDays;

            if (minute >= Data.MinutesPerHour)
            {
                int amountOver = Support.GetWholeNumber(minute, Data.MinutesPerHour, true);
                int leftOver = amountOver * Data.MinutesPerHour;

                minute -= leftOver;
                hour += amountOver;
            }

            if (hour >= Data.HoursPerDay)
            {
                int amountOver = Support.GetWholeNumber(hour, Data.HoursPerDay, true);
                int leftOver = amountOver * Data.HoursPerDay;

                hour -= leftOver;
                day += amountOver;
            }

            while (day > totalDays)
            {
                day -= totalDays;

                month++;

                if (month > totalMonths)
                {
                    month -= totalMonths;

                    year++;
                }

                mpo = Data.MonthsArray[month - 1];

                totalDays = mpo.TotalDays;
            }

            if (checkMoonPhaseDay)
            {
                if (hour == Data.NightStartHour && minute == Data.NightStartMinute)
                {
                    MoonEngine.IncrementMoonDay(1, day);
                }
            }
        }

        #endregion

        #region Calculation Methods

        public static void CalculateBaseTime()
        {
            if (Data.UseRealTime)
            {
                Data.Minute = DateTime.Now.Minute;
                Data.Hour = DateTime.Now.Hour;
                Data.Day = DateTime.Now.Day;
                Data.Month = DateTime.Now.Month;
                Data.Year = DateTime.Now.Year;
            }
            else
            {
                int minute = Data.Minute;
                int hour = Data.Hour;
                int day = Data.Day;
                int month = Data.Month;
                int year = Data.Year;

                minute += Data.MinutesPerTick;

                CheckTime(ref minute, ref hour, ref day, ref month, ref year, true);

                Data.Minute = minute;
                Data.Hour = hour;
                Data.Day = day;
                Data.Month = month;
                Data.Year = year;
            }
        }

        public static int CalculateLightLevel(object o)
        {
            return CalculateLightLevel(o, null);
        }

        public static int CalculateLightLevel(object o, EffectsObject eo)
        {
            if (!Data.Enabled)
            {
                return Data.DayLevel;
            }

            MobileObject mo = null;

            if (o is Mobile)
            {
                mo = Support.GetMobileObject((Mobile)o);

                if (mo != null)
                {
                    if (DateTime.Now - mo.UpdateTimeStamp < TimeSpan.FromMilliseconds(Data.UpdateInterval))
                    {
                        return mo.LightLevel;
                    }

                    mo.IsDarkestHour = false;
                }
                else
                {
                    return Data.DayLevel;
                }
            }

            if (o != null && eo == null)
            {
                eo = EffectsEngine.GetEffects(o, false);
            }

            int currentLevel = Data.BaseLightLevel;

            if (Data.UseLightLevelOverride && eo != null && eo.EffectsMap != null && eo.EffectsMap.UseLightLevelOverride)
            {
                currentLevel = eo.EffectsMap.LightLevelOverrideAdjust;
            }
            else
            {
                int nightLevelAdjust = MoonEngine.GetNightLevelAdjust();

                int x = Support.GetXAxis(o);

                int minute = Data.Minute + GetAdjustments(o, o is Mobile ? false : Data.UseTimeZones);
                int hour = Data.Hour;
                int day = Data.Day;
                int month = Data.Month;
                int year = Data.Year;

                if (o != null)
                {
                    CheckTime(ref minute, ref hour, ref day, ref month, ref year, false);
                }

                if (IsNightTime(minute, hour)) // Night time.
                {
                    bool isDarkestHour = IsDarkestHour(minute, hour, eo);

                    if (mo != null)
                    {
                        mo.IsDarkestHour = isDarkestHour;
                        // Timer.DelayCall( TimeSpan.FromMinutes( 5.0 ), Dn);
                    
                        //World.Broadcast(258, false, "");
                    }

                    int minutesAfterNight = GetMinutesAfterNight(minute, hour);

                    if (Data.ScaleTimeMinutes - minutesAfterNight >= 0)
                    {
                        currentLevel = (int)(nightLevelAdjust * ((double)minutesAfterNight / (double)Data.ScaleTimeMinutes));
                    }
                    else if (isDarkestHour)
                    {
                        if (o is BaseLight)
                        {
                            LightsEngine.CalculateLightOutage((BaseLight)o, eo);
                        }

                        int bonus = 0;

                        if (mo != null && eo != null && eo.EffectsMap != null)
                        {
                            if (Data.UseMurdererDarkestHourBonus && eo.EffectsMap.UseMurdererDarkestHourBonus && mo.IsMurderer)
                            {
                                bonus = eo.EffectsMap.MurdererDarkestHourLevelBonus;
                                // Timer.DelayCall( TimeSpan.FromMinutes( 5.0 ), Bc);
                                //World.Broadcast(258, false, ".");
                            //    World.Broadcast(258, false, ".");
                            }
                        }

                        int minutesAfterDarkestHour = minutesAfterNight - Data.DarkestHourStartMinutes;

                        if (minutesAfterDarkestHour <= Data.DarkestHourScaleTimeMinutes)
                        {
                            currentLevel = (int)(nightLevelAdjust + ((Data.DarkestHourLevel - bonus - nightLevelAdjust) * ((double)minutesAfterDarkestHour / (double)Data.DarkestHourScaleTimeMinutes)));
                        }
                        else if (minutesAfterDarkestHour > Data.DarkestHourScaleTimeMinutes && minutesAfterDarkestHour <= (Data.DarkestHourLength + Data.DarkestHourScaleTimeMinutes))
                        {
                            currentLevel = Data.DarkestHourLevel - bonus;
                        }
                        else if (minutesAfterDarkestHour > (Data.DarkestHourLength + Data.DarkestHourScaleTimeMinutes) && minutesAfterDarkestHour <= Data.DarkestHourTotalMinutes)
                        {
                            currentLevel = (int)(nightLevelAdjust + ((Data.DarkestHourLevel - bonus - nightLevelAdjust) * ((double)(Data.DarkestHourTotalMinutes - minutesAfterDarkestHour) / (double)Data.DarkestHourScaleTimeMinutes)));
                        }
                    }
                    else
                    {
                        currentLevel = nightLevelAdjust;
                    }

                    if (o is BaseLight && !isDarkestHour)
                    {
                        LightsEngine.UpdateManagedLight((BaseLight)o, currentLevel);
                    }
                }
                else // Day time.
                {
                    int minutesAfterDay = GetMinutesAfterDay(minute, hour);

                    if (Data.ScaleTimeMinutes - minutesAfterDay >= 0)
                    {
                        currentLevel = (int)((nightLevelAdjust - Data.DayLevel) - ((nightLevelAdjust - Data.DayLevel) * ((double)minutesAfterDay / (double)Data.ScaleTimeMinutes)));
                    //    World.Broadcast(258, false, "[EVENTO] El sol comienza a elevarse, la oscuridad es cada vez menor y tu sensacion de seguridad aumenta");
                    // Timer.DelayCall( TimeSpan.FromMinutes( 5.0 ), Dia);
                    }
                    else
                    {
                        currentLevel = Data.DayLevel;
                    }

                    if (o is BaseLight)
                    {
                        LightsEngine.UpdateManagedLight((BaseLight)o, currentLevel);
                    }
                }
            }

            if(currentLevel > Data.MaxLightLevel)
            {
                currentLevel = Data.MaxLightLevel;
            }
            else if(currentLevel < Data.MinLightLevel)
            {
                currentLevel = Data.MinLightLevel;
            }

            if (o == null)
            {
                Data.BaseLightLevel = currentLevel;
            }
            else if (o is Mobile)
            {
                if (mo != null)
                {
                    mo.UpdateTimeStamp = DateTime.Now;

                    mo.LightLevel = currentLevel;

                    EffectsEngine.CheckEffects(mo, eo, true, true);
                }
            }

            return currentLevel;
        }

        #endregion
    }
}

LightCycle.cs

Code:
    public static int ComputeLevelFor( Mobile from )
{
    if ( m_LevelOverride > int.MinValue )
        return m_LevelOverride;

// ** EDIT ** Time System

    return TimeSystem.TimeEngine.CalculateLightLevel(from);  //Line 77

    /*
    int hours, minutes;

    Server.Items.Clock.GetTime( from.Map, from.X, from.Y, out hours, out minutes );

    // OSI times:
     *
     * Midnight ->  3:59 AM : Night
     *  4:00 AM -> 11:59 PM : Day
     *
     * RunUO times:
     *
     * 10:00 PM -> 11:59 PM : Scale to night
     * Midnight ->  3:59 AM : Night
     *  4:00 AM ->  5:59 AM : Scale to day
     *  6:00 AM ->  9:59 PM : Day
     //

    if ( hours < 4 )
        return NightLevel;

    if ( hours < 6 )
        return NightLevel + (((((hours - 4) * 60) + minutes) * (DayLevel - NightLevel)) / 120);

    if ( hours < 22 )
        return DayLevel;

    if ( hours < 24 )
        return DayLevel + (((((hours - 22) * 60) + minutes) * (NightLevel - DayLevel)) / 120);

    return NightLevel; // should never be
    */

// ** END *** Time System

}

Again, my playermobile got edited so i post the few methods related to lightlevel

PlayerMobile.cs

Code:
        private int m_LastGlobalLight = -1, m_LastPersonalLight = -1;

        public override void OnNetStateChanged()
        {
            m_LastGlobalLight = -1;
            m_LastPersonalLight = -1;
        }

        public override void ComputeBaseLightLevels( out int global, out int personal )
{
    global = LightCycle.ComputeLevelFor( this );

// ** EDIT ** Time System

    /*if ( this.LightLevel < 21 && AosAttributes.GetValue( this, AosAttribute.NightSight ) > 0 )
        personal = 21;
    else
        personal = this.LightLevel;*/

    if (this.LightLevel < 21 && AosAttributes.GetValue(this, AosAttribute.NightSight) > 0)
    {
        int level = TimeSystem.EffectsEngine.GetNightSightLevel(this, 21);

        if (level > -1)
        {
            personal = level;
        }
        else
        {
            personal = 0;
        }
    }
    else
    {
        personal = this.LightLevel;
    }

// ** END *** Time System

}

        public override void CheckLightLevels( bool forceResend )
        {
            NetState ns = NetState;

            if ( ns == null )
                return;

            int global, personal;

            ComputeLightLevels( out global, out personal );

            if ( !forceResend )
                forceResend = ( global != m_LastGlobalLight || personal != m_LastPersonalLight );

            if ( !forceResend )
                return;

            m_LastGlobalLight = global;
            m_LastPersonalLight = personal;

            ns.Send( GlobalLightLevel.Instantiate( global ) );
            ns.Send( new PersonalLightLevel( this, personal ) );
        }

        public override int GetMinResistance( ResistanceType type )
        {
            int magicResist = (int)(Skills[SkillName.MagicResist].Value * 10);
            int min = int.MinValue;

            if ( magicResist >= 1000 )
                min = 40 + ((magicResist - 1000) / 50);
            else if ( magicResist >= 400 )
                min = (magicResist - 400) / 15;

            if ( min > MaxPlayerResistance )
                min = MaxPlayerResistance;

            int baseMin = base.GetMinResistance( type );

            if ( min < baseMin )
                min = baseMin;

            return min;
        }

Engine.cs

Code:
  private class TimeSystemTimer : Timer
        {
            public TimeSystemTimer()
                : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(Data.TimerSpeed))
            {
            }

            protected override void OnTick()
            {
                OnMasterTick();  //Line 252
            }
        }


Well i hope someone can help me find the null reference, the crash got me worried it happened many times already

Im not pretty sure but i think the crash happens when player is teleporting to another facet (And it almost never happens)
so its probably has to do with readjusting the lightlevel or something like that :S

thanks!!
 
Last edited:
if u have custom maps, neeed add their map index to Map.cs

Code:
        public static Map Felucca { get { return m_Maps[0]; } }
        public static Map Trammel { get { return m_Maps[1]; } }
        public static Map Ilshenar { get { return m_Maps[2]; } }
        public static Map Malas { get { return m_Maps[3]; } }
        public static Map Tokuno { get { return m_Maps[4]; } }
        public static Map TerMur { get { return m_Maps[5]; } }
        public static Map Internal { get { return m_Maps[0x7F]; } }

try check map for null reference:
Code:
if  ( ((Mobile)o).Map != null)
index =((Mobile)o).Map.MapIndex;
else
{
Console.WriteLine("Checked mobile with nulled map {0}", Mobile.ToString());
return index;
}
 
Thanks for your help @Juzzver , i dont have any custom map, the default ones is what i have: Felucca,Trammel,Ilshenar,Malas and Tokuno.

will add that null check and see if it keep crashing


best regards

Edit: server starts and crash since i added that null check: the line is the 609


Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.TimeSystem.Support.GetMapIndex(Object o) in c:\Scripts\CUSTOM\2017\TIMESYSTEM SERVUO\Support.cs:line 609
at Server.TimeSystem.TimeEngine.GetFacetAdjustment(Object o) in c:c:\Scripts\CUSTOM\2017\TIMESYSTEM SERVUO\Engines\TimeEngine.cs:line 145
at Server.TimeSystem.TimeEngine.GetAdjustments(Object o, Boolean useTimeZoneScaling) in c:\c:\Scripts\CUSTOM\2017\TIMESYSTEM SERVUO\Engines\TimeEngine.cs:line 135

at Server.TimeSystem.Formatting.GetTimeFormat(Object o, Format format, Boolean useTimeZoneScaling) in c:c:\Scripts\CUSTOM\2017\TIMESYSTEM SERVUO\Formatting.cs:line 37

at Server.TimeSystem.Formatting.GetTimeFormat(Object o, Format format) in c:\c:\Scripts\CUSTOM\2017\TIMESYSTEM SERVUO\Formatting.cs:line 32
at Server.TimeSystem.Engine.InitializeSystem() in c:c:\Scripts\CUSTOM\2017\TIMESYSTEM SERVUO\Engine.cs:line 57
at Server.TimeSystem.Engine.DelayedInitializationTimer.OnTick() in c:c:\Scripts\CUSTOM\2017\TIMESYSTEM SERVUO\Engine.cs:line 187
at Server.Timer.Slice()
at Server.Core.Main(String[] args)


This how the GetMapIndex looks:

Code:
  public static int GetMapIndex(object o)
        {
            int index = -1;

             if  ( ((Mobile)o).Map != null)  //if (o is Mobile)
            {
                index = ((Mobile)o).Map.MapIndex;
            }
            else if (o is Item)
            {
                index = ((Item)o).Map.MapIndex;
            }
            else if (o is Map)
            {
                index = ((Map)o).MapIndex;
            }
           Console.WriteLine("Checked mobile with nulled map {0}", ((Mobile)o).ToString());
            return index;
        }

Changed Mobile.ToString to ((Mobile)o).ToString()) because it was telling me ''an object reference is required...''

EDIT2: Removed the console line also changed:

if ( ((Mobile)o).Map != null)
to
if ((o is Mobile) && ((Mobile)o).Map != null)

And it doesnt crash on startup anymore, still need to see if the random crash keeps happening or not
 
Last edited:
Hi there !

Here is how I would write the code around line 611 :

Code:
if (o is Mobile)
    {
        if (((Mobile)o).Map != null && ((Mobile)o).Map.MapIndex != null)
            index = ((Mobile)o).Map.MapIndex; //Line 611
    }

I think it should avoid the crash when the object is a Mobile.
But you might check for Item and Map too.

Hopefully this helps ;)

btw, in the change you made just above, you removed the condition where it checks if it's a mobile. It's probably why it crashes (for a different reason).
Good luck !
 
Hi there !

Here is how I would write the code around line 611 :

Code:
if (o is Mobile)
    {
        if (((Mobile)o).Map != null && ((Mobile)o).Map.MapIndex != null)
            index = ((Mobile)o).Map.MapIndex; //Line 611
    }

I think it should avoid the crash when the object is a Mobile.
But you might check for Item and Map too.

Hopefully this helps ;)

btw, in the change you made just above, you removed the condition where it checks if it's a mobile. It's probably why it crashes (for a different reason).
Good luck !

Hello renak, thanks for your help and yes if you check my last edit thats what i just did :D we post at same time.

It have never crashed for Item and Map if i recall good should i add those null checks there too?
 
lol ! Awesome ! I didn't see the edit, but it seems we are on the same page ;)

I guess you'll know in the crash logs, if it crashes for items and maps. Hopefully not !
But yeah, there are potential null pointers there too ...
 
ah nvm my edit was different, cant add the nullcheck to the map one

Code:
        public static int GetMapIndex(object o)
        {
            int index = -1;
         if (o is Mobile)
         {
        if (((Mobile)o).Map != null && ((Mobile)o).Map.MapIndex != null)
            {
           
                index = ((Mobile)o).Map.MapIndex;
            }
           }
            else if (o is Item)
            {
                 if (((Item)o).Map != null && ((Item)o).Map.MapIndex != null)
                 {
               
                index = ((Item)o).Map.MapIndex;
            }
            }
            else if (o is Map)
            {
                 if (((Map)o).Map != null && ((Map)o).Map.MapIndex != null)
                 {
               
                index = ((Map)o).MapIndex;
            }
            }
         
            return index;
        }


CS1061: Line 626: 'Server.Map' does not contain a definition for 'Map' and n
o extension method 'Map' accepting a first argument of type 'Server.Map' could b
e found (are you missing a using directive or an assembly reference?)
CS1061: Line 626: 'Server.Map' does not contain a definition for 'Map' and n
o extension method 'Map' accepting a first argument of type 'Server.Map' could b

e found (are you missing a using directive or an assembly reference?)

what reference could i be missing?

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using Server;
using Server.Accounting;
using Server.Commands;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Targeting;
 
Can you try this bit of code ?

Code:
    public static int GetMapIndex(object o)
        {
            int index = -1;

			if((o is Mobile) && ((Mobile)o).Map!=null && ((Mobile)o).Map.MapIndex!=null)
            {
           
                index = ((Mobile)o).Map.MapIndex;
            }
            else if ((o is Item) && ((Item)o).Map != null) && ((Item)o).Map.MapIndex != null)
            {
         
                index = ((Item)o).Map.MapIndex;
            }
            else if ((o is Map) && ((Map)o).MapIndex != null)
            {
     
                index = ((Map)o).MapIndex;
            }
     
            return index;
        }

You were trying to do "Map.Map" ^^
 
Thankssss that one compile yes. theres a '')'' in
Code:
 else if ((o is Item) && ((Item)o).Map != null) && ((Item)o).Map.MapIndex != null)
that shouldnt be there hehe

Hopefully it stops crashing, thanks for your time @Regnak
 
lol ! indeed ! nice catch ! I wrote it in notepad and didn't double check. :p

You're welcome !

Keep us updated ;)
 
Back