Useful Functions

From SA-MP Wiki

Jump to: navigation, search

Contents

Useful Functions (uf.inc)

Here you can find useful functions for your pawno scripts. They are mostly copied from an older version of the useful functions topic on the SA-MP Forums, these can all be implemented with the Useful Functions include file.

AddStaticPickup2

Allows the saving of models, types and pickup positions, it is essential for OnPlayerPickupItem
Parameters:
(model, type, Float:X, Float:Y, Float:Z)
modelThe modelid of the pickup to spawn
typeThe typeid of the pickup to spawn
Float:XThe x value of the spawn position
Float:YThe y value of the spawn position
Float:ZThe z value of the spawn position
AddStaticPickup2(50,2,29.5,36.5,49.8);

By: Sacky

AddStaticVehicle2

Enables saving of vehicleclasses to a script (Alot of vehicle functions rely on this)
Parameters:
(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2)
modelidThe modelid of the vehicle to spawn
Float:spawn_xThe x value of the spawn position
Float:spawn_yThe y value of the spawn position
Float:spawn_zThe z value of the spawn position
Float:z_angleThe angle value of the spawn position
color1The first colour of the vehicle
color1The second colour of the vehicle
AddStaticVehicle2(50,2.6,29.5,36.5,49.8,6,7);

By: Sacky

AddStaticVehicleEx2

Allows the saving of models to the AddStaticVehicleEx function, for people who prefer this function to AddStaticVehicle
Parameters:
(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2,respawn_delay)
modelidThe modelid of the vehicle to spawn
Float:spawn_xThe x value of the spawn position
Float:spawn_yThe y value of the spawn position
Float:spawn_zThe z value of the spawn position
Float:z_angleThe angle value of the spawn position
color1The first colour of the vehicle
color1The second colour of the vehicle
respawn_delayThe amount of time in miliseconds the vehicle will wait before respawning when it dies
AddStaticVehicleEx2(50,2.6,29.5,36.5,49.8,6,7,7000);

By: Sacky

AddStaticVehicleLine

Makes a line of vehicle's
Parameters:
(Modelid, Float:Start[2], Float:Rate[2], Float:Z, Float:Z_Angle, MaxAmount)
ModelidThe modelid of the vehicles to spawn
Float:Start[2]The x value of the starting position
Float:Rate[2]The y value of the starting position
Float:ZThe z value of the starting position
Float:Z_AngleThe angle value of the spawn position for the cars in the line
MaxAmountThe amount of cars in the line
AddStaticVehicleLine(50,2.6,3.8,7.4,270.0,5);

By: Sacky

BanTeam

Bans all the players in an entire team
Parameters:
(team)
teamThe teamid to ban
BanTeam(1);

By: dyraXon

ConvertSeconds

Converts an integer of seconds into a string that will display hours,minutes and seconds
Parameters:
(time)
timeThe amount of seconds as an integer
ReturnsThe converted amount of seconds into hours, minutes, and seconds (Displays like: x hours, x minutes and x seconds
ConvertSeconds(12000);

By: El Presy

DegreesToRadians

Converts degree's to radians
Parameters:
(Float:degrees)
Float:degreesThe degree you want to convert
ReturnsThe conversion of the degree to a radian
DegreesToRadians(270);

By: Sacky

encrypt

This function allows you to encrypt strings, very useful for storing passwords without fear of someone cracking them
Parameters:
(string[])
string[]The string you want to encrypt
ReturnsThe encrypted string
encrypt("User Password");

Note: This function requires you to set a unique key to use with it. This is so no-one elses use of the function generates the same hashes as you. This key must contain ALL the letters and digits you want to make valid in a password or it will produce wierd results. They don't have to be listed only once but must be listed at least once, in any random order. The location of the key is clearly documented within the function. Don't change your key or no-one will be able to log in.

There is also a PHP version here.

By: Y_Less

floatrand

Generates a random number with 2 decimal places
Parameters:
(Float:min, Float:max)
Float:minThe minimum the random float can be
Float:maxThe maximum the random float can be
ReturnsThe random float between the minimum and maximum values
floatrand(1.2,5.6);

By: Y_Less

GameTextCheck

Returns 1 if the text won't crash your server, 0 if it will
Parameters:
(string[])
string[]The string to be checked
ReturnsThe 1 if the text is ok, 0 if it isn't
GameTextCheck("Hello World");

By: Kamazy

GameTextForTeam

Sends GameText to all the players in the specified team, the same as GameTextForPlayer except you can specify the team
Parameters:
(team, text[], time, style)
teamThe team you want the message sent to
text[]The text to be sent
timeThe time for the text to remain on the screen
styleThe style of the text
GameTextForTeam(1,"Hello",1000,3);

By: Y_Less

GetClosestCar

Returns the ID of the closest car
Parameters:
(playerid)
playeridThe first playerid to parse into the function
ReturnsThe closest vehicle to the player
GetClosestCar(1);

By: Darkrealm

GetClosestPlayer

Returns the ID of the closest player
Parameters:
(playerid)
playeridThe first playerid to parse into the function
ReturnsThe closest player to the specified player
GetClosestPlayer(1);

By: Slick

GetCurrentPosition

Returns the current position as a string
Parameters:
(playerid)
playeridThe playerid to get the position from
ReturnsThe current position in string format
GetCurrentPosition(1);

By: Sacky

GetDistanceBetweenPlayers

Returns the distance between players as an integer


Image:32px-Circle-style-warning.png Important Note: This function is no longer useable


Parameters:
(playerid,playerid2)
playeridThe first playerid to parse into the function
playerid2The second playerid to parse into the function
ReturnsThe distance between the players in meters as an integer
GetDistanceBetweenPlayers(1,2);

By: Slick

GetDistanceToCar

Returns the distance between the player and the car as an integer (Note: This doesnt fully work properly due to the GetVehiclePos not working properly, instead it will give you the distance to the car spawn)
Parameters:
(playerid,carid)
playeridThe player to parse
caridThe vehicleid to parse
ReturnsThe distance between the player and the vehicle
GetDistanceToCar(1,2);

By: Darkrealm

GetPickups

Returns the number of pickups on the server
ReturnsThe number of pickups present on the server
GetPickups();

By: Sacky

GetPlayerAcceleration

Returns the player accelaration in MPH as an integer, it requires the uftimer to be implemented in the gamemode
Parameters:
(playerid)
playeridThe player you want to get the speed from
ReturnsThe acceleration of the player
GetPlayerAcceleration(5);

By: Sacky

GetPlayerDistanceToPoint

Returns the player distance to a 2D point
Parameters:
(playerid,Float:x,Float:y)
playeridThe player you wish to query
Float:xThe x value of the point
Float:yThe y value of the point
ReturnsThe distance to the point
GetPlayerDistanceToPoint(1,1.9,8.5);

By: Sacky

GetPlayerDistanceToPointEx

Returns the player distance to a 3D point
Parameters:
(playerid, Float:x, Float:y, Float:z)
playeridThe player you wish to query
Float:xThe x value of the point
Float:yThe y value of the point
Float:zThe z value of the point
ReturnsThe distance to the point
GetPlayerDistanceToPoint(1,1.9,8.5,9.5);

By: Sacky

GetPlayerId

Returns the player ID from a playername
Parameters:
(playername[])
playername[]The name you want to get the playerid from
ReturnsThe playerid (if none then returns -1)
GetPlayerId("Y_Less");

By: Y_Less

GetPlayers

Returns the number of players on the server
ReturnsThe number of players on the server
GetPlayers();

By: rapidZ

GetPlayerSkin

Returns the class of the players skin
Parameters:
(playerid)
playeridThe player you want to get the skin from
ReturnsThe skin id (0 if invalid)
GetPlayerSkin(5);

By: Sacky

GetPlayerSpeed

Returns the player speed in KMPH as a float, it requires the uftimer to be implemented in the gamemode
Parameters:
(playerid)
playeridThe player you want to get the speed from
ReturnsThe speed of the player
GetPlayerSpeed(5);

By: Sacky

GetPointDistanceToPoint

Returns the distance between 1 x and y value and another x and y value
Parameters:
(Float:x,Float:y,Float:x2,Float:y2)
Float:xThe x value of the first point
Float:yThe y value of the first point
Float:x2The x value of the second point
Float:y2The y value of the second point
ReturnsThe distance between the 2 points
GetPointDistanceToPoint(12.3,14.5,109.7,88.9);

By: Sacky

GetPointDistanceToPointEx

Returns the distance between 1 x,y and z value and another x,y and z value
Parameters:
(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2)
Float:xThe x value of the first point
Float:yThe y value of the first point
Float:zThe z value of the first point
Float:x2The x value of the second point
Float:y2The y value of the second point
Float:z2The z value of the first point
ReturnsThe distance between the 2 points
GetPointDistanceToPointEx(12.3,14.5,15.6,109.7,88.9,13.4);

By: Sacky

GetVehicleClass

Returns the Vehicleclass/modelid (Needs AddStaticVehicle2 or AddStaticVehicleEx2)
Parameters:
(vehicleid)
vehicleidThe id of the vehicle to return the class from
ReturnsThe vehicle class (0 if invalid vehicle)
GetVehicleClass(1);

By: Sacky

GetVehicleName

Returns the name of a vehicle (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:
(vehicleid)
vehicleidThe id of the vehicle to return the class from
ReturnsThe name of a vehicle (by class)
GetVehicleName(1);

By: Sacky

GetVehicleType

Returns the type of a vehicle (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:
(vehicleid)
vehicleidThe id of the vehicle to return the type from
ReturnsThe type of a vehicle (eg. CAR or BOAT)
GetVehicleType(1);

By: Sacky

GetVehicleZAngle

Returns the vehicles angle
Parameters:
(vehicleid)
vehicleidThe id of the vehicle to return the angle from
ReturnsThe angle of the vehicle
GetVehicleZAngle(1);

By: Sacky

GetVehicles

Returns the number of vehicles on the server
ReturnsThe number of vehicles present on the server
GetVehicles();

By: Sacky

GivePlayerWeaponAlt

A version of GivePlayerWeapon, that displays an alert for weapon classes that cannot be given to players for some reason, then defaults to giving "Unarmed"
Parameters:
(playerid, weaponid, ammo)
playeridThe playerid to give the weapon to
weaponidThe weaponid you want to give to the player
ammoHow much ammo to give to the player
GivePlayerWeaponAlt(1,26,500);

By: Allan

GivePlayerWeaponEx

Lets you specify an unlimited number of weapons and ammo to be given to a player
Parameters:
( playerid, ... )
playeridThe playerid to give the weapon to
...The weaponid you want to give to the player, also specify the ammo
GivePlayerWeaponEx(1,25,400,26,400);

By: Peter

GiveTeamMoney

Gives every payer on a team a certain amount of money
Parameters:
(team, amount)
teamThe team to give the money to
amountThe amount of money to give to the team
GiveTeamMoney(1,500);

By: Hellomy

HexToRGBA

Converts Hexidecimal into RGBA
Parameters:
(colour, &r, &g, &b, &a)
colourThe hexidecimal colour
&rThe red colour to store
&gThe green colour to store
&bThe blue colour to store
&aThe alpha colour to store
HexToRGBA(0xAFAFAFAA,r,g,b,a);

By: Betamaster

icos

Inverse Trigonomic Function (cosine)
Parameters:
(Float:adj,Float:hyp)
Float:adjThe length of the adjacent side
Float:hypThe length of the hypotenuse side
ReturnsThe processed inverse trigonomic equation (Float)
icos(5.3,4.6);

By: Sacky

isin

Inverse Trigonomic Function (sine)
Parameters:
(Float:opp,Float:hyp)
Float:oppThe length of the opposite side
Float:hypThe length of the hypotenuse side
ReturnsThe processed inverse trigonomic equation (Float)
isin(5.3,4.6);

By: Sacky

IsNumeric

Returns 1 if the string is numeric, 0 if not
Parameters:
(string[])
string[]The string you want to check
Returns1 if numeric, 0 if not numeric
IsNumeric("12");

By: Mike

IsPickupConnected

Returns 1 if the pickup is connected and 0 if it isn't, it requires you to use AddStaticPickup2 rather than AddStaticPickup
Parameters:
(pickupid)
pickupidThe pickup id you want to query
Returns1 if it is connected, 0 if it isn't
IsPickupConnected(254);

By: Sacky

IsPlayerInAnyInterior

Returns the 1 if they are, returns 0 if they arent (There are some interiors which escape this function, it will work on about 95% of interiors)
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are in an interior, 0 if they aren't
IsPlayerInAnyInterior(5);

By: Sacky

IsPlayerInArea

Returns 1 if the player is in the area and 0 if they aren't
Parameters:
(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
playeridThe playerid you want to query
Float:minxThe minimum x value for the area
Float:minyThe minimum y value for the area
Float:maxxThe maximum x value for the area
Float:maxyThe maximum y value for the area
Returns1 if they are in the area, 0 if they aren't
IsPlayerInArea(2, 2.0, 2.0, 4.0, 4.0);

By: Y_Less

IsPlayerInAreaEx

Returns 1 if the player is in the area and 0 if they aren't
Parameters:
(playerid, ...)
playeridThe playerid you want to query
...The x and y values for your area
Returns1 if they are in the area, 0 if they aren't
IsPlayerInArea(2, 2.0, 2.0, 4.0, 4.0);

By: kool

IsPlayerInBoat

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are in a boat, 0 if they aren't
IsPlayerInBoat(5);

By: Sacky

IsPlayerInCar

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are in a car, 0 if they aren't
IsPlayerInCar(5);

By: Sacky

IsPlayerInCircle

Returns 1 if the player is in the circle and 0 if they aren't
Parameters:
(playerid, Float:x, Float:y, radius)
playeridThe playerid you want to query
Float:xThe x value of the center of the circle
Float:yThe y value of the center of the circle
radiusThe radius of the circle
Returns1 if they are in the area, 0 if they aren't
IsPlayerInCircle(2,13.9,14.8,5);

By: Sacky

IsPlayerInCube

Returns 1 if the player is in the cube and 0 if they aren't
Parameters:
(playerid, xmin, ymin, zmin, xmax, ymax, zmax)
playeridThe playerid you want to query
xminThe minimum x value of the cube
yminThe minimum y value of the cube
zminThe minimum z value of the cube
xmaxThe maximum x value of the cube
ymaxThe maximum y value of the cube
zmaxThe maximum z value of the cube
Returns1 if they are in the area, 0 if they aren't
IsPlayerInCube(2,2,3,4,1,2,3);

By: 50p

IsPlayerInHelicopter

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are in a helicopter, 0 if they aren't
IsPlayerInHelicopter(5);

By: Sacky

IsPlayerInMonsterTruck

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are in a monster truck, 0 if they aren't
IsPlayerInMonsterTruck(5);

By: Sacky

IsPlayerInPlane

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are in a plane, 0 if they aren't
IsPlayerInPlane(5);

By: Sacky

IsPlayerInSphere

Returns 1 if the player is in the sphere and 0 if they aren't
Parameters:
(playerid, Float:x, Float:y, Float:z, radius)
playeridThe playerid you want to query
Float:xThe x value of the center of the sphere
Float:yThe y value of the center of the sphere
Float:zThe z value of the center of the sphere
radiusThe radius of the circle
Returns1 if they are in the spherer, 0 if they aren't
IsPlayerInCircle(2,13.9,14.8,5,9.7);

By: Sacky

IsPlayerInQuad

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are in a quad, 0 if they aren't
IsPlayerInQuad(5);

By: Sacky

IsPlayerInRange

Returns 1 if if they are, 0 if they aren't
Parameters:
(playerid, Float: Range, Float: Z_Range, Float:tar_x, Float:tar_y, Float:tar_z)
playeridThe playerid you want to query
Float:RangeThe range the player can be in
Float:Z_RangeThe height range the player can be in
Float:tar_xThe x value for the point
Float:tar_yThe y value for the point
Float:tar_zThe z value for the point
Returns1 if they are in the range, 0 if they aren't
IsPlayerInRange(2, 2.0, 2.0, 4.0, 4.0, 4.0);

By: Simon

IsPlayerDriver

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are a driver, 0 if they aren't
IsPlayerDriver(5);

By: Sacky

IsPlayerOnBicycle

Returns the 1 if they are, returns 0 if they arent (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are on a bicycle, 0 if they aren't
IsPlayerOnBicycle(5);

By: Sacky

IsPlayerOnBike

Returns the 1 if they are, returns 0 if they arent (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are on a bike, 0 if they aren't
IsPlayerOnBike(5);

By: Sacky

IsPlayerOnFoot

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are on foot, 0 if they aren't
IsPlayerOnFoot(5);

By: Sacky

IsPlayerPassenger

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query
Returns1 if they are a passenger, 0 if they aren't
IsPlayerPassenger(5);

By: Sacky

IsTeamInArea

Returns 1 if the team is in the area and 0 if they aren't
Parameters:
(team, Float:minx, Float:maxx, Float:miny, Float:maxy)
teamThe teamid you want to query
Float:minxThe minimum x value for the area
Float:minyThe minimum y value for the area
Float:maxxThe maximum x value for the area
Float:maxyThe maximum y value for the area
Returns1 if they are in the area, 0 if they aren't
IsTeamInArea(2, 2.0, 2.0, 4.0, 4.0);

By: dyraXon

IsVehicleConnected

Returns 1 if the vehicle is connected and 0 if it isn't
Parameters:
(vehicleid)
vehicleidThe vehicle's id you want to query
Returns1 if it is connected, 0 if it isn't
IsVehicleConnected(254);

By: Sacky

IsVehicleInUse

Returns 1 if the vehicle is in use and 0 if it isn't
Parameters:
(vehicleid)
vehicleidThe vehicle's id you want to query
Returns1 if it is in use, 0 if it isn't
IsVehicleInUse(254);

By: Sacky

itan

Inverse Trigonomic Function (tangent)
Parameters:
(Float:opp,Float:adj)
Float:oppThe length of the opposite side
Float:adjThe length of the adjacent side
ReturnsThe processed inverse trigonomic equation (Float)
itan(5.3,4.6);

By: Sacky

KickTeam

Kicks all the players in an entire team
Parameters:
(team)
teamThe teamid to kick
KickTeam(1);

By: Sacky

left

Returns the first characters in the string, it will return how many you set in the len
Parameters:
(source[], len)
source[]The string you want to take the left characters from
lenThe number of characters from the left you want to return
ReturnsThe number of characters from the left specified in the len
left("Hello",1);

By: Y_Less

lengthdir_x

Returns the position relative to the current position taking angle and distance as the arguments
Parameters:
(Float:length,Float:angle)
Float:lengthHow long the line is
Float:angleThe angle in which to draw the virtual line
ReturnsThe length of the line
lengthdir_x(32.4,170.9);

By: Slick

lengthdir_y

Returns the position relative to the current position taking angle and distance as the arguments
Parameters:
(Float:length,Float:angle)
Float:lengthHow long the line is
Float:angleThe angle in which to draw the virtual line
ReturnsThe length of the line
lengthdir_y(32.4,170.9);

By: Slick

minrand

Generates a random integer between the minimum and maximum numbers set
Parameters:
(min, max)
minThe minimum number the random integer can be
maxThe maximum number the random integer can be
ReturnsThe random number between the min and max as an integer
minrand(1,5);

By: Y_Less

mktime

Returns the unix-timestamp of a date/time, equivalent to PHP's one: mktime on php.net
Parameters:
(hour,minute,second,day,month,year)
hourThe hour integer to pass
minuteThe minute integer to pass
secondThe second integer to pass
dayThe day integer to pass
monthThe month integer to pass
yearThe year integer to pass
Returnsseconds since the beginning of unix time/timestamp
mktime(1,1,1,1,1,2005);

By: mabako

parsecommand

This function takes a command passed to OnPlayerCommandText and splits it into the command and the rest
Parameters:
(cmdtext[], cmd[], text[], parcount)
cmdtext[]The whole text in the command
cmd[]The actual command (all letters that aren't separated by a space)
text[]The Text you want to find
parcountThe number of spaces there are
ReturnsWhether the text is valid
parsecommand("/test test","/test","test",1);

By: Y_Less

PlayerID

Returns the playerid by detecting players who have a part of a playername in them
Parameters:
(partofname[])
partofname[]The part of the players name you want to get the ID from
ReturnsThe Players ID (if valid)
PlayerID("NoV");

By: DracoBlue

PlayerPlaySoundEx

Plays a sound to a player exactly where the player is
Parameters:
(playerid,soundid)
playeridThe ID of the player you want to play the sound for
soundidThe ID of the sound you want to play
PlayerPlaySoundEx(1,205);

By: Sacky

RadiansToDegrees

Converts radians to degree's
Parameters:
(Float:radian)
Float:radianThe radian you want to convert
ReturnsThe conversion of the radian to a degree
RadiansToDegrees(0.26);

By: Sacky

ResetVehicleSpawnPos

Resets a vehicle's dynamic spawn position (proof of concept, recomend against using it)
Parameters:
(vehicleid)
vehicleidThe vehicleid of vehicle you want to reset
ResetVehicleSpawnPos(250);

By: Sacky

RetStr

Returns a string representation of a number
Parameters:
(num)
numThe number you want to convert into a string
ReturnsThe string representation of a number
RetStr(11);

By: Y_Less

ReturnPlayerName

Returns the playername from the playerid
Parameters:
(playerid)
playeridThe playerid you want to get the name from
ReturnsThe playername as a string
ReturnPlayerName(0);

By: Y_Less

RGBAToHex

Converts RGBA into Hexidecimal
Parameters:
(r, g, b, a)
rThe red value of the colour
gThe green value of the colour
bThe blue value of the colour
aThe alpha value of the colour
RGBAToHex(210,90,75,3);

By: Betamaster

right

Returns the last characters in the string, it will return how many you set in the len
Parameters:
(source[], len)
source[]The string you want to take the right characters from
lenThe number of characters from the right you want to return
ReturnsThe number of characters from the right specified in the len
right("Hello",1);

By: Y_Less

SendClientMessageToAdmins

Sends a string to all the admins logged in RCON
Parameters:
(colour, str[])
colourThe colour you want the Client Message to be
str[]The text to send them
SendClientMessageToAdmins(0xAFAFAFAA,"Hello");

By: Mike

SendClientMessageToAllOthers

Lets you send a client message to all clients except the one you specify
Parameters:
(playerid, color, message[])
playeridThe playerid you don't want the client message to be sent to
colorThe colour to send the message in
message[]The message to send
SendClientMessageToAllOthers(1,0xAFAFAFAA,"Hello");

By: yom

SendClientMessageToTeam

Sends a Client Message to a team, the same as SendClientMessage except you can specify the team
Parameters:
(team, color, text[])
teamThe team you want to send the client message to
colorThe color (in hexidecimal format) that you want to send the text in
text[]The text to send the team
SendClientMessageToTeam(1,0xAFAFAFAA,"Hello");

By: Y_Less

SendFormattedGameTextToPlayer

A simple, but effective GameTextToPlayer and format wrap
Parameters:
(playerid, const msg[], time, style, define)
playeridThe playerid you want to see the gametext
msg[]The text you want the gametext to be
timeThe amount of time the gametext should linger on the screen
styleThe style to send the gametext in
defineThe variable you want to put in
SendFormattedGameTextToPlayer(1,"Hello",1000,3,24);

By: Allan

SendFormattedGameTextToAll

A simple, but effective GameTextToAll and format wrap
Parameters:
(const msg[], time, style, define)
msg[]The text you want the gametext to be
timeThe amount of time the gametext should linger on the screen
styleThe style to send the gametext in
defineThe variable you want to put in
SendFormattedGameTextToAll("Hello",1000,3,24);

By: Allan

SetPlayerColourAlpha

Used to set a players alpha colour
Parameters:
(playerid, alpha)
playeridThe id of the player you want to set the alpha colour to
alphaThe alpha value to set for the player
SetPlayerColourAlpha(1,500);

By: Betamaster

SetPlayerMoney

Lets you Set the player money to any amount rather than going through GivePlayerMoney and minusing to take money away
Parameters:
(playerid, money)
playeridThe id of the player you want to set the money to
moneyThe amount of money to set
SetPlayerMoney(1,500);

By: DracoBlue

SetPlayerPosEx

Lets you set the angle and interior as well as the position
Parameters:
(playerid,Float:X,Float:Y,Float:Z,Float:Ang,Int)
playeridThe id of the player you want to set position
Float:XThe x value of the position
Float:YThe y value of the position
Float:ZThe z value of the position
Float:AngThe angle value of the position
IntThe interior id of the position
SetPlayerPosEx(1,1.1,2.2,3.3,270.9,6);

By: Kamazy

SetTeamScore

Sets a players score to everyone on a team
Parameters:
(team, score)
teamThe id of the team you'd like to set a score for
scoreThe score to set
SetTeamScore(1,500);

By: Hellomy

SetTeamPos

Lets you set player positions to everyone on a team at once
Parameters:
(team, x, y, z)
teamThe id of the team you'd like to set position
xThe x value of the position
yThe y value of the position
zThe z value of the position
SetTeamPos(1,2,2,2);

By: dyraXon

SetVehicleRespawnPos

Lets you Set the vehicle respawn position (proof of concept, recomend against using it)
Parameters:
(vehicleid,Float:x,Float:y,Float:z,Float:angle)
vehicleidThe id of the vehicle to reset its spawn
Float:xThe x value for the spawn position
Float:yThe y value for the spawn position
Float:zThe z value for the spawn position
Float:angleThe angle value for the spawn position
SetVehicleRespawnPos(1,500.5,500.5,10.5,270.0);

By: Sacky

str_replace

Replaces certain aspects in a string
Parameters:
(search[], replace[], source[])
search[]The string to search for
replace[]The strings to replace
source[]The original string
ReturnsThe string formatted by the replace
str_replace("o","1","Hello World");

By: Tratulla

strrest

Returns the rest of the string splitting it at the index
Parameters:
(string[], index)
string[]The full string to be split
&indexThe character to split the string at
ReturnsThe split string
strrest("Hello World Today",0);

By: mabako

strtok

Returns the string split by the index
Parameters:
(string[], &index)
string[]The full string to be split
&indexThe character to split the string at
ReturnsThe split string
strtok("Hello World",0);

By: Compuphase

TakePlayerMoney

The opposite to GivePlayerMoney, simply takes it away from the player
Parameters:
(playerid, money)
playeridThe ID of the player to take money from
moneyThe amount of money to take
TakePlayerMoney(1,500);

By: Sacky

timeconvert_seconds

Takes an integer of seconds and then formats it so it will say "minutes:seconds", useful for countdowns
Parameters:
(time)
timeThe number of seconds to convert
ReturnsThe converted seconds in a minutes:seconds format
timeconvert_seconds(181);

By: Sacky

TwoWayRand

Will generate a random number taking negatives into account, for example if you put in 10 there would be 20 possible numbers (-10 - 10)
Parameters:
(value)
valueThe value to randomise
ReturnsThe randomised number in a negative integer
TwoWayRand(10);

By: Allan

ValidEmail

Checks to see whether an email is valid, by entering in a string that should be an email address to it
Parameters:
(email[])
email[]The email as a string
ReturnsTrue if the email is valid, false if it isn't
ValidEmail("user1@hotmail.com");

By: DracoBlue

VehicleDriverID

Returns the playerid of the driver of the vehicle
Parameters:
(vehicleid)
vehicleidThe ID of the vehicle to get the driver from
ReturnsThe playerid if someone is driving the vehicle, -1 if no one is driving it
VehicleDriverID(52);

By: DracoBlue

VehicleDriverName

Returns the name of a player driving the vehicle (vehicleid)
Parameters:
(vehicleid)
vehicleidThe ID of the vehicle to get the driver from
ReturnsThe driver name of the vehicle
VehicleDriverName(52);

By: Sacky

QuadraticRootCalc

Provided that the conditions are met, this should generate solutions to quadratic equasions
Parameters:
(Float:Xsq,Float:X,Float:num)
Float:XsqThe square root of x
Float:XThe value of X
Float:numThe number to use
ReturnsThe Quadratic Root of the number
QuadraticRootCalc(52.2,16.2,78.9);

By: Allan

Wait

Makes the server wait a certain amount of time before processing the next request
Parameters:
(time)
timeThe time in miliseconds for the server to wait
Wait(1000);

wiper

Clears the players Chat Screen
Parameters:
(playerid)
playeridThe playerid's chat screen to wipe
wiper(1);

By: Spectre

Dini (Dini.inc)

Here you can find an easy way to store and save variables and strings into files. Download here: dini 1.1.4.

dini_Exists

Checks whether a file exists
Parameters:
(filename[])
filename[]The filename to check
ReturnsFalse if it doesn't exist and true if it does
dini_Exists("acertainfile.txt");

By: DracoBlue

dini_Remove

Remove's a file
Parameters:
(filename[])
filename[]The filename to remove
ReturnsTrue if it removes it, False if it doesn't
dini_Remove("acertainfile.txt");

By: DracoBlue

dini_Create

Create's a file
Parameters:
(filename[])
filename[]The filename to create
ReturnsTrue if it creates it, False if it doesn't
dini_Create("acertainfile.txt");

By: DracoBlue

dini_Set

Puts a string in a file using another string to call as a reference
Parameters:
(filename[],key[],value[])
filename[]The filename to open
key[]The value to save in
value[]The string to save
ReturnsTrue if it exists, False if it doesn't
dini_Set("acertainfile.txt","Servername","A SA:MP Server");

By: DracoBlue

dini_IntSet

Puts an integer in a file using another string to call as a reference
Parameters:
(filename[],key[],value)
filename[]The filename to open
key[]The value to save in
valueThe integer to save
ReturnsTrue if it exists, False if it doesn't
dini_Set("acertainfile.txt","Servermaxplayers",50);

By: DracoBlue

dini_BoolSet

Puts a bool in a file using another string to call as a reference
Parameters:
(filename[],key[],value)
filename[]The filename to open
key[]The value to save in
valueThe bool to save
ReturnsTrue if it exists, False if it doesn't
dini_BoolSet("acertainfile.txt","Serveractive",true);

By: DracoBlue

dini_FloatSet

Puts a Float in a file using another string to call as a reference
Parameters:
(filename[],key[],Float:value)
filename[]The filename to open
key[]The value to save in
Float:valueThe Float to save
ReturnsTrue if it exists, False if it doesn't
dini_FloatSet("acertainfile.txt","Xpos",2345.67);

By: DracoBlue

Personal tools