Exemplo n.º 1
0
        /// <summary>
        /// Prints a structure´s parameters to the console.
        /// </summary>
        /// <param name="parameters">The console input.</param>
        private void printStructureParams_console(ParameterCollection parameters)
        {
            if (parameters.Count == 0)
            {
                Game.Console.Print("usage: si_printparams <structure name>");
                return;
            }

            string structName = parameters.ToString(0);

            CEditableStruct tempStruct = GlobalVars.Structures.Find(x => x.Name == structName);

            if (tempStruct == null)
            {
                Game.Console.Print("No struct found with name \"" + structName + "\"!");
                return;
            }

            Game.Console.Print("Listing parameters for structure \"" + structName + "\":");

            SParameter tempParameter = new SParameter();

            for (int i = 0; i < tempStruct.NumParams; i++)
            {
                tempStruct.GetGenericParamByIndex(i, out tempParameter);
                Game.Console.Print(tempParameter.ParamName.ToString() + "  " + "0x" + String.Format("{0:X}", tempParameter.Offset) + "  " + tempParameter.Type.ToString() + "  " + tempParameter.MinVal.ToString() + "  " + tempParameter.MaxVal.ToString());
            }
        }
Exemplo n.º 2
0
        private void getParamName_scriptCmd(GTA.Script sender, GTA.ObjectCollection parameters)
        {
            // si_getparamnum <call identifier> <structure name> <param index>
            if (parameters.Count < 3)
            {
                // Error code -1: invalid parameter count
                SendScriptCommand(sender, "si_getparamname_response", parameters[0], 1);
                return;
            }

            string structName = parameters.Convert <string>(1);

            CEditableStruct tempStruct = GlobalVars.Structures.Find(x => x.Name == structName);

            if (tempStruct == null)
            {
                // Error code -3: invalid struct name
                SendScriptCommand(sender, "si_getparamname_response", parameters[0], 3);
                return;
            }

            int paramIndex = parameters.Convert <int>(2);

            if (paramIndex < 0 || paramIndex >= tempStruct.NumParams)
            {
                // Error code -4: invalid parameter index
                SendScriptCommand(sender, "si_getparamname_response", parameters[0], 4);
            }

            SParameter tempParameter = new SParameter();

            tempStruct.GetGenericParamByIndex(paramIndex, out tempParameter);

            SendScriptCommand(sender, "si_getelementsnum_response", parameters[0], tempParameter.ParamName);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a parameter's value.
        /// </summary>
        /// <param name="index">The parameter's index.</param>
        /// <returns>A string representing the parameter's value.</returns>
        private string getParamValue(int index)
        {
            SParameter      tempParam  = new SParameter();
            CEditableStruct tempStruct = GlobalVars.Structures[this.currentStructIndex];

            tempStruct.GetGenericParamByIndex(index, out tempParam);

            if (tempParam.Type == typeof(float))
            {
                float value = 0f;

                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value.ToString());
            }
            else if (tempParam.Type == typeof(string))
            {
                string value = string.Empty;
                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value);
            }
            else if (tempParam.Type == typeof(char))
            {
                char value = '\0';
                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value.ToString());
            }
            else if (tempParam.Type == typeof(int))
            {
                int value = 0;
                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value.ToString());
            }
            else if (tempParam.Type == typeof(uint))
            {
                uint value = 0;
                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value.ToString());
            }
            else if (tempParam.Type == typeof(short))
            {
                short value = 0;
                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value.ToString());
            }
            else if (tempParam.Type == typeof(double))
            {
                double value = 0f;
                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value.ToString());
            }
            else if (tempParam.Type == typeof(long))
            {
                long value = 0;
                tempStruct.GetParamValue(this.currentElementIndex, index, ref value);
                return(value.ToString());
            }

            return(string.Empty);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Prints a structure´s parameter values to the console.
        /// </summary>
        /// <param name="parameters">The console input.</param>
        private void printStructureValues_console(ParameterCollection parameters)
        {
            if (parameters.Count < 2)
            {
                Game.Console.Print("usage: si_printvalues <structure name> <element index>");
                return;
            }

            string structName = parameters.ToString(0);
            int    index      = 0;

            if (!int.TryParse(parameters.ToString(1), out index))
            {
                Game.Console.Print("Invalid index specified!");
                return;
            }

            CEditableStruct tempStruct = GlobalVars.Structures.Find(x => x.Name == structName);

            if (tempStruct == null)
            {
                Game.Console.Print("No struct found with name \"" + structName + "\"!");
                return;
            }

            SParameter tempParam = new SParameter();

            for (int i = 0; i < tempStruct.NumParams; i++)
            {
                tempStruct.GetGenericParamByIndex(i, out tempParam);

                if (tempParam.Type == typeof(float))
                {
                    float value = 0f;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value.ToString());
                }
                else if (tempParam.Type == typeof(uint))
                {
                    uint value = 0;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value.ToString());
                }
                else if (tempParam.Type == typeof(string))
                {
                    string value = string.Empty;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value);
                }
                else if (tempParam.Type == typeof(char))
                {
                    char value = '\0';
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value);
                }
                else if (tempParam.Type == typeof(int))
                {
                    int value = 0;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value.ToString());
                }
                else if (tempParam.Type == typeof(short))
                {
                    short value = 0;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value.ToString());
                }
                else if (tempParam.Type == typeof(double))
                {
                    double value = 0f;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value.ToString());
                }
                else if (tempParam.Type == typeof(long))
                {
                    long value = 0;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value.ToString());
                }
                else if (tempParam.Type == typeof(char[]))
                {
                    int value = 0;
                    tempStruct.GetParamValue(index, i, ref value);
                    Game.Console.Print(tempParam.ParamName + " " + value.ToString());
                }
            }
        }