Setarg
From SA-MP Wiki
(Difference between revisions)
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
[edit]
setarg
Note: This function name starts with a lowercase letter. |
Description:
Set an argument that was passed to a function.
(arg, index=0, value)
arg | The argument sequence number. Use 0 for the first argument. |
index | The index (if the argument is an array). |
value | The value to set the argument to. |
[edit]
Related Functions
The following functions may be useful, as they are related to this function in one way or another.