Valstr
From SA-MP Wiki
(Difference between revisions)
Revision as of 16:07, 26 April 2014 MP2 (Talk | contribs) ← Previous diff |
Current revision MP2 (Talk | contribs) (Updated link to fixes.inc) |
||
Line 19: | Line 19: | ||
</pawn> | </pawn> | ||
- | {{Note2|Passing a high value to this function can cause the server to freeze/crash. Fixes are available. Below is a fix that can be put straight in to your script (before valstr is used anywhere). [http://goo.gl/PYV1RP fixes.inc] includes this fix.}} | + | {{Note2|1=Passing a high value to this function can cause the server to freeze/crash. Fixes are available. Below is a fix that can be put straight in to your script (before valstr is used anywhere). [http://forum.sa-mp.com/showthread.php?t=570922 fixes.inc] includes this fix.}} |
<pawn> | <pawn> | ||
// valstr fix by Slice | // valstr fix by Slice |
Current revision
[edit]
valstr
Note: This function name starts with a lowercase letter. |
Description:
Convert an integer into a string.
(dest[], value, bool:pack=false)
dest | The destination of the string. |
value | The value to convert to a string. |
pack (optional) | Whether to pack the destination (off by default). |
Return Values:
This function does not return any specific values.
Example Usage:
new string[4]; new iValue = 250; valstr(string,iValue); // string is now "250"
Important | Passing a high value to this function can cause the server to freeze/crash. Fixes are available. Below is a fix that can be put straight in to your script (before valstr is used anywhere). fixes.inc includes this fix. |
// valstr fix by Slice stock FIX_valstr(dest[], value, bool:pack = false) { // format can't handle cellmin properly static const cellmin_value[] = !"-2147483648"; if (value == cellmin) pack && strpack(dest, cellmin_value, 12) || strunpack(dest, cellmin_value, 12); else format(dest, 12, "%d", value), pack && strpack(dest, dest, 12); } #define valstr FIX_valstr
[edit]
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- strval: Convert a string into an integer.
- strcmp: Compare two strings to check if they are the same.