Exemple #1
0
        /// <summary>
        /// Creates a new <see cref="ConVar"/> or returns the existing one if one with the same name already exists.
        /// </summary>
        /// <param name="plugin">The plugin creating the variable.</param>
        /// <param name="name">The name of the variable.</param>
        /// <param name="defaultValue">The default value of the variable as a string.</param>
        /// <param name="description">Optional description for the variable.</param>
        /// <param name="hasMin">Optional value indicating whether the variable has a minimum value.</param>
        /// <param name="min">The minimum value of the variable if <paramref name="hasMin"/> is <c>true</c>.</param>
        /// <param name="hasMax">Optional value indicating whether the variable has a maximum value.</param>
        /// <param name="max">The maximum value of the variable if <paramref name="hasMax"/> is <c>true</c>.</param>
        /// <returns>The <see cref="ConVar"/> object representing the console variable.</returns>
        public static ConVar CreateConVar(IPlugin plugin, string name, string defaultValue, string description = "", bool hasMin = false, float min = 0.0f, bool hasMax = false, float max = 1.0f)
        {
            name = name.Trim();
            var key = name.ToLower();

            if (!conVars.ContainsKey(key))
            {
                conVars[key]          = new ConVar(plugin, name, defaultValue, description, hasMin, min, hasMax, max);
                pluginReferences[key] = new HashSet <IPlugin>();
            }

            if (plugin != null)
            {
                pluginReferences[key].Add(plugin);
            }

            return(conVars[key]);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConVarChangedEventArgs"/> class.
 /// </summary>
 /// <param name="conVar">The <see cref="SevenMod.ConVar.ConVar"/> object that raised the event.</param>
 /// <param name="oldValue">The old value of the variable as a string.</param>
 /// <param name="newValue">The new value of the variable as a string.</param>
 internal ConVarChangedEventArgs(ConVar conVar, string oldValue, string newValue)
 {
     this.ConVar   = conVar;
     this.OldValue = oldValue;
     this.NewValue = newValue;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConVarValue"/> class.
 /// </summary>
 /// <param name="conVar">The <see cref="SevenMod.ConVar.ConVar"/> object containing this value.</param>
 /// <param name="value">The initial value as a string.</param>
 internal ConVarValue(ConVar conVar, string value)
 {
     this.ConVar   = conVar;
     this.AsString = value;
 }