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.
Allows the saving of models, types and pickup positions, it is essential for OnPlayerPickupItem
Parameters:({{{1}}})
| 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 |
AddStaticPickup2(50,2,29.5,36.5,49.8);
By: Sacky
Enables saving of vehicleclasses to a script (Alot of vehicle functions rely on this)
Parameters:({{{1}}})
| 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 |
AddStaticVehicle2(50,2.6,29.5,36.5,49.8,6,7);
By: Sacky
Allows the saving of models to the AddStaticVehicleEx function, for people who prefer this function to AddStaticVehicle
Parameters:({{{1}}})
| 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 |
AddStaticVehicleEx2(50,2.6,29.5,36.5,49.8,6,7,7000);
By: Sacky
Makes a line of vehicle's
Parameters:({{{1}}})
| 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 |
AddStaticVehicleLine(50,2.6,3.8,7.4,270.0,5);
By: Sacky
Bans all the players in an entire team
Parameters:({{{1}}})
BanTeam(1);
By: dyraXon
Converts an integer of seconds into a string that will display hours,minutes and seconds
Parameters:({{{1}}})
| time | The amount of seconds as an integer |
| Returns | The converted amount of seconds into hours, minutes, and seconds (Displays like: x hours, x minutes and x seconds |
ConvertSeconds(12000);
By: El Presy
Converts degree's to radians
Parameters:({{{1}}})
| Float:degrees | The degree you want to convert |
| Returns | The conversion of the degree to a radian |
DegreesToRadians(270);
By: Sacky
This function allows you to encrypt strings, very useful for storing passwords without fear of someone cracking them
Parameters:({{{1}}})
| string[] | The string you want to encrypt |
| Returns | 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
Generates a random number with 2 decimal places
Parameters:({{{1}}})
| Float:min | The minimum the random float can be |
| Float:max | The maximum the random float can be |
| Returns | The random float between the minimum and maximum values |
floatrand(1.2,5.6);
By: Y_Less
Returns 1 if the text won't crash your server, 0 if it will
Parameters:({{{1}}})
| string[] | The string to be checked |
| Returns | The 1 if the text is ok, 0 if it isn't |
GameTextCheck("Hello World");
By: Kamazy
Sends GameText to all the players in the specified team, the same as GameTextForPlayer except you can specify the team
Parameters:({{{1}}})
| 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 |
GameTextForTeam(1,"Hello",1000,3);
By: Y_Less
Returns the ID of the closest car
Parameters:({{{1}}})
| playerid | The first playerid to parse into the function |
| Returns | The closest vehicle to the player |
GetClosestCar(1);
By: Darkrealm
Returns the ID of the closest player
Parameters:({{{1}}})
| playerid | The first playerid to parse into the function |
| Returns | The closest player to the specified player |
GetClosestPlayer(1);
By: Slick
Returns the current position as a string
Parameters:({{{1}}})
| playerid | The playerid to get the position from |
| Returns | The current position in string format |
GetCurrentPosition(1);
By: Sacky
Returns the distance between players as an integer
Parameters:({{{1}}})
| playerid | The first playerid to parse into the function |
| playerid2 | The second playerid to parse into the function |
| Returns | The distance between the players in meters as an integer |
GetDistanceBetweenPlayers(1,2);
By: Slick
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:({{{1}}})
| playerid | The player to parse |
| carid | The vehicleid to parse |
| Returns | The distance between the player and the vehicle |
GetDistanceToCar(1,2);
By: Darkrealm
Returns the number of pickups on the server
| Returns | The number of pickups present on the server |
GetPickups();
By: Sacky
Returns the player accelaration in MPH as an integer, it requires the uftimer to be implemented in the gamemode
Parameters:({{{1}}})
| playerid | The player you want to get the speed from |
| Returns | The acceleration of the player |
GetPlayerAcceleration(5);
By: Sacky
Returns the player distance to a 2D point
Parameters:({{{1}}})
| playerid | The player you wish to query |
| Float:x | The x value of the point |
| Float:y | The y value of the point |
| Returns | The distance to the point |
GetPlayerDistanceToPoint(1,1.9,8.5);
By: Sacky
Returns the player distance to a 3D point
Parameters:({{{1}}})
| 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 |
| Returns | The distance to the point |
GetPlayerDistanceToPoint(1,1.9,8.5,9.5);
By: Sacky
Returns the player ID from a playername
Parameters:({{{1}}})
| playername[] | The name you want to get the playerid from |
| Returns | The playerid (if none then returns -1) |
GetPlayerId("Y_Less");
By: Y_Less
Returns the number of players on the server
| Returns | The number of players on the server |
GetPlayers();
By: rapidZ
Returns the class of the players skin
Parameters:({{{1}}})
| playerid | The player you want to get the skin from |
| Returns | The skin id (0 if invalid) |
GetPlayerSkin(5);
By: Sacky
Returns the player speed in KMPH as a float, it requires the uftimer to be implemented in the gamemode
Parameters:({{{1}}})
| playerid | The player you want to get the speed from |
| Returns | The speed of the player |
GetPlayerSpeed(5);
By: Sacky
Returns the distance between 1 x and y value and another x and y value
Parameters:({{{1}}})
| 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 |
| Returns | The distance between the 2 points |
GetPointDistanceToPoint(12.3,14.5,109.7,88.9);
By: Sacky
Returns the distance between 1 x,y and z value and another x,y and z value
Parameters:({{{1}}})
| 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 |
| Returns | The distance between the 2 points |
GetPointDistanceToPointEx(12.3,14.5,15.6,109.7,88.9,13.4);
By: Sacky
Returns the Vehicleclass/modelid (Needs AddStaticVehicle2 or AddStaticVehicleEx2)
Parameters:({{{1}}})
| vehicleid | The id of the vehicle to return the class from |
| Returns | The vehicle class (0 if invalid vehicle) |
GetVehicleClass(1);
By: Sacky
Returns the name of a vehicle (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:({{{1}}})
| vehicleid | The id of the vehicle to return the class from |
| Returns | The name of a vehicle (by class) |
GetVehicleName(1);
By: Sacky
Returns the type of a vehicle (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:({{{1}}})
| vehicleid | The id of the vehicle to return the type from |
| Returns | The type of a vehicle (eg. CAR or BOAT) |
GetVehicleType(1);
By: Sacky
Returns the vehicles angle
Parameters:({{{1}}})
| vehicleid | The id of the vehicle to return the angle from |
| Returns | The angle of the vehicle |
GetVehicleZAngle(1);
By: Sacky
Returns the number of vehicles on the server
| Returns | The number of vehicles present on the server |
GetVehicles();
By: Sacky
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:({{{1}}})
| 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 |
GivePlayerWeaponAlt(1,26,500);
By: Allan
Lets you specify an unlimited number of weapons and ammo to be given to a player
Parameters:({{{1}}})
| playerid | The 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
Gives every payer on a team a certain amount of money
Parameters:({{{1}}})
| team | The team to give the money to |
| amount | The amount of money to give to the team |
GiveTeamMoney(1,500);
By: Hellomy
Converts Hexidecimal into RGBA
Parameters:({{{1}}})
| 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 |
HexToRGBA(0xAFAFAFAA,r,g,b,a);
By: Betamaster
Inverse Trigonomic Function (cosine)
Parameters:({{{1}}})
| Float:adj | The length of the adjacent side |
| Float:hyp | The length of the hypotenuse side |
| Returns | The processed inverse trigonomic equation (Float) |
icos(5.3,4.6);
By: Sacky
Inverse Trigonomic Function (sine)
Parameters:({{{1}}})
| Float:opp | The length of the opposite side |
| Float:hyp | The length of the hypotenuse side |
| Returns | The processed inverse trigonomic equation (Float) |
isin(5.3,4.6);
By: Sacky
Returns 1 if the string is numeric, 0 if not
Parameters:({{{1}}})
| string[] | The string you want to check |
| Returns | 1 if numeric, 0 if not numeric |
IsNumeric("12");
By: Mike
Returns 1 if the pickup is connected and 0 if it isn't, it requires you to use AddStaticPickup2 rather than AddStaticPickup
Parameters:({{{1}}})
| pickupid | The pickup id you want to query |
| Returns | 1 if it is connected, 0 if it isn't |
IsPickupConnected(254);
By: Sacky
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:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are in an interior, 0 if they aren't |
IsPlayerInAnyInterior(5);
By: Sacky
Returns 1 if the player is in the area and 0 if they aren't
Parameters:({{{1}}})
| 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 |
| Returns | 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
Returns 1 if the player is in the area and 0 if they aren't
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| ... | The x and y values for your area |
| Returns | 1 if they are in the area, 0 if they aren't |
IsPlayerInArea(2, 2.0, 2.0, 4.0, 4.0);
By: kool
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are in a boat, 0 if they aren't |
IsPlayerInBoat(5);
By: Sacky
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are in a car, 0 if they aren't |
IsPlayerInCar(5);
By: Sacky
Returns 1 if the player is in the circle and 0 if they aren't
Parameters:({{{1}}})
| 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 |
| Returns | 1 if they are in the area, 0 if they aren't |
IsPlayerInCircle(2,13.9,14.8,5);
By: Sacky
Returns 1 if the player is in the cube and 0 if they aren't
Parameters:({{{1}}})
| 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 |
| Returns | 1 if they are in the area, 0 if they aren't |
IsPlayerInCube(2,2,3,4,1,2,3);
By: 50p
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are in a helicopter, 0 if they aren't |
IsPlayerInHelicopter(5);
By: Sacky
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are in a monster truck, 0 if they aren't |
IsPlayerInMonsterTruck(5);
By: Sacky
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are in a plane, 0 if they aren't |
IsPlayerInPlane(5);
By: Sacky
Returns 1 if the player is in the sphere and 0 if they aren't
Parameters:({{{1}}})
| 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 |
| Returns | 1 if they are in the spherer, 0 if they aren't |
IsPlayerInCircle(2,13.9,14.8,5,9.7);
By: Sacky
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are in a quad, 0 if they aren't |
IsPlayerInQuad(5);
By: Sacky
Returns 1 if if they are, 0 if they aren't
Parameters:({{{1}}})
| 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 |
| Returns | 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
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are a driver, 0 if they aren't |
IsPlayerDriver(5);
By: Sacky
Returns the 1 if they are, returns 0 if they arent (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are on a bicycle, 0 if they aren't |
IsPlayerOnBicycle(5);
By: Sacky
Returns the 1 if they are, returns 0 if they arent (Needs AddStaticVehicle2 or AddStaticVehicle2Ex)
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are on a bike, 0 if they aren't |
IsPlayerOnBike(5);
By: Sacky
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are on foot, 0 if they aren't |
IsPlayerOnFoot(5);
By: Sacky
Returns the 1 if they are, returns 0 if they arent
Parameters:({{{1}}})
| playerid | The playerid you want to query |
| Returns | 1 if they are a passenger, 0 if they aren't |
IsPlayerPassenger(5);
By: Sacky
Returns 1 if the team is in the area and 0 if they aren't
Parameters:({{{1}}})
| 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 |
| Returns | 1 if they are in the area, 0 if they aren't |
IsTeamInArea(2, 2.0, 2.0, 4.0, 4.0);
By: dyraXon
Returns 1 if the vehicle is connected and 0 if it isn't
Parameters:({{{1}}})
| vehicleid | The vehicle's id you want to query |
| Returns | 1 if it is connected, 0 if it isn't |
IsVehicleConnected(254);
By: Sacky
Returns 1 if the vehicle is in use and 0 if it isn't
Parameters:({{{1}}})
| vehicleid | The vehicle's id you want to query |
| Returns | 1 if it is in use, 0 if it isn't |
IsVehicleInUse(254);
By: Sacky
Inverse Trigonomic Function (tangent)
Parameters:({{{1}}})
| Float:opp | The length of the opposite side |
| Float:adj | The length of the adjacent side |
| Returns | The processed inverse trigonomic equation (Float) |
itan(5.3,4.6);
By: Sacky
Kicks all the players in an entire team
Parameters:({{{1}}})
KickTeam(1);
By: Sacky
Returns the first characters in the string, it will return how many you set in the len
Parameters:({{{1}}})
| source[] | The string you want to take the left characters from |
| len | The number of characters from the left you want to return |
| Returns | The number of characters from the left specified in the len |
left("Hello",1);
By: Y_Less
Returns the position relative to the current position taking angle and distance as the arguments
Parameters:({{{1}}})
| Float:length | How long the line is |
| Float:angle | The angle in which to draw the virtual line |
| Returns | The length of the line |
lengthdir_x(32.4,170.9);
By: Slick
Returns the position relative to the current position taking angle and distance as the arguments
Parameters:({{{1}}})
| Float:length | How long the line is |
| Float:angle | The angle in which to draw the virtual line |
| Returns | The length of the line |
lengthdir_y(32.4,170.9);
By: Slick
Generates a random integer between the minimum and maximum numbers set
Parameters:({{{1}}})
| min | The minimum number the random integer can be |
| max | The maximum number the random integer can be |
| Returns | The random number between the min and max as an integer |
minrand(1,5);
By: Y_Less
Returns the unix-timestamp of a date/time, equivalent to PHP's one:
mktime on php.net
Parameters:({{{1}}})
| 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 |
| Returns | seconds since the beginning of unix time/timestamp |
mktime(1,1,1,1,1,2005);
By: mabako
This function takes a command passed to OnPlayerCommandText and splits it into the command and the rest
Parameters:({{{1}}})
| 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 |
| Returns | Whether the text is valid |
parsecommand("/test test","/test","test",1);
By: Y_Less
Returns the playerid by detecting players who have a part of a playername in them
Parameters:({{{1}}})
| partofname[] | The part of the players name you want to get the ID from |
| Returns | The Players ID (if valid) |
PlayerID("NoV");
By: DracoBlue
Plays a sound to a player exactly where the player is
Parameters:({{{1}}})
| playerid | The ID of the player you want to play the sound for |
| soundid | The ID of the sound you want to play |
PlayerPlaySoundEx(1,205);
By: Sacky
Converts radians to degree's
Parameters:({{{1}}})
| Float:radian | The radian you want to convert |
| Returns | The conversion of the radian to a degree |
RadiansToDegrees(0.26);
By: Sacky
Resets a vehicle's dynamic spawn position (proof of concept, recomend against using it)
Parameters:({{{1}}})
| vehicleid | The vehicleid of vehicle you want to reset |
ResetVehicleSpawnPos(250);
By: Sacky
Returns a string representation of a number
Parameters:({{{1}}})
| num | The number you want to convert into a string |
| Returns | The string representation of a number |
RetStr(11);
By: Y_Less
Returns the playername from the playerid
Parameters:({{{1}}})
| playerid | The playerid you want to get the name from |
| Returns | The playername as a string |
ReturnPlayerName(0);
By: Y_Less
Converts RGBA into Hexidecimal
Parameters:({{{1}}})
| 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 |
RGBAToHex(210,90,75,3);
By: Betamaster
Returns the last characters in the string, it will return how many you set in the len
Parameters:({{{1}}})
| source[] | The string you want to take the right characters from |
| len | The number of characters from the right you want to return |
| Returns | The number of characters from the right specified in the len |
right("Hello",1);
By: Y_Less
Sends a string to all the admins logged in RCON
Parameters:({{{1}}})
| colour | The colour you want the Client Message to be |
| str[] | The text to send them |
SendClientMessageToAdmins(0xAFAFAFAA,"Hello");
By: Mike
Lets you send a client message to all clients except the one you specify
Parameters:({{{1}}})
| 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 |
SendClientMessageToAllOthers(1,0xAFAFAFAA,"Hello");
By: yom
Sends a Client Message to a team, the same as SendClientMessage except you can specify the team
Parameters:({{{1}}})
| 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 |
SendClientMessageToTeam(1,0xAFAFAFAA,"Hello");
By: Y_Less
A simple, but effective GameTextToPlayer and format wrap
Parameters:({{{1}}})
| 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 |
SendFormattedGameTextToPlayer(1,"Hello",1000,3,24);
By: Allan
A simple, but effective GameTextToAll and format wrap
Parameters:({{{1}}})
| 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 |
SendFormattedGameTextToAll("Hello",1000,3,24);
By: Allan
Used to set a players alpha colour
Parameters:({{{1}}})
| playerid | The id of the player you want to set the alpha colour to |
| alpha | The alpha value to set for the player |
SetPlayerColourAlpha(1,500);
By: Betamaster
Lets you Set the player money to any amount rather than going through GivePlayerMoney and minusing to take money away
Parameters:({{{1}}})
| playerid | The id of the player you want to set the money to |
| money | The amount of money to set |
SetPlayerMoney(1,500);
By: DracoBlue
Lets you set the angle and interior as well as the position
Parameters:({{{1}}})
| 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 |
SetPlayerPosEx(1,1.1,2.2,3.3,270.9,6);
By: Kamazy
Sets a players score to everyone on a team
Parameters:({{{1}}})
| team | The id of the team you'd like to set a score for |
SetTeamScore(1,500);
By: Hellomy
Lets you set player positions to everyone on a team at once
Parameters:({{{1}}})
| 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 |
SetTeamPos(1,2,2,2);
By: dyraXon
Lets you Set the vehicle respawn position (proof of concept, recomend against using it)
Parameters:({{{1}}})
| 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 |
SetVehicleRespawnPos(1,500.5,500.5,10.5,270.0);
By: Sacky
Replaces certain aspects in a string
Parameters:({{{1}}})
| search[] | The string to search for |
| replace[] | The strings to replace |
| source[] | The original string |
| Returns | The string formatted by the replace |
str_replace("o","1","Hello World");
By: Tratulla
Returns the rest of the string splitting it at the index
Parameters:({{{1}}})
| string[] | The full string to be split |
| &index | The character to split the string at |
strrest("Hello World Today",0);
By: mabako
Returns the string split by the index
Parameters:({{{1}}})
| string[] | The full string to be split |
| &index | The character to split the string at |
strtok("Hello World",0);
By: Compuphase
The opposite to GivePlayerMoney, simply takes it away from the player
Parameters:({{{1}}})
| playerid | The ID of the player to take money from |
| money | The amount of money to take |
TakePlayerMoney(1,500);
By: Sacky
Takes an integer of seconds and then formats it so it will say "minutes:seconds", useful for countdowns
Parameters:({{{1}}})
| time | The number of seconds to convert |
| Returns | The converted seconds in a minutes:seconds format |
timeconvert_seconds(181);
By: Sacky
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:({{{1}}})
| value | The value to randomise |
| Returns | The randomised number in a negative integer |
TwoWayRand(10);
By: Allan
Checks to see whether an email is valid, by entering in a string that should be an email address to it
Parameters:({{{1}}})
| email[] | The email as a string |
| Returns | True if the email is valid, false if it isn't |
ValidEmail("user1@hotmail.com");
By: DracoBlue
Returns the playerid of the driver of the vehicle
Parameters:({{{1}}})
| vehicleid | The ID of the vehicle to get the driver from |
| Returns | The playerid if someone is driving the vehicle, -1 if no one is driving it |
VehicleDriverID(52);
By: DracoBlue
Returns the name of a player driving the vehicle (vehicleid)
Parameters:({{{1}}})
| vehicleid | The ID of the vehicle to get the driver from |
| Returns | The driver name of the vehicle |
VehicleDriverName(52);
By: Sacky
Provided that the conditions are met, this should generate solutions to quadratic equasions
Parameters:({{{1}}})
| Float:Xsq | The square root of x |
| Float:num | The number to use |
| Returns | The Quadratic Root of the number |
QuadraticRootCalc(52.2,16.2,78.9);
By: Allan
Makes the server wait a certain amount of time before processing the next request
Parameters:({{{1}}})
| time | The time in miliseconds for the server to wait |
Wait(1000);
Clears the players Chat Screen
Parameters:({{{1}}})
| playerid | The 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.
Checks whether a file exists
Parameters:({{{1}}})
| filename[] | The filename to check |
| Returns | False if it doesn't exist and true if it does |
dini_Exists("acertainfile.txt");
By: DracoBlue
Remove's a file
Parameters:({{{1}}})
| filename[] | The filename to remove |
| Returns | True if it removes it, False if it doesn't |
dini_Remove("acertainfile.txt");
By: DracoBlue
Create's a file
Parameters:({{{1}}})
| filename[] | The filename to create |
| Returns | True if it creates it, False if it doesn't |
dini_Create("acertainfile.txt");
By: DracoBlue
Puts a string in a file using another string to call as a reference
Parameters:({{{1}}})
| filename[] | The filename to open |
| key[] | The value to save in |
| value[] | The string to save |
| Returns | True if it exists, False if it doesn't |
dini_Set("acertainfile.txt","Servername","A SA:MP Server");
By: DracoBlue
Puts an integer in a file using another string to call as a reference
Parameters:({{{1}}})
| filename[] | The filename to open |
| key[] | The value to save in |
| Returns | True if it exists, False if it doesn't |
dini_Set("acertainfile.txt","Servermaxplayers",50);
By: DracoBlue
Puts a bool in a file using another string to call as a reference
Parameters:({{{1}}})
| filename[] | The filename to open |
| key[] | The value to save in |
| Returns | True if it exists, False if it doesn't |
dini_BoolSet("acertainfile.txt","Serveractive",true);
By: DracoBlue
Puts a Float in a file using another string to call as a reference
Parameters:({{{1}}})
| filename[] | The filename to open |
| key[] | The value to save in |
| Float:value | The Float to save |
| Returns | True if it exists, False if it doesn't |
dini_FloatSet("acertainfile.txt","Xpos",2345.67);
By: DracoBlue