示例#1
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);
        }
示例#2
0
        private void ThrowAPed(GTA.Script sender, GTA.ObjectCollection Parameter)
        {
            Ped ped = Parameter.Convert <Ped>(0);

            if (!Exists(ped) || ped.isInAir)
            {
                return;
            }
            ped.ApplyForce(new Vector3(0.0F, 0.0F, 5.0F), new Vector3(0.0F, 5.0F, 0.0F));
        }
示例#3
0
        private void getStructName_scriptCmd(GTA.Script sender, GTA.ObjectCollection parameters)
        {
            // si_getstructname <sender> <index>
            if (parameters.Count < 2)
            {
                // Error code 1: invalid parameter count.
                SendScriptCommand(sender, "si_getstructname_response", parameters[0], 1);
            }

            int index = parameters.Convert <int>(1);

            if (index < 0 || index >= GlobalVars.Structures.Count)
            {
                // Error code 2: invalid index
                SendScriptCommand(sender, "si_getstructname_response", parameters[0], 2);
            }

            SendScriptCommand(sender, "si_getstructname_response", parameters[0], GlobalVars.Structures[index].Name);
        }
示例#4
0
        private void getParamNum_scriptCmd(GTA.Script sender, GTA.ObjectCollection parameters)
        {
            // si_getparamnum <call identifier> <structure name>
            if (parameters.Count < 2)
            {
                // Error code 1: invalid parameter count
                SendScriptCommand(sender, "si_getparamnum_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_getparamnum_response", parameters[0], 3);
                return;
            }

            SendScriptCommand(sender, "si_getparamnum_response", parameters[0], tempStruct.NumParams);
        }
示例#5
0
        private void setParamValue_scriptCmd(GTA.Script sender, GTA.ObjectCollection parameters)
        {
            if (parameters.Count < 5)
            {
                // Error code 1: invalid parameter count
                SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 1);
                return;
            }

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

            int index = 0;

            if (!int.TryParse(parameters.Convert <string>(2), out index))
            {
                // Error code 2: invalid index
                SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 2);
                return;
            }

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

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

            string     paramName = parameters.Convert <string>(3);
            SParameter tempParam = new SParameter();

            if (tempStruct.GetGenericParamByName(paramName, ref tempParam) != 0)
            {
                // Error code 4: invalid param name
                SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 4);
                return;
            }

            if (tempParam.Type == typeof(int))
            {
                int newVal = parameters.Convert <int>(4);
                int retVal = tempStruct.SetParamValue <int>(index, paramName, newVal);

                if (retVal == -1)
                {
                    // Error code 5: invalid param index number
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 5);
                    return;
                }
            }
            else if (tempParam.Type == typeof(string))
            {
                string newVal = parameters.Convert <string>(4);
                int    retVal = tempStruct.SetParamValue(index, paramName, newVal);

                if (retVal == -1)
                {
                    // Error code 5: invalid param index number
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 5);
                    return;
                }
                else if (retVal == -3)
                {
                    // Error code 6: input string too long
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 6);
                    return;
                }
            }
            else if (tempParam.Type == typeof(char))
            {
                string newValString = parameters.Convert <string>(4);
                char   newVal       = '\0';
                int    retVal       = 0;

                if (newValString != string.Empty)
                {
                    newVal = newValString[0];
                    if (retVal == -1)
                    {
                        // Error code 5: invalid param index number
                        SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 5);
                        return;
                    }
                }
                else
                {
                    // Error code 6: invalid character entered
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 6);
                    return;
                }
            }
            else if (tempParam.Type == typeof(float))
            {
                float newVal = parameters.Convert <float>(4);
                int   retVal = tempStruct.SetParamValue(index, paramName, newVal);

                if (retVal == -1)
                {
                    // Error code 5: invalid param index number
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 5);
                    return;
                }
            }
            else if (tempParam.Type == typeof(double))
            {
                double newVal = parameters.Convert <float>(4);
                int    retVal = tempStruct.SetParamValue(index, paramName, newVal);

                if (retVal == -1)
                {
                    // Error code 5: invalid param index number
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 5);
                    return;
                }
            }
            else if (tempParam.Type == typeof(short))
            {
                short newVal = parameters.Convert <short>(4);
                int   retVal = tempStruct.SetParamValue(index, paramName, newVal);

                if (retVal == -1)
                {
                    // Error code 5: invalid param index number
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 5);
                    return;
                }
            }
            else if (tempParam.Type == typeof(long))
            {
                long newVal = parameters.Convert <long>(4);
                int  retVal = tempStruct.SetParamValue(index, paramName, newVal);

                if (retVal == -1)
                {
                    // Error code 5: invalid param index number
                    SendScriptCommand(sender, "si_setparamvalue_response", parameters[0], 5);
                    return;
                }
            }

            // Success! :D
            SendScriptCommand(sender, "si_setparamvalue_respons", parameters[0], 0);
        }
示例#6
0
        private void getParamValue_scriptCmd(GTA.Script sender, GTA.ObjectCollection parameters)
        {
            // si_getparamvalue <call identifier> <structure name> <element index> <parameter name>
            if (parameters.Count < 4)
            {
                // Error code 1: invalid parameter count
                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 1);
                return;
            }

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

            int index = 0;

            if (!int.TryParse(parameters.Convert <string>(2), out index))
            {
                // Error code 2: invalid index
                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 2);
                return;
            }

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

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

            string     paramName = parameters.Convert <string>(3);
            SParameter tempParam = new SParameter();

            if (tempStruct.GetGenericParamByName(paramName, ref tempParam) != 0)
            {
                // Error code 4: invalid param name
                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 4);
                return;
            }

            if (tempParam.Type == typeof(int))
            {
                int retVal = 0;
                tempStruct.GetParamValue(index, paramName, ref retVal);

                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 0, retVal);
            }
            else if (tempParam.Type == typeof(string))
            {
                string retVal = string.Empty;
                tempStruct.GetParamValue(index, paramName, ref retVal);

                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 0, retVal);
            }
            else if (tempParam.Type == typeof(char))
            {
                char retVal = char.MinValue;
                tempStruct.GetParamValue(index, paramName, ref retVal);

                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 0, retVal);
            }
            else if (tempParam.Type == typeof(float))
            {
                float retVal = 0f;
                tempStruct.GetParamValue(index, paramName, ref retVal);

                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 0, retVal);
            }
            else if (tempParam.Type == typeof(double))
            {
                double retVal = 0f;
                tempStruct.GetParamValue(index, paramName, ref retVal);

                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 0, retVal);
            }
            else if (tempParam.Type == typeof(short))
            {
                short retVal = 0;
                tempStruct.GetParamValue(index, paramName, ref retVal);

                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 0, retVal);
            }
            else if (tempParam.Type == typeof(long))
            {
                long retVal = 0;
                tempStruct.GetParamValue(index, paramName, ref retVal);

                SendScriptCommand(sender, "si_getparamvalue_response", parameters[0], 0, retVal);
            }

            return;
        }
示例#7
0
 private void getStructNum_scriptCmd(GTA.Script sender, GTA.ObjectCollection parameters)
 {
     SendScriptCommand(sender, "si_getstructnum_response", parameters[0], GlobalVars.Structures.Count);
 }