Useful Functions
From SA-MP Wiki
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:
model | The modelid of the pickup to spawn |
type | The typeid of the pickup to spawn |
Float:X | The x value of the spawn position |
Float:Y | The y value of the spawn position |
Float:Z | The z value of the spawn position |
By: Sacky
AddStaticVehicle2
Description:
modelid | The modelid of the vehicle to spawn |
Float:spawn_x | The x value of the spawn position |
Float:spawn_y | The y value of the spawn position |
Float:spawn_z | The z value of the spawn position |
Float:z_angle | The angle value of the spawn position |
color1 | The first colour of the vehicle |
color1 | The second colour of the vehicle |
By: Sacky
AddStaticVehicleEx2
Description:
modelid | The modelid of the vehicle to spawn |
Float:spawn_x | The x value of the spawn position |
Float:spawn_y | The y value of the spawn position |
Float:spawn_z | The z value of the spawn position |
Float:z_angle | The angle value of the spawn position |
color1 | The first colour of the vehicle |
color1 | The second colour of the vehicle |
respawn_delay | The amount of time in miliseconds the vehicle will wait before respawning when it dies |
By: Sacky
AddStaticVehicleLine
Description:
Modelid | The 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:Z | The z value of the starting position |
Float:Z_Angle | The angle value of the spawn position for the cars in the line |
MaxAmount | The amount of cars in the line |
By: Sacky
BanTeam
Description:
team | The teamid to ban |
By: dyraXon
ConvertSeconds
Description:
time | The amount of seconds as an integer |
Return Values:
By: El Presy
DegreesToRadians
Description:
Float:degrees | The degree you want to convert |
Return Values:
By: Sacky
encrypt
Description:
string[] | The string you want to encrypt |
Return Values:
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:
Float:min | The minimum the random float can be |
Float:max | The maximum the random float can be |
Return Values:
By: Y_Less
GameTextCheck
Description:
string[] | The string to be checked |
Return Values:
By: Kamazy
GameTextForTeam
Description:
team | The team you want the message sent to |
text[] | The text to be sent |
time | The time for the text to remain on the screen |
style | The style of the text |
By: Y_Less
GetClosestCar
Description:
playerid | The first playerid to parse into the function |
Return Values:
By: Darkrealm
GetClosestPlayer
Description:
playerid | The first playerid to parse into the function |
Return Values:
By: Slick
GetCurrentPosition
Description:
playerid | The playerid to get the position from |
Return Values:
By: Sacky
GetDistanceBetweenPlayers
Description:
playerid | The first playerid to parse into the function |
playerid2 | The second playerid to parse into the function |
Return Values:
By: Slick
GetDistanceToCar
Description:
playerid | The player to parse |
carid | The vehicleid to parse |
Return Values:
By: Darkrealm
GetPickups
Description:
Return Values:
By: Sacky
GetPlayerAcceleration
Description:
playerid | The player you want to get the speed from |
Return Values:
By: Sacky
GetPlayerDistanceToPoint
Description:
playerid | The player you wish to query |
Float:x | The x value of the point |
Float:y | The y value of the point |
Return Values:
By: Sacky
GetPlayerDistanceToPointEx
Description:
playerid | The player you wish to query |
Float:x | The x value of the point |
Float:y | The y value of the point |
Float:z | The z value of the point |
Return Values:
By: Sacky
GetPlayerId
Description:
playername[] | The name you want to get the playerid from |
Return Values:
By: Y_Less
GetPlayers
Description:
Return Values:
By: rapidZ
GetPlayerSkin
Description:
playerid | The player you want to get the skin from |
Return Values:
By: Sacky
GetPlayerSpeed
Description:
playerid | The player you want to get the speed from |
Return Values:
By: Sacky
GetPointDistanceToPoint
Description:
Float:x | The x value of the first point |
Float:y | The y value of the first point |
Float:x2 | The x value of the second point |
Float:y2 | The y value of the second point |
Return Values:
By: iRaiDeN
GetPointDistanceToPointEx
Description:
Float:x | The x value of the first point |
Float:y | The y value of the first point |
Float:z | The z value of the first point |
Float:x2 | The x value of the second point |
Float:y2 | The y value of the second point |
Float:z2 | The z value of the first point |
Return Values:
By: Sacky
GetVehicleClass
Description:
vehicleid | The id of the vehicle to return the class from |
Return Values:
By: Sacky
GetVehicleName
Description:
vehicleid | The id of the vehicle to return the class from |
Return Values:
By: Sacky
GetVehicleType
Description:
vehicleid | The id of the vehicle to return the type from |
Return Values:
By: Sacky
GetVehicleZAngle
Description:
vehicleid | The id of the vehicle to return the angle from |
Return Values:
By: Sacky
GetVehicles
Description:
Return Values:
By: Sacky
GivePlayerWeaponAlt
Description:
playerid | The playerid to give the weapon to |
weaponid | The weaponid you want to give to the player |
ammo | How much ammo to give to the player |
By: Allan
GivePlayerWeaponEx
Description:
playerid | The playerid to give the weapon to |
... | The weaponid you want to give to the player, also specify the ammo |
By: Peter
GiveTeamMoney
Description:
team | The team to give the money to |
amount | The amount of money to give to the team |
By: Hellomy
HexToRGBA
Description:
colour | The hexidecimal colour |
&r | The red colour to store |
&g | The green colour to store |
&b | The blue colour to store |
&a | The alpha colour to store |
By: Betamaster
icos
Description:
Float:adj | The length of the adjacent side |
Float:hyp | The length of the hypotenuse side |
Return Values:
By: Sacky
isin
Description:
Float:opp | The length of the opposite side |
Float:hyp | The length of the hypotenuse side |
Return Values:
By: Sacky
IsNumeric
Description:
string[] | The string you want to check |
Return Values:
By: Mike
IsPickupConnected
Description:
pickupid | The pickup id you want to query |
Return Values:
By: Sacky
IsPlayerInAnyInterior
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerInArea
Description:
playerid | The playerid you want to query |
Float:minx | The minimum x value for the area |
Float:miny | The minimum y value for the area |
Float:maxx | The maximum x value for the area |
Float:maxy | The maximum y value for the area |
Return Values:
By: Y_Less
IsPlayerInAreaEx
Description:
playerid | The playerid you want to query |
... | The x and y values for your area |
Return Values:
By: kool
IsPlayerInBoat
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerInCar
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerInCircle
Description:
playerid | The playerid you want to query |
Float:x | The x value of the center of the circle |
Float:y | The y value of the center of the circle |
radius | The radius of the circle |
Return Values:
By: Sacky
IsPlayerInCube
Description:
playerid | The playerid you want to query |
xmin | The minimum x value of the cube |
ymin | The minimum y value of the cube |
zmin | The minimum z value of the cube |
xmax | The maximum x value of the cube |
ymax | The maximum y value of the cube |
zmax | The maximum z value of the cube |
Return Values:
By: 50p
IsPlayerInHelicopter
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerInMonsterTruck
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerInPlane
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerInSphere
Description:
playerid | The playerid you want to query |
Float:x | The x value of the center of the sphere |
Float:y | The y value of the center of the sphere |
Float:z | The z value of the center of the sphere |
radius | The radius of the circle |
Return Values:
By: Sacky
IsPlayerInQuad
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerInRange
Description:
playerid | The playerid you want to query |
Float:Range | The range the player can be in |
Float:Z_Range | The height range the player can be in |
Float:tar_x | The x value for the point |
Float:tar_y | The y value for the point |
Float:tar_z | The z value for the point |
Return Values:
By: Simon
IsPlayerDriver
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerOnBicycle
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerOnBike
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerOnFoot
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsPlayerPassenger
Description:
playerid | The playerid you want to query |
Return Values:
By: Sacky
IsTeamInArea
Description:
team | The teamid you want to query |
Float:minx | The minimum x value for the area |
Float:miny | The minimum y value for the area |
Float:maxx | The maximum x value for the area |
Float:maxy | The maximum y value for the area |
Return Values:
By: dyraXon
IsVehicleConnected
Description:
vehicleid | The vehicle's id you want to query |
Return Values:
By: Sacky
IsVehicleInUse
Description:
vehicleid | The vehicle's id you want to query |
Return Values:
By: Sacky
itan
Description:
Float:opp | The length of the opposite side |
Float:adj | The length of the adjacent side |
Return Values:
By: Sacky
KickTeam
Description:
team | The teamid to kick |
By: Sacky
left
Description:
source[] | The string you want to take the left characters from |
len | The number of characters from the left you want to return |
Return Values:
By: Y_Less
lengthdir_x
Description:
Float:length | How long the line is |
Float:angle | The angle in which to draw the virtual line |
Return Values:
By: Slick
lengthdir_y
Description:
Float:length | How long the line is |
Float:angle | The angle in which to draw the virtual line |
Return Values:
By: Slick
minrand
Description:
min | The minimum number the random integer can be |
max | The maximum number the random integer can be |
Return Values:
By: Y_Less
mktime
Description:
hour | The hour integer to pass |
minute | The minute integer to pass |
second | The second integer to pass |
day | The day integer to pass |
month | The month integer to pass |
year | The year integer to pass |
Return Values:
By: mabako
parsecommand
Description:
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 |
parcount | The number of spaces there are |
Return Values:
By: Y_Less
PlayerID
Description:
partofname[] | The part of the players name you want to get the ID from |
Return Values:
By: DracoBlue
PlayerPlaySoundEx
Description:
playerid | The ID of the player you want to play the sound for |
soundid | The ID of the sound you want to play |
By: Sacky
RadiansToDegrees
Description:
Float:radian | The radian you want to convert |
Return Values:
By: Sacky
ResetVehicleSpawnPos
Description:
vehicleid | The vehicleid of vehicle you want to reset |
By: Sacky
RetStr
Description:
num | The number you want to convert into a string |
Return Values:
By: Y_Less
ReturnPlayerName
Description:
playerid | The playerid you want to get the name from |
Return Values:
By: Y_Less
RGBAToHex
Description:
r | The red value of the colour |
g | The green value of the colour |
b | The blue value of the colour |
a | The alpha value of the colour |
By: Betamaster
right
Description:
source[] | The string you want to take the right characters from |
len | The number of characters from the right you want to return |
Return Values:
By: Y_Less
SendClientMessageToAdmins
Description:
colour | The colour you want the Client Message to be |
str[] | The text to send them |
By: Mike
SendClientMessageToAllOthers
Description:
playerid | The playerid you don't want the client message to be sent to |
color | The colour to send the message in |
message[] | The message to send |
By: yom
SendClientMessageToTeam
Description:
team | The team you want to send the client message to |
color | The color (in hexidecimal format) that you want to send the text in |
text[] | The text to send the team |
By: Y_Less
SendFormattedGameTextToPlayer
Description:
playerid | The playerid you want to see the gametext |
msg[] | The text you want the gametext to be |
time | The amount of time the gametext should linger on the screen |
style | The style to send the gametext in |
define | The variable you want to put in |
By: Allan
SendFormattedGameTextToAll
Description:
msg[] | The text you want the gametext to be |
time | The amount of time the gametext should linger on the screen |
style | The style to send the gametext in |
define | The variable you want to put in |
By: Allan
SetPlayerColourAlpha
Description:
playerid | The id of the player you want to set the alpha colour to |
alpha | The alpha value to set for the player |
By: Betamaster
SetPlayerMoney
Description:
playerid | The id of the player you want to set the money to |
money | The amount of money to set |
By: DracoBlue
SetPlayerPosEx
Description:
playerid | The id of the player you want to set position |
Float:X | The x value of the position |
Float:Y | The y value of the position |
Float:Z | The z value of the position |
Float:Ang | The angle value of the position |
Int | The interior id of the position |
By: Kamazy
SetTeamScore
Description:
team | The id of the team you'd like to set a score for |
score | The score to set |
By: Hellomy
SetTeamPos
Description:
team | The id of the team you'd like to set position |
x | The x value of the position |
y | The y value of the position |
z | The z value of the position |
By: dyraXon
SetVehicleRespawnPos
Description:
vehicleid | The id of the vehicle to reset its spawn |
Float:x | The x value for the spawn position |
Float:y | The y value for the spawn position |
Float:z | The z value for the spawn position |
Float:angle | The angle value for the spawn position |
By: Sacky
str_replace
Description:
search[] | The string to search for |
replace[] | The strings to replace |
source[] | The original string |
Return Values:
By: Tratulla
strrest
Description:
string[] | The full string to be split |
&index | The character to split the string at |
Return Values:
By: mabako
strtok
Description:
string[] | The full string to be split |
&index | The character to split the string at |
Return Values:
By: Compuphase
TakePlayerMoney
Description:
playerid | The ID of the player to take money from |
money | The amount of money to take |
By: Sacky
timeconvert_seconds
Description:
time | The number of seconds to convert |
Return Values:
By: Sacky
TwoWayRand
Description:
value | The value to randomise |
Return Values:
By: Allan
ValidEmail
Description:
email[] | The email as a string |
Return Values:
By: DracoBlue
VehicleDriverID
Description:
vehicleid | The ID of the vehicle to get the driver from |
Return Values:
By: DracoBlue
VehicleDriverName
Description:
vehicleid | The ID of the vehicle to get the driver from |
Return Values:
By: Sacky
QuadraticRootCalc
Description:
Float:Xsq | The square root of x |
Float:X | The value of X |
Float:num | The number to use |
Return Values:
By: Allan
Wait
Description:
time | The time in miliseconds for the server to wait |
wiper
Description:
playerid | The playerid's chat screen to wipe |
By: Spectre
Dini (Dini.inc)
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:
filename[] | The filename to check |
Return Values:
dini_Remove
Description:
filename[] | The filename to remove |
Return Values:
dini_Create
Description:
filename[] | The filename to create |
Return Values:
dini_Set
Description:
filename[] | The filename to open |
key[] | The value to save in |
value[] | The string to save |
Return Values:
dini_IntSet
Description:
filename[] | The filename to open |
key[] | The value to save in |
value | The integer to save |
Return Values:
dini_BoolSet
Description:
filename[] | The filename to open |
key[] | The value to save in |
value | The bool to save |
Return Values:
dini_FloatSet
Description:
filename[] | The filename to open |
key[] | The value to save in |
Float:value | The Float to save |
Return Values: