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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

By: dyraXon

ConvertSeconds

Description:

Converts an integer of seconds into a string that will display hours,minutes and seconds
Parameters:
(time)
timeThe amount of seconds as an integer

Return Values:

The converted amount of seconds into hours, minutes, and seconds (Displays like: x hours, x minutes and x seconds
ConvertSeconds(12000);

By: El Presy

DegreesToRadians

Description:

Converts degree's to radians
Parameters:
(Float:degrees)
Float:degreesThe degree you want to convert

Return Values:

The conversion of the degree to a radian
DegreesToRadians(270);

By: Sacky

encrypt

Description:

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

Return Values:

The 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

Description:

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

Return Values:

The random float between the minimum and maximum values
floatrand(1.2,5.6);

By: Y_Less

GameTextCheck

Description:

Returns 1 if the text won't crash your server, 0 if it will
Parameters:
(string[])
string[]The string to be checked

Return Values:

The 1 if the text is ok, 0 if it isn't
GameTextCheck("Hello World");

By: Kamazy

GameTextForTeam

Description:

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

Description:

Returns the ID of the closest car
Parameters:
(playerid)
playeridThe first playerid to parse into the function

Return Values:

The closest vehicle to the player
GetClosestCar(1);

By: Darkrealm

GetClosestPlayer

Description:

Returns the ID of the closest player
Parameters:
(playerid)
playeridThe first playerid to parse into the function

Return Values:

The closest player to the specified player
GetClosestPlayer(1);

By: Slick

GetCurrentPosition

Description:

Returns the current position as a string
Parameters:
(playerid)
playeridThe playerid to get the position from

Return Values:

The current position in string format
GetCurrentPosition(1);

By: Sacky

GetDistanceBetweenPlayers

Description:

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

Return Values:

The distance between the players in meters as an integer
GetDistanceBetweenPlayers(1,2);

By: Slick

GetDistanceToCar

Description:

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

Return Values:

The distance between the player and the vehicle
GetDistanceToCar(1,2);

By: Darkrealm

GetPickups

Description:

Returns the number of pickups on the server

Return Values:

The number of pickups present on the server
GetPickups();

By: Sacky

GetPlayerAcceleration

Description:

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

Return Values:

The acceleration of the player
GetPlayerAcceleration(5);

By: Sacky

GetPlayerDistanceToPoint

Description:

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

Return Values:

The distance to the point
GetPlayerDistanceToPoint(1,1.9,8.5);

By: Sacky

GetPlayerDistanceToPointEx

Description:

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

Return Values:

The distance to the point
GetPlayerDistanceToPoint(1,1.9,8.5,9.5);

By: Sacky

GetPlayerId

Description:

Returns the player ID from a playername
Parameters:
(playername[])
playername[]The name you want to get the playerid from

Return Values:

The playerid (if none then returns -1)
GetPlayerId("Y_Less");

By: Y_Less

GetPlayers

Description:

Returns the number of players on the server

Return Values:

The number of players on the server
GetPlayers();

By: rapidZ

GetPlayerSkin

Description:

Returns the class of the players skin
Parameters:
(playerid)
playeridThe player you want to get the skin from

Return Values:

The skin id (0 if invalid)
GetPlayerSkin(5);

By: Sacky

GetPlayerSpeed

Description:

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

Return Values:

The speed of the player
GetPlayerSpeed(5);

By: Sacky

GetPointDistanceToPoint

Description:

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

Return Values:

The distance between the 2 points
GetPointDistanceToPoint(12.3,14.5,109.7,88.9);

By: iRaiDeN

GetPointDistanceToPointEx

Description:

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

Return Values:

The distance between the 2 points
GetPointDistanceToPointEx(12.3,14.5,15.6,109.7,88.9,13.4);

By: Sacky

GetVehicleClass

Description:

Returns the Vehicleclass/modelid (Needs AddStaticVehicle2 or AddStaticVehicleEx2)
Parameters:
(vehicleid)
vehicleidThe id of the vehicle to return the class from

Return Values:

The vehicle class (0 if invalid vehicle)
GetVehicleClass(1);

By: Sacky

GetVehicleName

Description:

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

Return Values:

The name of a vehicle (by class)
GetVehicleName(1);

By: Sacky

GetVehicleType

Description:

Returns the type of a vehicle (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:
(vehicleid)
vehicleidThe id of the vehicle to return the type from

Return Values:

The type of a vehicle (eg. CAR or BOAT)
GetVehicleType(1);

By: Sacky

GetVehicleZAngle

Description:

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

Return Values:

The angle of the vehicle
GetVehicleZAngle(1);

By: Sacky

GetVehicles

Description:

Returns the number of vehicles on the server

Return Values:

The number of vehicles present on the server
GetVehicles();

By: Sacky

GivePlayerWeaponAlt

Description:

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

Description:

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

Description:

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

Description:

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

Description:

Inverse Trigonomic Function (cosine)
Parameters:
(Float:adj,Float:hyp)
Float:adjThe length of the adjacent side
Float:hypThe length of the hypotenuse side

Return Values:

The processed inverse trigonomic equation (Float)
icos(5.3,4.6);

By: Sacky

isin

Description:

Inverse Trigonomic Function (sine)
Parameters:
(Float:opp,Float:hyp)
Float:oppThe length of the opposite side
Float:hypThe length of the hypotenuse side

Return Values:

The processed inverse trigonomic equation (Float)
isin(5.3,4.6);

By: Sacky

IsNumeric

Description:

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

Return Values:

1 if numeric, 0 if not numeric
IsNumeric("12");

By: Mike

IsPickupConnected

Description:

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

Return Values:

1 if it is connected, 0 if it isn't
IsPickupConnected(254);

By: Sacky

IsPlayerInAnyInterior

Description:

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

Return Values:

1 if they are in an interior, 0 if they aren't
IsPlayerInAnyInterior(5);

By: Sacky

IsPlayerInArea

Description:

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

Return Values:

1 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

Description:

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

Return Values:

1 if they are in the area, 0 if they aren't
IsPlayerInArea(2, 2.0, 2.0, 4.0, 4.0);

By: kool

IsPlayerInBoat

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are in a boat, 0 if they aren't
IsPlayerInBoat(5);

By: Sacky

IsPlayerInCar

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are in a car, 0 if they aren't
IsPlayerInCar(5);

By: Sacky

IsPlayerInCircle

Description:

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

Return Values:

1 if they are in the area, 0 if they aren't
IsPlayerInCircle(2,13.9,14.8,5);

By: Sacky

IsPlayerInCube

Description:

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

Return Values:

1 if they are in the area, 0 if they aren't
IsPlayerInCube(2,2,3,4,1,2,3);

By: 50p

IsPlayerInHelicopter

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are in a helicopter, 0 if they aren't
IsPlayerInHelicopter(5);

By: Sacky

IsPlayerInMonsterTruck

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are in a monster truck, 0 if they aren't
IsPlayerInMonsterTruck(5);

By: Sacky

IsPlayerInPlane

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are in a plane, 0 if they aren't
IsPlayerInPlane(5);

By: Sacky

IsPlayerInSphere

Description:

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

Return Values:

1 if they are in the spherer, 0 if they aren't
IsPlayerInCircle(2,13.9,14.8,5,9.7);

By: Sacky

IsPlayerInQuad

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are in a quad, 0 if they aren't
IsPlayerInQuad(5);

By: Sacky

IsPlayerInRange

Description:

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

Return Values:

1 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

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are a driver, 0 if they aren't
IsPlayerDriver(5);

By: Sacky

IsPlayerOnBicycle

Description:

Returns the 1 if they are, returns 0 if they arent (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are on a bicycle, 0 if they aren't
IsPlayerOnBicycle(5);

By: Sacky

IsPlayerOnBike

Description:

Returns the 1 if they are, returns 0 if they arent (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are on a bike, 0 if they aren't
IsPlayerOnBike(5);

By: Sacky

IsPlayerOnFoot

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are on foot, 0 if they aren't
IsPlayerOnFoot(5);

By: Sacky

IsPlayerPassenger

Description:

Returns the 1 if they are, returns 0 if they arent
Parameters:
(playerid)
playeridThe playerid you want to query

Return Values:

1 if they are a passenger, 0 if they aren't
IsPlayerPassenger(5);

By: Sacky

IsTeamInArea

Description:

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

Return Values:

1 if they are in the area, 0 if they aren't
IsTeamInArea(2, 2.0, 2.0, 4.0, 4.0);

By: dyraXon

IsVehicleConnected

Description:

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

Return Values:

1 if it is connected, 0 if it isn't
IsVehicleConnected(254);

By: Sacky

IsVehicleInUse

Description:

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

Return Values:

1 if it is in use, 0 if it isn't
IsVehicleInUse(254);

By: Sacky

itan

Description:

Inverse Trigonomic Function (tangent)
Parameters:
(Float:opp,Float:adj)
Float:oppThe length of the opposite side
Float:adjThe length of the adjacent side

Return Values:

The processed inverse trigonomic equation (Float)
itan(5.3,4.6);

By: Sacky

KickTeam

Description:

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

By: Sacky

left

Description:

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

Return Values:

The number of characters from the left specified in the len
left("Hello",1);

By: Y_Less

lengthdir_x

Description:

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

Return Values:

The length of the line
lengthdir_x(32.4,170.9);

By: Slick

lengthdir_y

Description:

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

Return Values:

The length of the line
lengthdir_y(32.4,170.9);

By: Slick

minrand

Description:

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

Return Values:

The random number between the min and max as an integer
minrand(1,5);

By: Y_Less

mktime

Description:

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

Return Values:

seconds since the beginning of unix time/timestamp
mktime(1,1,1,1,1,2005);

By: mabako

parsecommand

Description:

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

Return Values:

Whether the text is valid
parsecommand("/test test","/test","test",1);

By: Y_Less

PlayerID

Description:

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

Return Values:

The Players ID (if valid)
PlayerID("NoV");

By: DracoBlue

PlayerPlaySoundEx

Description:

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

Description:

Converts radians to degree's
Parameters:
(Float:radian)
Float:radianThe radian you want to convert

Return Values:

The conversion of the radian to a degree
RadiansToDegrees(0.26);

By: Sacky

ResetVehicleSpawnPos

Description:

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

Description:

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

Return Values:

The string representation of a number
RetStr(11);

By: Y_Less

ReturnPlayerName

Description:

Returns the playername from the playerid
Parameters:
(playerid)
playeridThe playerid you want to get the name from

Return Values:

The playername as a string
ReturnPlayerName(0);

By: Y_Less

RGBAToHex

Description:

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

Description:

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

Return Values:

The number of characters from the right specified in the len
right("Hello",1);

By: Y_Less

SendClientMessageToAdmins

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Description:

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

Return Values:

The string formatted by the replace
str_replace("o","1","Hello World");

By: Tratulla

strrest

Description:

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

Return Values:

The split string
strrest("Hello World Today",0);

By: mabako

strtok

Description:

Returns the string split by the index
Parameters:
(string[], &index)
string[]The full string to be split
&indexThe character to split the string at

Return Values:

The split string
strtok("Hello World",0);

By: Compuphase

TakePlayerMoney

Description:

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

Description:

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

Return Values:

The converted seconds in a minutes:seconds format
timeconvert_seconds(181);

By: Sacky

TwoWayRand

Description:

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

Return Values:

The randomised number in a negative integer
TwoWayRand(10);

By: Allan

ValidEmail

Description:

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

Return Values:

True if the email is valid, false if it isn't
ValidEmail("user1@hotmail.com");

By: DracoBlue

VehicleDriverID

Description:

Returns the playerid of the driver of the vehicle
Parameters:
(vehicleid)
vehicleidThe ID of the vehicle to get the driver from

Return Values:

The playerid if someone is driving the vehicle, -1 if no one is driving it
VehicleDriverID(52);

By: DracoBlue

VehicleDriverName

Description:

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

Return Values:

The driver name of the vehicle
VehicleDriverName(52);

By: Sacky

QuadraticRootCalc

Description:

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

Return Values:

The Quadratic Root of the number
QuadraticRootCalc(52.2,16.2,78.9);

By: Allan

Wait

Description:

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

Description:

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

By: Spectre

Dini (Dini.inc)

Image:50px-Ambox_outdated_serious.png This section is outdated. It may use methods or functions which no longer exist or which are deemed obsolete by the community. Caution is advised.


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

dini_Exists

Description:

Checks whether a file exists
Parameters:
(filename[])
filename[]The filename to check

Return Values:

False if it doesn't exist and true if it does
dini_Exists("acertainfile.txt");

dini_Remove

Description:

Remove's a file
Parameters:
(filename[])
filename[]The filename to remove

Return Values:

True if it removes it, False if it doesn't
dini_Remove("acertainfile.txt");

dini_Create

Description:

Create's a file
Parameters:
(filename[])
filename[]The filename to create

Return Values:

True if it creates it, False if it doesn't
dini_Create("acertainfile.txt");

dini_Set

Description:

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

Return Values:

True if it exists, False if it doesn't
dini_Set("acertainfile.txt","Servername","A SA:MP Server");

dini_IntSet

Description:

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

Return Values:

True if it exists, False if it doesn't
dini_Set("acertainfile.txt","Servermaxplayers",50);

dini_BoolSet

Description:

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

Return Values:

True if it exists, False if it doesn't
dini_BoolSet("acertainfile.txt","Serveractive",true);

dini_FloatSet

Description:

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

Return Values:

True if it exists, False if it doesn't
dini_FloatSet("acertainfile.txt","Xpos",2345.67);
Personal tools
Navigation
Toolbox