Scripting Functions Old

From SA-MP

Jump to: navigation, search

Contents

SA-MP Functions (a_player.inc)

DisablePlayerCheckpoint

Disable any initialized checkpoints for a specific player, since you can only have one at any given time.


(playerid)
playeridThe player to disable the current checkpoint for.
DisablePlayerCheckpoint(playerid);


GetPlayerArmour

Get the current armour of the player. This can be perfectly used for cheat-detection for example.


(playerid,&Float:armour)
playeridThe player you want to know the armour of.
&Float:armourThe variable you want to save the player's armour in, passed by reference.
GetPlayerArmour(playerid, armour);


GetPlayerColor

This function returns the color the player is currently using.


(playerid)
playeridThe player you want to know the color of.
ReturnsThe player's color as an integer.
new playerColor = GetPlayerColor(playerid);


GetPlayerFacingAngle

Get the angle of the player's current view. This could be handy if you're creating a spectate system, for example.


(playerid,&Float:ang)
playeridThe player you want to know the angle of.
&Float:angThe variable to store the angle in, passed by reference.
GetPlayerFacingAngle(playerid, angle);


GetPlayerHealth

Get the current health of the player. This can be perfectly used for cheat-detection for example.


(playerid,&Float:health)
playeridThe player you want to know the health of.
&Float:healthThe variable you want to save the player's health in, passed by reference.
GetPlayerHealth(playerid, health);


GetPlayerIp

Get the IP of the player. Can be used for IP locked nicks or extended IP Bans


(playerid,name[],len)
playeridThe player you want to know the IP of.
name[]The variable you want to save the player's IP in.
lenThe lenght of the IP string.
GetPlayerIp(playerid,PlayerIP,sizeof PlayerIP);


GetPlayerMoney

Get the amount of money a player is currently possessing. This function can be used for cheat detection, to buy things, and so on.


(playerid)
playeridThe player to get the amount of money from.
ReturnsThe amount of money the player currently has.
new playerMoney = GetPlayerMoney(playerid);


GetPlayerName

Get the player's name, and save it into a multi-cell variable which you state in the second argument.


(playerid,const name[],len)
playeridThe player to get the name of.
const name[]The variable to store the name in, passed by reference.
lenNumber of cells the variable has been assigned.
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);


GetPlayerPos

Get the current position of a player, and save it in the variables stated in the three following arguments.


(playerid,&Float:x,&Float:y,&Float:z)
playeridThe player you want to know the position of.
&Float:xThe variable for the x-coordinate to save the position in, passed by reference.
&Float:yThe variable for the y-coordinate to save the position in, passed by reference.
&Float:zThe variable for the z-coordinate to save the position in, passed by reference.
GetPlayerPos(playerid, x, y, z);


GetPlayerScore

Get the score that the player currently has, which has been set by SetPlayerScore().


(playerid)
playeridThe player to get the score of.
ReturnsThe player's current score.
new playerScore = GetPlayerScore(playerid);


GetPlayerState

Get the current state of the user, to check if he/she is driver of a vehicle, on foot, or still spawning, and so on.


(playerid)
playeridThe player to get the state of.
ReturnsThe player's current state.
new playerState = GetPlayerState(playerid);


GetPlayerTeam

Get the ID of the team that the player is currently in, usable for team balancing for example.


(playerid)
playeridThe player you want to get the team of.
ReturnsThe player's current team.
new playerTeam = GetPlayerTeam(playerid);


GetPlayerVehicleID

Get the vehicle added ID the player is currently driving in. This does not return the vehicle model ID.


(playerid)
playeridThe player you want to get the vehicle off.
ReturnsThe vehicle ID the player currently is driving in.
new playerVehicle = GetPlayerVehicleID(playerid);


GivePlayerMoney

This function enables you to either give or take money from the user. Give the player a negative amount of money to decrease it.


(playerid,money)
playeridThe player you want to give money/take money from.
moneyThe amount of money you want to give/take.
GivePlayerMoney(playerid, 10000);


GivePlayerWeapon

Give the player a specific weapon, where you decide the weapon ID and the amount of ammo the player gets.


(playerid,weaponid,ammo)
playeridThe player to give a weapon to.
weaponidThe weapon ID to give.
ammoThe amount of ammo you want to give the player.
GivePlayerWeapon(playerid, 26, 250);


IsPlayerAdmin

Detect if a player is logged in with the in-game rcon functions.


(playerid)
playeridThe player ID you want to get the status of.
Returns1 if the player is an admin, 0 if he/she is not.
if(IsPlayerAdmin(playerid)){


IsPlayerConnected

This function can be used to check if the given player is connected with the server.


(playerid)
playeridThe ID of the player you want to check.
Returns1 if the player is connected, 0 if he/she is not.
if(IsPlayerConnected(playerid)){


IsPlayerInAnyVehicle

This function can be used to check if the given user is currently inside any vehicle.


(playerid)
playeridThe player you want to know the current status of.
Returns1 if the player is inside a vehicle, 0 if he/she is not.
if(IsPlayerInAnyVehicle(playerid)){


IsPlayerInCheckpoint

Check if the player is currently inside a checkpoint, this could be used for properties, teleport points or races for example.


(playerid)
playeridThe player you want to know the status of.
Returns1 if the player is inside a checkpoint, 0 if he/she is not.
if(IsPlayerInCheckpoint(playerid)){


IsPlayerInVehicle

Check if the player is inside a specific vehicle. Remember you have to use the vehicle added ID's here, not the vehicle model ID!


(playerid,vehicleid)
playeridThe player you want to look up.
vehicleidThe vehicle to check if the player is in it.
Returns1 if the player is inside the vehicle, 0 if he/she is not.
if(IsPlayerInVehicle(playerid, 32)){


PlayerPlaySound

This function plays a sound for the player. Sounds can be added for some very nice effects, there are just only a few sounds available, because you can't load any extra soundbanks.
Important note: The x/y/z-coordinates don't seem to have much influence on the sound.


(playerid,soundid,Float:x,Float:y,Float:z)
playeridThe player you want to hear the sound.
soundidThe Sound ID you want the player to hear.
Float:xThe x-coordinate to play the sound at.
Float:yThe y-coordinate to play the sound at.
Float:zThe z-coordinate to play the sound at.
PlayerPlaySound(playerid, 1025, 0.0, 0.0, 0.0);


PutPlayerInVehicle

You can use this function to place a player into a specific vehicle. You can pick both the vehicle ID as the seat ID, which gives you many options.


(playerid,vehicleid,seatid)
playeridThe player you want to move into a vehicle.
vehicleidThe vehicle you want to place the player in.
seatidThe seat you want to place the player in.
PutPlayerInVehicle(playerid, 0, 1);


RemovePlayerFromVehicle

This function removes a player from a vehicle. Remember that the OnPlayerExitVehicle callback won't be called!


(playerid)
playeridThe player ID to remove from it's vehicle.
RemovePlayerFromVehicle(playerid);


ResetPlayerMoney

Reset the money a player is currently carrying with him/her. This can be useful to create a SetPlayerMoney command.


(playerid)
playeridThe player to reset the money of.
ResetPlayerMoney(playerid);


ResetPlayerWeapons

Reset the weapons a player is currently wearing, useful if someone is teamkilling for example, to replace all his weapons with some flowers.


(playerid)
playeridThe player you want to reset the weapons of.
ResetPlayerWeapons(playerid);


SetCameraBehindPlayer

Restore the camera to a place behind the player, after using a function like SetPlayerCameraPos.
Important note: This function only works when a player is not spawned yet, for use in the OnPlayerSpawn for example.


(playerid)
playeridThe player you want to restore the camera for.
SetCameraBehindPlayer(playerid);


SetPlayerArmour

Set the armour for a given player, The armour parameter can be seen as a percentage, as 100 means the armour-bar is completely full.


(playerid,Float:Armour)
playeridThe player you want to get the team of.
Float:ArmourThe new armour you want to give a player as a float.
SetPlayerArmour(playerid,100.0);


SetPlayerCameraLookAt

Set the direction and place the player's camera will be looking at. You should use this in combination with SetPlayerCameraPos.
Important note: You will have to use SetCameraBehindPlayer function to restore the player's camera.


(playerid,Float:x,Float:y,Float:z)
playeridThe player you want to change the camera of.
Float:xThe x-coordinate for the camera to look at.
Float:yThe y-coordinate for the camera to look at.
Float:zThe z-coordinate for the camera to look at.
SetPlayerCameraLookAt(playerid, 324.34, 54.122. -173.35);


SetPlayerCameraPos

Set the new camera position for the player.
Important note: You will have to use SetCameraBehindPlayer function to restore the player's camera.


(playerid,Float:x,Float:y,Float:z)
playeridThe player you want the change the camera's position of.
Float:xThe new x-coordinate for the camera.
Float:yThe new y-coordinate for the camera.
Float:zThe new z-coordinate for the camera.
SetPlayerCameraPos(playerid, 652.23, 457.21, 10.84);


SetPlayerCheckpoint

Set the current active checkpoint for the player. You can only have one checkpoint at each time, you should use DisablePlayerCheckpoint to first destroy the old one.


(playerid,Float:x,Float:y,Float:z,Float:size)
playeridThe player ID to set the new checkpoint for.
Float:xThe x-coordinate for the new checkpoint.
Float:yThe y-coordinate for the new checkpoint.
Float:zThe z-coordinate for the new checkpoint.
Float:sizeThe checkpoint's size.
SetPlayerCheckpoint(playerid, 354.12, 932.12, 19.34, 2.0);


SetPlayerColor

This function allows you to change the color of a player currently in-game.


(playerid,color)
playeridThe player you want to change the color of.
colorThe new player's color, as an integer.
SetPlayerColor(playerid, 0xFFFF00AA);
SetPlayerColor(playerid, 4294901930);


SetPlayerFacingAngle

Set the currently facing angle for the player.


(playerid,Float:ang)
playeridThe player you want to change the facing angle of.
Float:angThe new player's facing angle.
SetPlayerFacingAngle(playerid, 90.0);


SetPlayerHealth

Change the player's current health. The health parameter can be seen as a percentage, as 100 means the health-bar is completely full.


(playerid,Float:health)
playeridThe player you want to change the health of.
Float:healthThe new health you want to give the player, as a float.
SetPlayerHealth(playerid, 95.0);


SetPlayerInterior

Change the player's current interior. A list of currently known interiors with their positions can be found on this page.


(playerid,interiorid)
playeridThe player you want to change the interior of.
interioridThe new interior ID (or Universe ID) for the player.
SetPlayerInterior(playerid, 0);


SetPlayerName

Change the player's nickname while he/she is in game


(playerid,const name[])
playeridThe playerID you want to change the nick of.
const name[]the new nickname for the player
SetPlayerName(playerid,"Victim");


SetPlayerPos

Change a player's position to another place on the map.


(playerid,Float:x,Float:y,Float:z)
playeridThe player you want to move.
Float:xThe new x-coordinate for the player's position.
Float:yThe new y-coordinate for the player's position.
Float:zThe new z-coordinate for the player's position.
SetPlayerPos(playerid, 34.236, 934.323, 12.345);


SetPlayerScore

Update the player's score to another value.


(playerid,score)
playeridThe player you want to change the score of.
scoreThe new player's score.
SetPlayerScore(playerid, 10000);


SetPlayerSkin

Change the player's skin. You should check in the General Reference on the forums if the skin can be used, since some skins are prone to crash. The following Skin ID's, and only the following skin ID's, crash the game for the user: 3, 4, 5, 6, 7, 8, 42, 65, 74, 86, 119, 149, 208, 265, 266, 267, 268, 269, 270, 271, 272, 273, 289.
Important note: This player can crash your game!


(playerid,skinid)
playeridThe player you want to change the skin of.
skinidThe new skinID for the player.
SetPlayerSkin(playerid, 121);


SetPlayerTeam

Important note: This Function can cause crashes and is not sync'd with other players. Do not use.
Use this function to change a player's team, useful for teambalacing for example.


(playerid,teamid)
playeridThe player you want to change the skin of.
teamidThe new team you want to place the player in.
SetPlayerTeam(playerid, TEAM_BALLAS);


SetPlayerVirtualWorld

Use this function to put a player in an alternate interior where they can not see anyone else who is not in that same virtual interior.


(playerid,virtual world ID)
playeridThe player you want to set in the virtual world.
virtual world IDThe name of the virtual world.
SetPlayerVirtualWorld(playerid,playerid+1);


SetPlayerWorldBounds

This function can be used to change the player's World Boundaries, the places he/she can go.


(playerid,Float:x_max,Float:x_min,Float:y_max,Float:y_min)
playeridThe player you want to set the boundaries of.
Float:x_maxThe max. x-coordinate where the player can go.
Float:x_minThe min. x-coordinate where the player can go.
Float:y_maxThe max. y-coordinate where the player can go.
Float:y_minThe min. z-coordinate where the player can go.
SetPlayerWorldBounds(playerid, 20.0, 0.0, 20.0, 0.0);


SetSpawnInfo

Change the spawn info for a specific player, instead of a whole class.


(playerid,team,skin,Float:x,Float:y,Float:z,Float:rotation,weapon1,weapon1_ammo,weapon2,weapon2_ammo,weapon3,weapon3_ammo)
playeridThe player you want to change the spawninfo of.
teamidThe ID of the team the player has to be put in.
modelidThe model ID for the player's skin.
Float:spawn_xThe x-coordinate for the player's spawn position.
Float:spawn_yThe y-coordinate for the player's spawn position.
Float:spawn_zThe z-coordinate for the player's spawn position.
Float:z_angleThe player's facing angle after spawning.
weapon1The weapon ID for the player's first weapon.
weapon1_ammoThe amount of ammo for the player's first weapon.
weapon2The weapon ID for the player's third weapon.
weapon2_ammoThe amount of ammo for the player's second weapon.
weapon3The weapon ID for the player's third weapon.
weapon3_ammoThe amount of ammo for the player's third weapon.
SetSpawnInfo(playerid, 1, 121, 2016.5950, 1545.0306, 10.8308, 90.5, 26, 250, 28, 250, 0, 0);


SpawnPlayer

This function can be used to respawn a player, good for use after setting a different camera position, for example.


(playerid)
playeridThe player you want to respawn.
SpawnPlayer(playerid);


TogglePlayerClock

Important note: This Function is not sync'd with other players. Do not use.
This function allows you to toggle the given players game clock on and off.


(playerid,show)
playeridThe player you want to toggle.
showtrue Shows the clock, false Hides the clock.
TogglePlayerClock(playerid, 1);


TogglePlayerControllable

This function allows you to toggle if the player can move or not. Useful for freezing players that you suspect for cheating for example.


(playerid,moveable)
playeridThe player you want to toggle.
moveabletrue says the player can move, false says he cannot.
TogglePlayerControllable(playerid, 0);


SA-MP Functions (a_vehicle.inc)

AddStaticVehicle

AddStaticVehicle places a vehicle into your gamemode. The function has to be called in the OnGameModeInit callback to work, until the new vehicle system from SA-MP 0.2 will be released.


(modelid,Float:spawn_x,Float:spawn_y,Float:spawn_z,Float:z_angle,color1,color2)
modelidThe vehicle model ID to be added.
Float:spawn_xThe x-coordinate for the added vehicle.
Float:spawn_yThe y-coordinate for the added vehicle.
Float:spawn_zThe z-coordinate for the added vehicle.
Float:z_angleThe facing-angle for the new vehicle.
color1The vehicle's primary color.
color2The vehicle's secondary color.


ReturnsThe added vehicles vehicleid.
AddStaticVehicle(520, 2503.34, 2345.34, -322.43, 311.43, 0, 0);


AddStaticVehicleEx

AddStaticVehicle places a vehicle into your gamemode. This function is exactly the same as AddStaticVehicle, except it takes a respawn_delay parameter.


(modelid,Float:spawn_x,Float:spawn_y,Float:spawn_z,Float:z_angle,color1,color2,respawn_delay)
modelidThe vehicle model ID to be added.
Float:spawn_xThe x-coordinate for the added vehicle.
Float:spawn_yThe y-coordinate for the added vehicle.
Float:spawn_zThe z-coordinate for the added vehicle.
Float:z_angleThe facing-angle for the new vehicle.
color1The vehicle's primary color.
color2The vehicle's secondary color.
respawn_delayThe delay used for the vehicle to respawn.
AddStaticVehicleEx(520, 2503.34, 2345.34, -322.43, 311.43, 0, 0, 600);


AddVehicleComponent

Add a new component to the vehicle, nitro for example.


(vehicleid,componentid)
vehicleidThe vehicle added ID.
componentidThe ID of the component that has to be added.
AddVehicleComponent(25, 1095);


ChangeVehicleColor

Change the vehicle's colors, which are set with the AddStaticVehicle(ex) function, or earlier with this function.


(vehicleid,color1,color2)
vehicleidThe vehicle's added ID.
color1The new primary color of the vehicle.
color2The new secondary color of the vehicle.
ChangeVehicleColor(100, 6, 6);


ChangeVehiclePaintjob

This function allows you to change the paintjob of a specific vehicle.


(vehicleid,paintjobid)
vehicleidThe vehicle's added ID.
paintjobidThe new paintjob ID to apply.
ChangeVehiclePaintjob(100, 12);


CreateVehicle

Dynamically spawn a vehicle in San Andreas Multiplayer, the same as AddStaticVehicle, but this one can be used at any time.


(vehicletype,Float:x,Float:y,Float:z,Float:rotation,color1,color2,respawn_delay)
vehicletypeThe model ID of the vehicle.
Float:xThe x-coordinate to spawn the vehicle.
Float:yThe y-coordinate to spawn the vehicle.
Float:zThe z-coordinate to spawn the vehicle.
Float:rotationThe rotation that must be applied to the vehicle.
color1The vehicle's primary color.
color2The vehicle's secondary color.
respawn_delayThe vehicle's respawn delay.
CreateVehicle(520, 34.23, -1230.23, 19.34, 273.234, 6, 4, 600);


GetVehiclePos

You can use this function to get the accurate position of the named vehicle. The position is saved by reference in three x/y/z variables.
Important note: This function DOES NOT WORK, it only returns the co-ordinates where the car spawned, or the co-ordinates set by SetVehiclePos. It does not return the current position of a car - It works as of 0.2 - Will Only retrieve coords of where the last player was in vehicle or Vehicles Spawn Position. Will not retrieve true coords if it has rolled down a hill for example


(vehicleid,&Float:x,&Float:y,&Float:z)
vehicleidThe added ID of the vehicle.
&Float:xThe variable to store the x-coordinate in, passed by reference.
&Float:yThe variable to store the y-coordinate in, passed by reference.
&Float:zThe variable to store the z-coordinate in, passed by reference.
GetVehiclePos(playerVehicle, x, y, z);


SetVehicleParamsForPlayer

Change specific parameters for a vehicle, per player. This allows you to place an arrow above the user, or lock the doors.


(vehicleid,playerid,objective,doorslocked)
vehicleidThe vehicle to change the parameters of.
playeridThe player where you want to change the parameters for.
objectiveDoes the vehicle have to be an objective?
doorslockedDo you want the vehicle's doors to be locked?
SetVehicleParamsForPlayer(vehicleid, playerid, 1, 1);


SetVehiclePos

Change the vehicle's position. The user is teleported with it if someone is in the vehicle.
Important note: This function ONLY works if someone has been in the vehicle since it spawn.
Important note: A vacated vehicle will not fall after being teleported into the air


(vehicleid,Float:x,Float:y,Float:z)
vehicleidThe vehicle you want to move.
Float:xThe new x-coordinate for the vehicle.
Float:yThe new y-coordinate for the vehicle.
Float:zThe new z-coordinate for the vehicle.
SetVehiclePos(vehicleid, 343.46, 459.34, 19.23);


SetVehicleToRespawn

SetVehicleToRespawn allows you to respawn a specific vehicle, even when a player is currently driving it.


(vehicleid)
vehicleidThe vehicle you want to respawn.
SetVehicleToRespawn(vehicleid);


SetVehicleZAngle

This function allows you to change the angle of a specific vehicle.


(vehicleid,Float:z_angle)
vehicleidThe vehicle you want to change the angle of.
Float:z_angleThe new angle for the vehicle.
SetVehicleZAngle(vehicleid, 270.0);


SA-MP Functions (a_object.inc)

CreateObject

Creates an Object on the Map. Use DestroyObject( ) to remove it.


(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ)
modelidThe Model ID you want to use.
Float:XThe X coordinate.
Float:YThe Y coordinate.
Float:ZThe Z coordinate.
Float:rXThe X rotation.
Float:rYThe Y rotation.
Float:rZthe Z rotation.


objectid = CreateObject( 2587, 2001.195679, 1547.113892, 14.283400, 0, 0, 96 );


SetObjectPos

Moves an Object to the specified position.


(objectid, Float:X, Float:Y, Float:Z)
objectidThis is the Object ID (Not the Model ID).
Float:XThe X coordinate.
Float:YThe Y coordinate.
Float:ZThe Z coordinate.


SetObjectPos( objectid, 2001.195679, 1547.113892, 14.283400 );


GetObjectPos

Returns the coordinates of the current position of the given object. The position is saved by reference in three x/y/z variables.


(objectid, &Float:X, &Float:Y, &Float:Z)
objectidThe object's id of which you want the current location.
Float:XThe variable to store the X coordinate, passed by reference.
Float:YThe variable to store the Y coordinate, passed by reference.
Float:ZThe variable to store the Z coordinate, passed by reference.


GetObjectPos( objectid, x, y, z );


SetObjectRot

Rotates an object in all directions.


(objectid, Float:RotX, Float:RotY, Float:RotZ)
objectidThe objectid of the object you want to rotate.
Float:RotXThe X rotation.
Float:RotYThe Y rotation.
Float:RotZThe Z rotation.


SetObjectRot( objectid, 2.25, 0, 0 );


GetObjectRot

Use this function to get the object' s current rotation. The rotation is saved by reference in three RotX/RotY/RotZ variables.


(objectid, &Float:RotX, &Float:RotY, &Float:RotZ)
objectidThe objectid of the object you want to get the rotation from.
Float:XThe variable to store the X rotation, passed by reference.
Float:YThe variable to store the Y rotation, passed by reference.
Float:ZThe variable to store the Z rotation, passed by reference.


GetObjectRot( objectid, RotX, RotY, RotZ );


IsValidObject

Checks if the given objectid is valid.
Returns1 if the object exists, 0 if not.


(objectid)
objectidThe objectid you want to validate.


if ( IsValidObject( objectid ) ) { DoSomething( ); }


DestroyObject

Destroys (removes) the given object.


(objectid)
objectidThe objectid from the object you want to delete.


DestroyObject( objectid );


MoveObject

This function can be used to move an existing object without destroying it first. If you let the object move slowly you can move the players on/under/in the object with it.


(objectid, Float:X, Float:Y, Float:Z, Float:Speed)
objectidThe objectid you want to move.
Float:XThe new X coordinate.
Float:YThe new Y coordinate.
Float:ZThe new Z coordinate.
Float:SpeedThe speed of which the object will be moved with.


MoveObject( objectid, 2001.195679, 1547.113892, 10 );


StopObject

Use this function to stop a moving object, for example after using MoveObject. To move a object in one time, use SetObjectPosition.


(objectid)
objectidThe objectid of the object you want to stop moving.


StopObject( objectid );


CreatePlayerObject

This function does the same as CreateObject but only for a specific player.


(playerid, modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ)
playeridThe id of the player you want to set the object for.
modelidThe Model ID you want to use.
Float:XThe X coordinate.
Float:YThe Y coordinate.
Float:ZThe Z coordinate.
Float:rXThe X rotation.
Float:rYThe Y rotation.


objectid = CreatePlayerObject( playerid, 2587, 2001.195679, 1547.113892, 14.283400, 0, 0, 96 );


SetPlayerObjectPos

Again, this function does the same as SetObjectPos but only for a specific player.


(playerid, objectid, Float:X, Float:Y, Float:Z)
playeridThe id of the player you move the object for.
objectidThe objectid you want to move.
Float:XThe new X coordinate.
Float:YThe new Y coordinate.
Float:ZThe new Z coordinate.


SetPlayerObjectPos( playerid, objectid, 2001.195679, 1547.113892, 14.283400 );


GetPlayerObjectPos

Returns the coordinates of the current position of the given object wich is set for the given player ID. The position is saved by reference in three x/y/z variables.


(playerid, objectid, &Float:X, &Float:Y, &Float:Z)
playeridThe playerid which is linked with the object.
objectidThe object's id of which you want the current location.
Float:XThe variable to store the X coordinate, passed by reference.
Float:YThe variable to store the Y coordinate, passed by reference.
Float:ZThe variable to store the Z coordinate, passed by reference.


GetPlayerObjectPos( playerid, objectid, x, y, z );


SetPlayerObjectRot

Rotates an object in all directions.


(playerid, objectid, Float:RotX, Float:RotY, Float:RotZ)
playeridThe playerid which is linked with the object.
objectidThe objectid of the object you want to rotate.
Float:RotXThe X rotation.
Float:RotYThe Y rotation.
Float:RotZThe Z rotation.


CreateObject( playerid, objectid, 0.12, 0 , 0 );


GetPlayerObjectRot

Use this function to get the object' s current rotation. The rotation is saved by reference in three RotX/RotY/RotZ variables.


(playerid, objectid, &Float:RotX, &Float:RotY, &Float:RotZ)
playeridThe playerid of which is linked with the object.
objectidThe objectid of the object you want to get the rotation from.
Float:XThe variable to store the X rotation, passed by reference.
Float:YThe variable to store the Y rotation, passed by reference.
Float:ZThe variable to store the Z rotation, passed by reference.


GetPlayerObjectRot( playerid, objectid, RotX, RotY, RotZ );


IsValidPlayerObject

Checks if the given objectid is valid object for the given playerid.
Returns1 if the object is valid for that player, 0 if not.


(playerid, objectid)
playeridThe playerid which you want to know if it has access to the object.
objectidThe objectid you want to validate.


if ( IsValidPlayerObject( playerid, objectid ) ) { DoSomething( ); }


DestroyPlayerObject

use this function to destroy a object linked to a player created with CreatePlayerObject.


(playerid, objectid)
playeridThe playerid which is linked with the object.
objectidThe objectid from the object you want to delete.


DestroyPlayerObject( playerid, objectid );


MovePlayerObject

This function can be used to move an existing object without destroying it first. If you let the object move slowly you can move the players on/under/in the object with it.


(playerid, objectid, Float:X, Float:Y, Float:Z, Float:Speed)
playeridThe playerid which is linked with the object.
objectidThe objectid you want to move.
Float:XThe new X coordinate.
Float:YThe new Y coordinate.
Float:ZThe new Z coordinate.
Float:SpeedThe speed of which the object will be moved with.


MovePlayerObject( playerid, objectid, 2001.195679, 1547.113892, 14.283400, 10 );


StopPlayerObject

Use this function to stop a moving object, for example after using MovePlayerObject. To move a object in one time, use SetPlayerObjectPosition.


(playerid, objectid)
playeridThe playerid which is linked with the object.
objectidThe objectid of the object you want to stop moving.


StopPlayerObject( playerid, objectid );


AttachObjectToPlayer

You can use this function to attach objects to players. The objects will folow the player.


(objectid, playerid, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:rX, Float:rY, Float:rZ)
objectidThe objectid you want to attach to the player.
playeridThe playerid which is linked with the object.
Float:OffsetXThe distance between the player and the object in the X direction.
Float:OffsetYThe distance between the player and the object in the Y direction.
Float:OffsetZThe distance between the player and the object in the Z direction.
Float:RotXThe X rotation between the object and the player.
Float:RotYThe Y rotation between the object and the player.
Float:RotZThe Z rotation between the object and the player.


AttachObjectToPlayer( objectid, playerid, 1.5, 0.5, 0, 0, 1.5, 2 );


AttachPlayerObjectToPlayer

The same as AttachObjectToPlayer but for objects which created for player.


(objectplayer, objectid, attachplayer, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:rX, Float:rY, Float:rZ)
objectplayerThe id of the player witch is linked with the object.
objectidThe objectid you want to attach to the player.
attachidThe id of the player you want to attach to the object.
Float:OffsetXThe distance between the player and the object in the X direction.
Float:OffsetYThe distance between the player and the object in the X direction.
Float:OffsetZThe distance between the player and the object in the X direction.
Float:RotXThe X rotation.
Float:RotYThe Y rotation.
Float:RotZThe Z rotation.


AttachPlayerObjectToPlayer(bjectplayer, objectid, attachplayer, 1.5, 0.5, 0, 0, 1.5, 2 );


Serverwindow functions

clreol

This function clears the current output line till the end of it, could be useful in the Windows Server.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(No Parameters)
ReturnsThis function always returns 0.
clreol();


clrscr

This function clears all the output that has already been printed on the screen.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(No Parameters)
ReturnsThis function always returns 0.
clrscr();


getarg

Important note: Works NOT with arrays as paramter!
Get a specific argument from a function, very good for use with functions that have a dynamic argument count.


(arg,index=0)
argThe ID of the argument you want to know.
index=0Cell to read when the argument is a string.
ReturnsThis function returns one cell.
getarg(0);


getchar

This function allows you to read one char that has been inputted in the console window.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(echo=0)
echo=0Do you want to echo the inputted character in the console window?
ReturnsOne cell with the inputted character.
new char[1] = getchar(1);


getstring

This function reads a string from the keyboard. You can define the number of cells to read (not characters!) with the second parameter.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(string[],size=sizeof(string),pack=false)
string[]The string you want to save the input in.
size=sizeof(string)The number of cells you want to read from the keyboard.
pack=falseDo you want the string to be packed?
getstring(string, 256, false);


getvalue

This function allows you to read a signed value from the keyboard. The function allows you to read in a numeric radix from 2 to 36.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(base=10,end='\r')
base=10The default radix to use.
end='\r'The parameter to stop reading the value.
ReturnsThe requested value.
new value = getvalue(10, '\r');


gotoxy

You can use gotoxy() to set the current position for the cursor in the console window. The upper left corner is 1,1.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(x=1,y=1)
x=1The x-position in the console to move the cursor to.
y=1The y-position in the console to move the cursor to.
gotoxy(20,43);


heapspace

Heapspace allows you to free the space on the heap, the shared memory area.


(No Parameters)
ReturnsThe number of bytes the function saved.
new sparedBytes = heapspace();


numargs

This function returns the number of arguments given to a function with a dynamic number of arguments.


(No Parameters)
ReturnsThe number of arguments given.
new argumentCount = numargs();


print

Print a non-formatted line to the console.


(const string[])
const string[]The string you want to display on the console.
print("This is an example output.");


printf

Printf prints a formatted string to the console, with specific formatting options.


(const format[],...)
const format[]The format you want to print the sentence in.
%b represents a number in binary radix.
%c represents a character.
%d represents a double (or normal integer).
%f represents a float to the console.
%i represents a string to the console.
%s represents a string to the console.
%x represents a number in hexadecimal format.
printf("This %s has %d words.", "string", 4);


setarg

Change the value of a given argument.


(arg,index=0,value)
argThe argument ID you want to change.
index=0The argument's cell.
valueThe new value
setarg(0, 3, "e");


wherexy

WhereXY allows you to get the current cursor position from the console window.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(&x,&y)
&xThe variable to store the x-position in, passed by reference.
&yThe variable to store the y-position in, passed by reference.
ReturnsThis function always returns 0.
wherexy(x,y);


Properties

deleteproperty

This function allows you to delete an earlier set property.


(id=0,const name[]="",value=cellmin)
id=0Defines which virtual machine to use.
const name[]=""Defines if to use with call by name, you should keep this "".
value=cellminThis identifys the variable. Use the hash-function to calculate it from a string.
deleteproperty(0, "", 123984334);


existproperty

You can use this function to check if a specific property exists. You can use the Adler 32 function to generate the hash.


(id=0,const name[]="",value=cellmin)
id=0The virtual machine to use, you should keep this zero.
const name[]=""Use the property by its name, you should keep this "".
value=cellminThe property's hash, probably generated by Adler 32.
if(existproperty(0, "", 9384932)){


getproperty

Get a specific property from the memory, the string is returned as a packed string!


(id=0,const name[]="",value=cellmin,&string[]="")
id=0The virtual machine to use, you should keep this zero.
const name[]=""The property's name, you should keep this "".
value=cellminThe property's hash, can be generated via Adler 32.
&string[]=""The variable to store the result in, passed by reference.
getproperty(0, "", 93473413, value);


setproperty

Use this function to save a value into a property.


(id=0,const name[]="",value=cellmin,const string[]="")
id=0The virtual machine to use, should be kept zero.
const name[]=""The name of the property, should be kept empty.
value=cellminThe hash of the property, can be generated via Adler 32.
const string[]=""The actual value of the property, will be packed when used.
setproperty(0, "", 9723423, value);


UDP Broadcasting functions

listenport

This function allows you to choose which port your pawn script should listen to.
Broken function in the current San Andreas - Multiplayer version. It cannot be used!


(port)
portThe portnumber used for listening.
listenport(7778);


sendpacket

This function allows you to send a packet over the internet, or on your local machine.


(const packet[],size,const destination[]="")
const packet[]The packet to send, as a string.
sizeThe size of the packed, sizeof(packet) for example.
const destination[]=""The destination, in a 0.0.0.0:0000 format. It's broadcasted if left empty,
sendpacket("Hello world!", 12);


sendstring

Send a string to a specific location, or broadcast it.


(const message[],const destination[]="")
const message[]The string you want to send.
const destination[]=""The destination of the string, in a 0.0.0.0:0000 format, or it's broadcasted when left empty.
sendstring("Hello world!", "127.0.0.1:7779");


File functions (file.inc)

You may refer also on File tutorial for a tutorial on this.

fblockread

This function allows you to read data from a file, without encoding and line terminators (binary format)


(handle,buffer[],size=sizeof buffer)
handleFile handle to use, opened by fopen()
buffer[]The buffer to save the read data in.
size=sizeof bufferThe number of cells to read.
fblockread(gFile, string, 256);


fblockwrite

Write data to a file in binary format, while ignoring line brakes and encoding.


(handle,const buffer[],size=sizeof buffer)
handleThe File handle to use, opened by fopen().
const buffer[]The data to write to the file.
size=sizeof bufferThe number of cells to write.
fblockwrite(gFile, "Save this data!", 15);


fclose

Close a file handle, earlier opened by fopen. It's very important to use this function after you're done with reading/writing!


(handle)
handleThe File handle to close, opened by fopen().
fclose(gFile);


fexist

Check if a specific file exists in your scriptfiles directory.


(const pattern[])
const pattern[]The filename to check if it exists.
Returns1 is the file exist, 0 if it doesn't.
if(fexist("datafile.txt")){


fgetchar

This function reads one character from the file, and saves it in the value variable, passed by reference.


(handle,&value,utf8=true)
handleThe File handle to use, opened by fopen().
&valueThe variable to save the character in.
utf8=trueRead the character as UTF8.
fgetchar(gFile, handle, false);


flength

Check the length of a file which is already opened.


(handle)
handleThe File handle to use, opened by fopen().
ReturnsThe length of the file, in bytes.
new fileLength = flength(gFile);


fmatch

This function checks whether a part of the given file matched the string specified.


(name[],const pattern[],index=0,size=sizeof name)
name[]The filename to check.
const pattern[]The pattern that should be matched.
index=0The offset to start searching.
size=sizeof nameThe amount of characters to search in.
fmatch("searchFile.txt", "Peter", 0);


fopen

Open a specific file for reading, writing or both. This function is needed for most of the other file-based functions.
Important note: This function can crash your game when either the scriptfiles directory doesn't exist, or the file itself doesn't.


(const name[],mode=io_readwrite)
const name[]The filename of the file you want to open.
mode=io_readwriteThe mode which you like to use for opening the file.
ReturnsThe File handle
new File:gFile = fopen("exampleFile.txt", io_readwrite);


fputchar

This function writes one character to the file.


(handle,value,utf8=true)
handleThe File handle to use, earlier opened by fopen().
valueThe character you want to write.
utf8=trueShould the character be written as UTF8?
fputchar(gFile, 'e', false);


fread

Use this function if you want to read a line of the file. You'll need a for/while loop to read multiple lines.


(handle,&string[],size=sizeof string,pack=false)
handleThe File handle to use, earlier opened by fopen().
&string[]The string you want to save the data in, passed by reference.
size=sizeof stringThe number of bytes to read.
pack=falseShould the string reference be packed?
fread(gFile, string, sizeof(string));


fremove

Remove an existing file from your scriptfiles folder.
Important note: This function can crash your game if the requested file does not exist.


(const name[])
const name[]The filename you want to delete.
fremove("exampleFile.txt");


fseek

Change the current position in the file. You can either seek forward or backward through the file.


(handle,position=0,whence=seek_start)
handleThe File handle to use, earlier opened by fopen().
position=0The position to place the file-cursor.
whence=seek_startThe way to seek within the file.
fseek(gFile, 25);


ftemp

This function opens a file in the "tmp" or "temp" directory for reading and writing. The file is deleted after you close it with fclose().
Important note: This function can crash your game when the right directory isn't created.


(No Parameters)
ReturnsThe File handle
new File:gFile = ftemp();


fwrite

Write a specific string or line to the file. Remember that the file has to be opened for writing.


(handle,const string[])
handleThe File handle you opened earlier with fopen().
const string[]The string you want to write to the file.
fwrite(gFile, "This will be put in the file!");


Float functions (float.inc)

float

This function converts an integer value to a float.


(value)
valueThe integer you want to convert to a float.
new Float:fVar = float(122);


floatabs

Returns the absolute value of a float.


(value)
valueThe float you want to check
ReturnsThe absolute value of the float.
new Float:fAbs = floatabs(-123.54);


floatadd

Calculate the sum of two floats, it's the same as Float1 + Float2.


(oper1,oper2)
oper1The first float value.
oper2The value you want to add with the first argument.
ReturnsThe sum of the two floats.
new Float:fSum = floatadd(123.45, 678.90);


floatcmp

Compare two floats to each other.


(oper1,oper2)
oper1The first float you want to compare.
oper2The second float you want to compare.
Returns1 if the first argument is larger, -1 is the second one is larger.
new compare = floatcmp(127.45, 127.450);


floatcos

Calculate the right cosine of a float, with a specific anglemode.


(value,anglemode=radian)
valueThe float you want to know the cosine of.
anglemode=radianThe Anglemode.
ReturnsThe cosine of the given float.
new Float:fCos = floatcos(87.343, radian);


floatdiv

Divide a float with a value specified by the divisor float.


(dividend,divisor)
dividendThe float value you want to divide.
divisorThe (float) value you want to divide it with.
ReturnsThis function returns the divided value as a float.
new Float:fDivide = floatdiv(128.00, 32.00);


floatfract

Calculate and return the fractional part of a float.


(value)
valueThe float you want to know that fractional path of.
ReturnsThe fractional part of the float.
new Float:fFract = floatfract(3249.34);


floatlog

Use this function if you want to know the logarithm of a float.


(value,base=10.0)
valueThe float you want to know the log. of.
base=10.0The base value to use.
ReturnsThe logarithm value of the float.
new Float:fLog = floatlog(128.0);


floatmul

Multiply the two floats with eachother, and returns the product.


(oper1,oper2)
oper1The first float you want to multiply.
oper2And the second one.
ReturnsThe product of the two floats.
new Float:fMul = floatmul(128.1,7.9);


floatpower

Raises the float to the power of the exponent float.


(value,exponent)
valueThe float you want to raise.
exponentThe exponent you want, as a float.
ReturnsThe float raised by the power of the exponent.
new Float:fPower = floatpower(128.0, 8.0); // 1024


floatround

Round the float values with the given method.


(value,:method=floatround_round)
valueThe float value you want to round.
:method=floatround_roundThe float-round method you wish to use.
ReturnsThe rounded value as a integer.
new round = floatround(128.9, floatround_floor);


floatsin

Calculate the sinus of the given float, with the anglemode in radian, degrees or grads


(value,anglemode:mode=radian)
valueThe float you want to know the sinus of.
mode=radianThe Anglemode.
ReturnsThe sinus of the given float.
new Float:fSin = floatsin(82.4);


floatsqroot

Calculate the square root of the given float.


(value)
valueThe float you want to know the square root of.
ReturnsThe square root of the float.
new Float:fSqroot = floatsqroot(743.34);


floatsub

Decrease the first oper1 value with the float given in oper2.


(oper1,oper2)
oper1The float you want to decrease with the second value.
oper2The value to decrease the first value with.
ReturnsThe leftover value of the first argument.
new Float:fSub = floatsub(233.54, 23.34);


floattan

Calculate the tangent of the given float in the first argument, using it on a radian, grads or degree basis.


(value,mode=radian)
valueThe float you want to know the tangent of.
mode=radianThe you Anglemode wish to use.
ReturnsThe tangent value of the float.
new Float:fTan = floattan(87.4);


floatstr

Convert a string to it's rightful float value.


(const string[])
const string[]The string you want to convert to a float.
ReturnsThe requested float.
new Float:fFloat = floatstr("124.34");


String functions (string.inc)

format

Format enables you to use variables in a string; the same as printf(), but this returns the actual string.


(const format[],...)
const format[]The format you want to print the sentence in.
%b represents a number in binary radix.
%c represents a character.
%d represents a double (or normal integer).
%f represents a float to the console.
%i represents a string to the console.
%s represents a string to the console.
%x represents a number in hexadecimal format.
format(string, sizeof(string), "This %s has %d words.", "string", 4);


ispacked

Check if the given string is packed, and return the result.


(const string[])
const string[]The string you want to check.
Returns1 if the string is packed, 0 if it's unpacked.
if(ispacked(string)){


memcpy

memcpy can be used to copy bytes from one location to another.


(dest[],const source[],index=0,numbytes,maxlength=sizeof dest)
dest[]The destination for the copy.
const source[]The source for the copy, the original string.
index=0The offset within the source to copy.
numbytesThe number of bytes to copy.
maxlength=sizeof destThe size of the destination argument.
memcpy(playerNames[playerid], playerName, 0, MAX_PLAYER_NAME);


strcat

This function concats two strings into the destination reference.


(dest[],const source[],maxlength=sizeof dest)
dest[]The destination to copy the two concatted string in.
const source[]The source string.
maxlength=sizeof destThe maximum length of the destination.
ReturnsThe length of the new destination string.
strcat(destination, "Hi, how are you?", sizeof(destination));


strcmp

Compare two strings with each other, with options like ignoring capitals and the maximum length. Used a lot in OnPlayerCommandText.


(const string1[],const string2[],ignorecase=false,length=cellmax)
const string1[]The first string to compare.
const string2[]The string you want to compare with string1.
ignorecase=falseIgnore capitals if true.
length=cellmaxThe maximum number of cells to check.
Returns0 if the string are equal to each other.
if(strcmp(cmdtext, "/me", true) == 0){


strdel

This function deletes a part from a string.


(string[],start,end)
string[]The string you want to delete a part of.
startThe offset to start deleting.
endThe end, where to stop deleting (start + number of chars)
strdel("Peter is cool", 8, 10);


strfind

Use this function to search for a substring in a string.


(const string[],const sub[],ignorecase=false,pos=0)
const string[]The string you want to search in (haystack).
const sub[]The string you want to search for (needle).
ignorecase=falseIgnore capitals if true.
pos=0The offset to start searching.
ReturnsThe occurance of the substr, returns -1 if it's not found.
new instring = strfind("Are you in here?", "you", true);


strins

This function inserts a string into another string, defined by substr and string.


(string[],const substr[],pos,maxlength=sizeof string)
string[]The string you want to insert substr in.
const substr[]The string you want to insert into string.
posThe position to start inserting.
maxlength=sizeof stringThe maximum size to insert.
strins("f3llah1n is a ", "silly boy", 15);


strlen

This function can be used to check the length of a specific string.


(const string[])
const string[]The string you want to know the length of.
ReturnsThe length as an integer value.
new stringLength = strlen("This is an example string.");


strmid

Extract a range of characters from a string.


(dest[],const source[],start,end,maxlength=sizeof dest)
dest[]The string to store the extracted characters in.
const source[]The string from which to extract characters.
startThe position of the first character.
endThe position of the last character.
maxlength=sizeof destThe maximum length of dest.
strmid(string, "Grab the this word without !: HELLO!!!!", 30, 35); //string contains "HELLO"


strpack

This function can be used to pack a string.


(dest[],const source[],maxlength=sizeof dest)
dest[]The destination string to save the packed string in, passed by reference.
const source[]The source, original string.
maxlength=sizeof destThe maximum size of dest to use.
strpack(string, "Hi, how are you?");



strunpack

This function unpacks a packed string, into the destination.


(dest[],const source[],maxlength=sizeof dest)
dest[]The destination for the unpacked string.
const source[]The current packed string to unpack.
maxlength=sizeof destThe length of the destination string.
strunpack(string, packedString);


strval

strval can be used to convert a string to an integer.


(const string[])
const string[]The string you want to convert to an integer.
ReturnsThe integer value of the string.
new iValue = strval("250");


uudecode

This function enables you to decode an UU-encoded stream.


(dest[],const source[],maxlength=sizeof dest)
dest[]The destination for the decoded string array.
const source[]The UU-encoded source string.
maxlength=sizeof destThe maximum length of dest that can be used.
uudecode(decodedString, encodedString);


uuencode

The string you can decode with uudecode, must be encoded with this function.


(dest[],const source[],numbytes,maxlength=sizeof dest)
dest[]The destination string for the encoded stream.
const source[]The source, non-encoded string.
numbytesThe number of bytes to encode, this should not exceed 45.
maxlength=sizeof destThe maximum length of the dest[] array.
uudecode(encodedString, normalString, 45);


valstr

Converts an integer value to a string.


(dest[],value,pack=false)
dest[]The string to store the value in.
valueThe integer value to convert to a string.
pack=falsePack the string if true.
valstr(string, 454);


Misc functions

getdate

Get the current server date, which will be stored in the variables &year, &month and &day.


(&year=0,&month=0,&day=0)
&year=0The variable to store the year in, passed by reference.
&month=0The variable to store the month in, passed by reference.
&day=0The variable to store the day in, passed by reference.
ReturnsThe number of days since the start of the year.
new Year, Month, Day;

getdate(Year, Month, Day);

printf("%02d/%02d/%d", Day, Month, Year);


GetTickCount

Get the number of ticks, since the server's last restart. This function only works on Windows!


(No Parameters)
ReturnsThe number of ticks since the servers last restart.
new Ticks = GetTickCount();


gettime

Get the current server time, which will be stored in the variables &hour, &minute and &second.


(&hour=0,&minute=0,&second=0)
&hour=0The variable to store the hour in, passed by reference.
&minute=0The variable to store the minute in, passed by reference.
&second=0The variable to store the seconds in, passed by reference.
ReturnsThe number of seconds since midnight, 1 January 1970.
new Hour, Minute, Second;

gettime(Hour, Minute, Second);

printf("%02d:%02d:%02d, Hour, Minute, Second);


KillTimer

Kill a specific timer, this is only necessary for timers that stay running.


(timerid)
timeridThe ID of the timer you want to kill.
KillTimer(gameTimerID);


random

Get a pseudo-random number, which will be number different possibilities starting with 0, ending with the number one smaller then number.


(max)
maxThe maximum number for the random sequence.
ReturnsA random number between 0 and max.
new iRandomNumber = random(25); // random number between 0 and 24


SetTimer

Set a timer on the server, which can run one or more times. You cannot pass any parameters to the function called by the timer.


(funcname[],interval,repeating)
funcname[]The function to call, as a string.
intervalThe interval to call the timer, in milliseconds. An interval of 1000 means every second.
repeatingfalse to run once, true to keep running.
ReturnsThe ID of the timer.
new gameTimerID = SetTimer("ExitGameFunc", 600000, 0);


sizeof

Returns the defined length of a variable.


(variable[])
variable[]The variable you want to know the length of..
ReturnsThe length as number of cells.
new string[256]; new length = sizeof(string); // length = 256


tickcount

This function can be used as a replacement for GetTickCount, as it returns the number of milliseconds since the start-up.


(&granularity=0)
&granularity=0This is an indication of the accuracy of the function, passed by reference.
ReturnsThe number of ticks since the server's start-up.
new iTickCount = tickcount();
Personal tools
In other languages