GetStringValue() public static method

Gets the value of a CVariable
public static GetStringValue ( string name ) : string
name string /// Name of the CVariable ///
return string
Beispiel #1
0
        /// <summary>
        /// Returns a list of all valid maps in the mapcycle.
        /// </summary>
        /// <returns>
        /// String array of all map names <see cref="System.String[]"/>
        /// </returns>
        public static string[] LoadMapListFromMapcycle()
        {
            StreamReader  sr   = null;
            List <string> list = new List <string>();

            try {
                string mapcyclefile = Path.Combine(Server.GameDirectory, CVar.GetStringValue("mapcyclefile"));
                sr = new StreamReader(File.Open(mapcyclefile, FileMode.Open));
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();
                    if (line.ToLower().EndsWith(".bsp"))
                    {
                        string map = line.Substring(0, line.Length - 4);
                        if (Server.IsMapValid(map))
                        {
                            list.Add(map);
                        }
                    }
                    else
                    {
                        if (Server.IsMapValid(line))
                        {
                            list.Add(line);
                        }
                    }
                }
                return(list.ToArray());
            } catch {
                try {
                    return(list.ToArray());
                } catch {
                    return(new string[] {});
                }
            } finally {
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }