Scripting Functions Old
From SA-MP Wiki
Contents |
[edit]
File functions (file.inc)
You may refer also on File tutorial for a tutorial on this.
[edit]
fmatch
This function checks whether a part of the given file matched the string specified.
Parameters:({{{1}}})
| name[] | The filename to check. |
| const pattern[] | The pattern that should be matched. |
| index=0 | The offset to start searching. |
| size=sizeof name | The amount of characters to search in. |
fmatch("searchFile.txt", "Peter", 0);
[edit]
fputchar
This function writes one character to the file.
Parameters:({{{1}}})
| handle | The File handle to use, earlier opened by fopen(). |
| value | The character you want to write. |
| utf8=true | Should the character be written as UTF8? |
fputchar(gFile, 'e', false);
[edit]
ftemp
This function opens a file in the "tmp" or "temp" directory for reading and writing. The file is deleted after you close it with fclose().
({{{1}}})
| Returns | The File handle |
new File:gFile = ftemp();
[edit]
Float functions (float.inc)
[edit]
floatabs
Returns the absolute value of a float.
Parameters:({{{1}}})
| value | The float you want to check |
| Returns | The absolute value of the float. |
new Float:fAbs = floatabs(-123.54);
[edit]
floatcos
Calculate the right cosine of a float, with a specific anglemode.
Parameters:({{{1}}})
| value | The float you want to know the cosine of. |
| anglemode=radian | The Anglemode. |
| Returns | The cosine of the given float. |
new Float:fCos = floatcos(87.343, radian);
[edit]
floatfract
Calculate and return the fractional part of a float.
Parameters:({{{1}}})
| value | The float you want to know that fractional path of. |
| Returns | The fractional part of the float. |
new Float:fFract = floatfract(3249.34);
[edit]
floatlog
Use this function if you want to know the logarithm of a float.
Parameters:({{{1}}})
| value | The float you want to know the log. of. |
| base=10.0 | The base value to use. |
| Returns | The logarithm value of the float. |
new Float:fLog = floatlog(128.0);
[edit]
floatpower
Raises the float to the power of the exponent float.
Parameters:({{{1}}})
| value | The float you want to raise. |
| exponent | The exponent you want, as a float. |
| Returns | The float raised by the power of the exponent. |
new Float:fPower = floatpower(5.0, 2); // 25
[edit]
floatsin
Calculate the sinus of the given float, with the anglemode in radian, degrees or grads
Parameters:({{{1}}})
| value | The float you want to know the sinus of. |
| mode=radian | The Anglemode. |
| Returns | The sinus of the given float. |
new Float:fSin = floatsin(82.4);
[edit]
floatsqroot
Calculate the square root of the given float.
Parameters:({{{1}}})
| value | The float you want to know the square root of. |
| Returns | The square root of the float. |
new Float:fSqroot = floatsqroot(743.34);
[edit]
floattan
Calculate the tangent of the given float in the first argument, using it on a radian, grads or degree basis.
Parameters:({{{1}}})
| value | The float you want to know the tangent of. |
| mode=radian | The you Anglemode wish to use. |
| Returns | The tangent value of the float. |
new Float:fTan = floattan(87.4);
[edit]
String functions (string.inc)
[edit]
ispacked
Check if the given string is packed, and return the result.
Parameters:({{{1}}})
| const string[] | The string you want to check. |
| Returns | 1 if the string is packed, 0 if it's unpacked. |
if(ispacked(string)){
[edit]
strunpack
This function unpacks a packed string, into the destination.
Parameters:({{{1}}})
| dest[] | The destination for the unpacked string. |
| const source[] | The current packed string to unpack. |
| maxlength=sizeof dest | The length of the destination string. |
strunpack(string, packedString);
[edit]
uudecode
This function enables you to decode an UU-encoded stream.
Parameters:({{{1}}})
| dest[] | The destination for the decoded string array. |
| const source[] | The UU-encoded source string. |
| maxlength=sizeof dest | The maximum length of dest that can be used. |
uudecode(decodedString, encodedString);
[edit]
uuencode
The string you can decode with uudecode, must be encoded with this function.
Parameters:({{{1}}})
| dest[] | The destination string for the encoded stream. |
| const source[] | The source, non-encoded string. |
| numbytes | The number of bytes to encode, this should not exceed 45. |
| maxlength=sizeof dest | The maximum length of the dest[] array. |
uudecode(encodedString, normalString, 45);
