ItsMods

Full Version: [Code] Getting nextmap by custom way
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I just wrote code which will tell you next map!
You can replace GetServerCfg and split char to space if you want to use sv_maprotation var.

It will tell full map name. ( Not mp_dome or mp_alpha etc )

Oh, and remove unsafe if you don't need it.
Code:
public unsafe string GetNextMap()
        {
            ServerPrint("[KillMe V1.0] Getting nextmap..... ");
            string s = GetServerCFG("KillMe", "maprotation", null);

            string nextmap = string.Empty;

            String[] maps = s.Split(new Char[] { ',' });
            for (int i = 0; i < maps.Length; i++)
            {
                // getting current map
                if (maps[i] == GetDvar("mapname"))
                {
                    if (maps.Length >= i + 1)
                    {
                        nextmap = maps[1];
                    }
                    else
                    {
                        nextmap = maps[i + 1];
                    }
                }
            }
            ServerPrint("[KillMe V1.0] Next map is " + nextmap);
            string sortedmapname = nextmap.Substring(3); // skip 'mp_'
            string mapname_prefix = "MPUI_";

            // some maps
            if (sortedmapname == "alpha")
            {
                sortedmapname = "LOCKDOWN"; // we'll get MPUI_LOCKDOWN
            }
    
            string mapname = mapname_prefix + "" + sortedmapname.ToUpper();
            return mapname; // Returns full map name
        }