Scripting Functions Old

From SA-MP Wiki

Jump to: navigation, search

Contents

File functions (file.inc)

You may refer also on File tutorial for a tutorial on this.

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=0The offset to start searching.
size=sizeof nameThe amount of characters to search in.
fmatch("searchFile.txt", "Peter", 0);


fputchar

This function writes one character to the file.
Parameters:
({{{1}}})
handleThe File handle to use, earlier opened by fopen().
valueThe character you want to write.
utf8=trueShould the character be written as UTF8?
fputchar(gFile, 'e', false);


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().


Image:32px-Circle-style-warning.png Important Note: This function can crash your game when the right directory isn't created.


Parameters:
({{{1}}})
ReturnsThe File handle
new File:gFile = ftemp();


Float functions (float.inc)

floatabs

Returns the absolute value of a float.
Parameters:
({{{1}}})
valueThe float you want to check
ReturnsThe absolute value of the float.
new Float:fAbs = floatabs(-123.54);


floatcos

Calculate the right cosine of a float, with a specific anglemode.
Parameters:
({{{1}}})
valueThe float you want to know the cosine of.
anglemode=radianThe Anglemode.
ReturnsThe cosine of the given float.
new Float:fCos = floatcos(87.343, radian);


floatfract

Calculate and return the fractional part of a float.
Parameters:
({{{1}}})
valueThe float you want to know that fractional path of.
ReturnsThe fractional part of the float.
new Float:fFract = floatfract(3249.34);


floatlog

Use this function if you want to know the logarithm of a float.
Parameters:
({{{1}}})
valueThe float you want to know the log. of.
base=10.0The base value to use.
ReturnsThe logarithm value of the float.
new Float:fLog = floatlog(128.0);


floatpower

Raises the float to the power of the exponent float.
Parameters:
({{{1}}})
valueThe float you want to raise.
exponentThe exponent you want, as a float.
ReturnsThe float raised by the power of the exponent.
new Float:fPower = floatpower(5.0, 2); // 25


floatsin

Calculate the sinus of the given float, with the anglemode in radian, degrees or grads
Parameters:
({{{1}}})
valueThe float you want to know the sinus of.
mode=radianThe Anglemode.
ReturnsThe sinus of the given float.
new Float:fSin = floatsin(82.4);


floatsqroot

Calculate the square root of the given float.
Parameters:
({{{1}}})
valueThe float you want to know the square root of.
ReturnsThe square root of the float.
new Float:fSqroot = floatsqroot(743.34);


floattan

Calculate the tangent of the given float in the first argument, using it on a radian, grads or degree basis.
Parameters:
({{{1}}})
valueThe float you want to know the tangent of.
mode=radianThe you Anglemode wish to use.
ReturnsThe tangent value of the float.
new Float:fTan = floattan(87.4);


String functions (string.inc)

ispacked

Check if the given string is packed, and return the result.
Parameters:
({{{1}}})
const string[]The string you want to check.
Returns1 if the string is packed, 0 if it's unpacked.
if(ispacked(string)){


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 destThe length of the destination string.
strunpack(string, packedString);


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 destThe maximum length of dest that can be used.
uudecode(decodedString, encodedString);


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.
numbytesThe number of bytes to encode, this should not exceed 45.
maxlength=sizeof destThe maximum length of the dest[] array.
uudecode(encodedString, normalString, 45);
Personal tools
In other languages