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.

fblockwrite

Write data to a file in binary format, while ignoring line brakes and encoding.
Parameters:
({{{1}}})
handleThe File handle to use, opened by fopen().
const buffer[]The data to write to the file.
size=sizeof bufferThe number of cells to write.
fblockwrite(gFile, "Save this data!", 15);


fgetchar

This function reads one character from the file, and saves it in the value variable, passed by reference.
Parameters:
({{{1}}})
handleThe File handle to use, opened by fopen().
&valueThe variable to save the character in.
utf8=trueRead the character as UTF8.
fgetchar(gFile, handle, false);


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

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);


floatcmp

Compare two floats to each other.
Parameters:
({{{1}}})
oper1The first float you want to compare.
oper2The second float you want to compare.
Returns1 if the first argument is larger, -1 is the second one is larger.
new compare = floatcmp(127.45, 127.450);


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);


floatstr

Convert a string to it's rightful float value.
Parameters:
({{{1}}})
const string[]The string you want to convert to a float.
ReturnsThe requested float.
new Float:fFloat = floatstr("124.34");


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);


valstr

Converts an integer value to a string.
Parameters:
({{{1}}})
dest[]The string to store the value in.
valueThe integer value to convert to a string.
pack=falsePack the string if true.
valstr(string, 454);
Personal tools
In other languages