Setarg

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 16:12, 26 April 2014
MP2 (Talk | contribs)

← Previous diff
Current revision
RoboN1X (Talk | contribs)
(The example was not good)
Line 10: Line 10:
{{Param|value|The value to set the argument to.}} {{Param|value|The value to set the argument to.}}
-{{Example}} 
-<pawn> 
-// Example on getting string from a function 
-GetAString(const string[], len) 
-{ 
- #pragma unused string // we used the argument to pass it to variable. 
- new astring[8+1] = "A string"; // 8 characters + end of string (null) 
- new i = 0; 
- while(i < len) // loop through the string 
- { 
- setarg(0, i, astring[i]); 
- i++; 
- } 
-} 
- 
-public OnFilterScriptInit() 
-{ 
- new str[9]; // The size should be same or less than astring variable above 
- GetAString(str, sizeof(str)); // Get the string 
- print(str); // Output: "A string" 
-} 
- 
-</pawn> 
{{RelatedFunctions}} {{RelatedFunctions}}

Current revision


setarg

Image:Farm-Fresh text lowercase.png Note: This function name starts with a lowercase letter.


Description:

Set an argument that was passed to a function.


Parameters:
(arg, index=0, value)
argThe argument sequence number. Use 0 for the first argument.
indexThe index (if the argument is an array).
valueThe value to set the argument to.


Related Functions

The following functions may be useful, as they are related to this function in one way or another.

  • getarg: Retrieve an argument from a variable argument list.
  • numargs: Return the number of arguments.