Scripting Functions Old
From SA-MP
[edit]
SA-MP Functions (a_player.inc)
[edit]
DisablePlayerCheckpoint
Disable any initialized checkpoints for a specific player, since you can only have one at any given time.
(playerid)
| playerid | The player to disable the current checkpoint for. |
DisablePlayerCheckpoint(playerid);
[edit]
GetPlayerArmour
Get the current armour of the player. This can be perfectly used for cheat-detection for example.
(playerid,&Float:armour)
| playerid | The player you want to know the armour of. |
| &Float:armour | The variable you want to save the player's armour in, passed by reference. |
GetPlayerArmour(playerid, armour);
[edit]
GetPlayerColor
This function returns the color the player is currently using.
(playerid)
| playerid | The player you want to know the color of. |
| Returns | The player's color as an integer. |
new playerColor = GetPlayerColor(playerid);
[edit]
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)
| playerid | The player you want to know the angle of. |
| &Float:ang | The variable to store the angle in, passed by reference. |
GetPlayerFacingAngle(playerid, angle);
[edit]
GetPlayerHealth
Get the current health of the player. This can be perfectly used for cheat-detection for example.
(playerid,&Float:health)
| playerid | The player you want to know the health of. |
| &Float:health | The variable you want to save the player's health in, passed by reference. |
GetPlayerHealth(playerid, health);
[edit]
GetPlayerIp
Get the IP of the player. Can be used for IP locked nicks or extended IP Bans
(playerid,name[],len)
| playerid | The player you want to know the IP of. |
| name[] | The variable you want to save the player's IP in. |
| len | The lenght of the IP string. |
GetPlayerIp(playerid,PlayerIP,sizeof PlayerIP);
[edit]
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)
| playerid | The player to get the amount of money from. |
| Returns | The amount of money the player currently has. |
new playerMoney = GetPlayerMoney(playerid);
[edit]
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)
| playerid | The player to get the name of. |
| const name[] | The variable to store the name in, passed by reference. |
| len | Number of cells the variable has been assigned. |
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
[edit]
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)
| playerid | The player you want to know the position of. |
| &Float:x | The variable for the x-coordinate to save the position in, passed by reference. |
| &Float:y | The variable for the y-coordinate to save the position in, passed by reference. |
| &Float:z | The variable for the z-coordinate to save the position in, passed by reference. |
GetPlayerPos(playerid, x, y, z);
[edit]
GetPlayerScore
Get the score that the player currently has, which has been set by SetPlayerScore().
(playerid)
| playerid | The player to get the score of. |
| Returns | The player's current score. |
new playerScore = GetPlayerScore(playerid);
[edit]
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)
| playerid | The player to get the state of. |
| Returns | The player's current state. |
new playerState = GetPlayerState(playerid);
[edit]
GetPlayerTeam
Get the ID of the team that the player is currently in, usable for team balancing for example.
(playerid)
| playerid | The player you want to get the team of. |
| Returns | The player's current team. |
new playerTeam = GetPlayerTeam(playerid);
[edit]
GetPlayerVehicleID
Get the vehicle added ID the player is currently driving in. This does not return the vehicle model ID.
(playerid)
| playerid | The player you want to get the vehicle off. |
| Returns | The vehicle ID the player currently is driving in. |
new playerVehicle = GetPlayerVehicleID(playerid);
[edit]
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)
| playerid | The player you want to give money/take money from. |
| money | The amount of money you want to give/take. |
GivePlayerMoney(playerid, 10000);
[edit]
GivePlayerWeapon
Give the player a specific weapon, where you decide the weapon ID and the amount of ammo the player gets.
(playerid,weaponid,ammo)
| playerid | The player to give a weapon to. |
| weaponid | The weapon ID to give. |
| ammo | The amount of ammo you want to give the player. |
GivePlayerWeapon(playerid, 26, 250);
[edit]
IsPlayerAdmin
Detect if a player is logged in with the in-game rcon functions.
(playerid)
| playerid | The player ID you want to get the status of. |
| Returns | 1 if the player is an admin, 0 if he/she is not. |
if(IsPlayerAdmin(playerid)){
[edit]
IsPlayerConnected
This function can be used to check if the given player is connected with the server.
(playerid)
| playerid | The ID of the player you want to check. |
| Returns | 1 if the player is connected, 0 if he/she is not. |
if(IsPlayerConnected(playerid)){
[edit]
IsPlayerInAnyVehicle
This function can be used to check if the given user is currently inside any vehicle.
(playerid)
| playerid | The player you want to know the current status of. |
| Returns | 1 if the player is inside a vehicle, 0 if he/she is not. |
if(IsPlayerInAnyVehicle(playerid)){
[edit]
IsPlayerInCheckpoint
Check if the player is currently inside a checkpoint, this could be used for properties, teleport points or races for example.
(playerid)
| playerid | The player you want to know the status of. |
| Returns | 1 if the player is inside a checkpoint, 0 if he/she is not. |
if(IsPlayerInCheckpoint(playerid)){
[edit]
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)
| playerid | The player you want to look up. |
| vehicleid | The vehicle to check if the player is in it. |
| Returns | 1 if the player is inside the vehicle, 0 if he/she is not. |
if(IsPlayerInVehicle(playerid, 32)){
[edit]
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)
| playerid | The player you want to hear the sound. |
| soundid | The Sound ID you want the player to hear. |
| Float:x | The x-coordinate to play the sound at. |
| Float:y | The y-coordinate to play the sound at. |
| Float:z | The z-coordinate to play the sound at. |
PlayerPlaySound(playerid, 1025, 0.0, 0.0, 0.0);
[edit]
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)
| playerid | The player you want to move into a vehicle. |
| vehicleid | The vehicle you want to place the player in. |
| seatid | The seat you want to place the player in. |
PutPlayerInVehicle(playerid, 0, 1);
[edit]
RemovePlayerFromVehicle
This function removes a player from a vehicle. Remember that the OnPlayerExitVehicle callback won't be called!
(playerid)
| playerid | The player ID to remove from it's vehicle. |
RemovePlayerFromVehicle(playerid);
[edit]
ResetPlayerMoney
Reset the money a player is currently carrying with him/her. This can be useful to create a SetPlayerMoney command.
(playerid)
| playerid | The player to reset the money of. |
ResetPlayerMoney(playerid);
[edit]
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)
| playerid | The player you want to reset the weapons of. |
ResetPlayerWeapons(playerid);
[edit]
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)
| playerid | The player you want to restore the camera for. |
SetCameraBehindPlayer(playerid);
[edit]
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)
| playerid | The player you want to get the team of. |
| Float:Armour | The new armour you want to give a player as a float. |
SetPlayerArmour(playerid,100.0);
[edit]
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)
| playerid | The player you want to change the camera of. |
| Float:x | The x-coordinate for the camera to look at. |
| Float:y | The y-coordinate for the camera to look at. |
| Float:z | The z-coordinate for the camera to look at. |
SetPlayerCameraLookAt(playerid, 324.34, 54.122. -173.35);
[edit]
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)
| playerid | The player you want the change the camera's position of. |
| Float:x | The new x-coordinate for the camera. |
| Float:y | The new y-coordinate for the camera. |
| Float:z | The new z-coordinate for the camera. |
SetPlayerCameraPos(playerid, 652.23, 457.21, 10.84);
[edit]
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)
| playerid | The player ID to set the new checkpoint for. |
| Float:x | The x-coordinate for the new checkpoint. |
| Float:y | The y-coordinate for the new checkpoint. |
| Float:z | The z-coordinate for the new checkpoint. |
| Float:size | The checkpoint's size. |
SetPlayerCheckpoint(playerid, 354.12, 932.12, 19.34, 2.0);
[edit]
SetPlayerColor
This function allows you to change the color of a player currently in-game.
(playerid,color)
| playerid | The player you want to change the color of. |
| color | The new player's color, as an integer. |
SetPlayerColor(playerid, 0xFFFF00AA);
SetPlayerColor(playerid, 4294901930);
[edit]
SetPlayerFacingAngle
Set the currently facing angle for the player.
(playerid,Float:ang)
| playerid | The player you want to change the facing angle of. |
| Float:ang | The new player's facing angle. |
SetPlayerFacingAngle(playerid, 90.0);
[edit]
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)
| playerid | The player you want to change the health of. |
| Float:health | The new health you want to give the player, as a float. |
SetPlayerHealth(playerid, 95.0);
[edit]
SetPlayerInterior
Change the player's current interior. A list of currently known interiors with their positions can be found on this page.
(playerid,interiorid)
| playerid | The player you want to change the interior of. |
| interiorid | The new interior ID (or Universe ID) for the player. |
SetPlayerInterior(playerid, 0);
[edit]
SetPlayerName
Change the player's nickname while he/she is in game
(playerid,const name[])
| playerid | The playerID you want to change the nick of. |
| const name[] | the new nickname for the player |
SetPlayerName(playerid,"Victim");
[edit]
SetPlayerPos
Change a player's position to another place on the map.
(playerid,Float:x,Float:y,Float:z)
| playerid | The player you want to move. |
| Float:x | The new x-coordinate for the player's position. |
| Float:y | The new y-coordinate for the player's position. |
| Float:z | The new z-coordinate for the player's position. |
SetPlayerPos(playerid, 34.236, 934.323, 12.345);
[edit]
SetPlayerScore
Update the player's score to another value.
(playerid,score)
| playerid | The player you want to change the score of. |
| score | The new player's score. |
SetPlayerScore(playerid, 10000);
[edit]
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)
| playerid | The player you want to change the skin of. |
| skinid | The new skinID for the player. |
SetPlayerSkin(playerid, 121);
[edit]
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)
| playerid | The player you want to change the skin of. |
| teamid | The new team you want to place the player in. |
SetPlayerTeam(playerid, TEAM_BALLAS);
[edit]
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)
| playerid | The player you want to set in the virtual world. |
| virtual world ID | The name of the virtual world. |
SetPlayerVirtualWorld(playerid,playerid+1);
[edit]
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)
| playerid | The player you want to set the boundaries of. |
| Float:x_max | The max. x-coordinate where the player can go. |
| Float:x_min | The min. x-coordinate where the player can go. |
| Float:y_max | The max. y-coordinate where the player can go. |
| Float:y_min | The min. z-coordinate where the player can go. |
SetPlayerWorldBounds(playerid, 20.0, 0.0, 20.0, 0.0);
[edit]
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)
| playerid | The player you want to change the spawninfo of. |
| teamid | The ID of the team the player has to be put in. |
| modelid | The model ID for the player's skin. |
| Float:spawn_x | The x-coordinate for the player's spawn position. |
| Float:spawn_y | The y-coordinate for the player's spawn position. |
| Float:spawn_z | The z-coordinate for the player's spawn position. |
| Float:z_angle | The player's facing angle after spawning. |
| weapon1 | The weapon ID for the player's first weapon. |
| weapon1_ammo | The amount of ammo for the player's first weapon. |
| weapon2 | The weapon ID for the player's third weapon. |
| weapon2_ammo | The amount of ammo for the player's second weapon. |
| weapon3 | The weapon ID for the player's third weapon. |
| weapon3_ammo | The 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);
[edit]
SpawnPlayer
This function can be used to respawn a player, good for use after setting a different camera position, for example.
(playerid)
| playerid | The player you want to respawn. |
SpawnPlayer(playerid);
[edit]
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)
| playerid | The player you want to toggle. |
| show | true Shows the clock, false Hides the clock. |
TogglePlayerClock(playerid, 1);
[edit]
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)
| playerid | The player you want to toggle. |
| moveable | true says the player can move, false says he cannot. |
TogglePlayerControllable(playerid, 0);
[edit]
SA-MP Functions (a_vehicle.inc)
[edit]
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)
| modelid | The vehicle model ID to be added. |
| Float:spawn_x | The x-coordinate for the added vehicle. |
| Float:spawn_y | The y-coordinate for the added vehicle. |
| Float:spawn_z | The z-coordinate for the added vehicle. |
| Float:z_angle | The facing-angle for the new vehicle. |
| color1 | The vehicle's primary color. |
| color2 | The vehicle's secondary color. |
| Returns | The added vehicles vehicleid. |
AddStaticVehicle(520, 2503.34, 2345.34, -322.43, 311.43, 0, 0);
[edit]
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)
| modelid | The vehicle model ID to be added. |
| Float:spawn_x | The x-coordinate for the added vehicle. |
| Float:spawn_y | The y-coordinate for the added vehicle. |
| Float:spawn_z | The z-coordinate for the added vehicle. |
| Float:z_angle | The facing-angle for the new vehicle. |
| color1 | The vehicle's primary color. |
| color2 | The vehicle's secondary color. |
| respawn_delay | The delay used for the vehicle to respawn. |
AddStaticVehicleEx(520, 2503.34, 2345.34, -322.43, 311.43, 0, 0, 600);
[edit]
AddVehicleComponent
Add a new component to the vehicle, nitro for example.
(vehicleid,componentid)
| vehicleid | The vehicle added ID. |
| componentid | The ID of the component that has to be added. |
AddVehicleComponent(25, 1095);
[edit]
ChangeVehicleColor
Change the vehicle's colors, which are set with the AddStaticVehicle(ex) function, or earlier with this function.
(vehicleid,color1,color2)
| vehicleid | The vehicle's added ID. |
| color1 | The new primary color of the vehicle. |
| color2 | The new secondary color of the vehicle. |
ChangeVehicleColor(100, 6, 6);
[edit]
ChangeVehiclePaintjob
This function allows you to change the paintjob of a specific vehicle.
(vehicleid,paintjobid)
| vehicleid | The vehicle's added ID. |
| paintjobid | The new paintjob ID to apply. |
ChangeVehiclePaintjob(100, 12);
[edit]
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)
| vehicletype | The model ID of the vehicle. |
| Float:x | The x-coordinate to spawn the vehicle. |
| Float:y | The y-coordinate to spawn the vehicle. |
| Float:z | The z-coordinate to spawn the vehicle. |
| Float:rotation | The rotation that must be applied to the vehicle. |
| color1 | The vehicle's primary color. |
| color2 | The vehicle's secondary color. |
| respawn_delay | The vehicle's respawn delay. |
CreateVehicle(520, 34.23, -1230.23, 19.34, 273.234, 6, 4, 600);
[edit]
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)
| vehicleid | The added ID of the vehicle. |
| &Float:x | The variable to store the x-coordinate in, passed by reference. |
| &Float:y | The variable to store the y-coordinate in, passed by reference. |
| &Float:z | The variable to store the z-coordinate in, passed by reference. |
GetVehiclePos(playerVehicle, x, y, z);
[edit]
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)
| vehicleid | The vehicle to change the parameters of. |
| playerid | The player where you want to change the parameters for. |
| objective | Does the vehicle have to be an objective? |
| doorslocked | Do you want the vehicle's doors to be locked? |
SetVehicleParamsForPlayer(vehicleid, playerid, 1, 1);
[edit]
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)
| vehicleid | The vehicle you want to move. |
| Float:x | The new x-coordinate for the vehicle. |
| Float:y | The new y-coordinate for the vehicle. |
| Float:z | The new z-coordinate for the vehicle. |
SetVehiclePos(vehicleid, 343.46, 459.34, 19.23);
[edit]
SetVehicleToRespawn
SetVehicleToRespawn allows you to respawn a specific vehicle, even when a player is currently driving it.
(vehicleid)
| vehicleid | The vehicle you want to respawn. |
SetVehicleToRespawn(vehicleid);
[edit]
SetVehicleZAngle
This function allows you to change the angle of a specific vehicle.
(vehicleid,Float:z_angle)
| vehicleid | The vehicle you want to change the angle of. |
| Float:z_angle | The new angle for the vehicle. |
SetVehicleZAngle(vehicleid, 270.0);
[edit]
SA-MP Functions (a_object.inc)
[edit]
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)
| modelid | The Model ID you want to use. |
| Float:X | The X coordinate. |
| Float:Y | The Y coordinate. |
| Float:Z | The Z coordinate. |
| Float:rX | The X rotation. |
| Float:rY | The Y rotation. |
| Float:rZ | the Z rotation. |
objectid = CreateObject( 2587, 2001.195679, 1547.113892, 14.283400, 0, 0, 96 );
[edit]
SetObjectPos
Moves an Object to the specified position.
(objectid, Float:X, Float:Y, Float:Z)
| objectid | This is the Object ID (Not the Model ID). |
| Float:X | The X coordinate. |
| Float:Y | The Y coordinate. |
| Float:Z | The Z coordinate. |
SetObjectPos( objectid, 2001.195679, 1547.113892, 14.283400 );
[edit]
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)
| objectid | The object's id of which you want the current location. |
| Float:X | The variable to store the X coordinate, passed by reference. |
| Float:Y | The variable to store the Y coordinate, passed by reference. |
| Float:Z | The variable to store the Z coordinate, passed by reference. |
GetObjectPos( objectid, x, y, z );
[edit]
SetObjectRot
Rotates an object in all directions.
(objectid, Float:RotX, Float:RotY, Float:RotZ)
| objectid | The objectid of the object you want to rotate. |
| Float:RotX | The X rotation. |
| Float:RotY | The Y rotation. |
| Float:RotZ | The Z rotation. |
SetObjectRot( objectid, 2.25, 0, 0 );
[edit]
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)
| objectid | The objectid of the object you want to get the rotation from. |
| Float:X | The variable to store the X rotation, passed by reference. |
| Float:Y | The variable to store the Y rotation, passed by reference. |
| Float:Z | The variable to store the Z rotation, passed by reference. |
GetObjectRot( objectid, RotX, RotY, RotZ );
[edit]
IsValidObject
Checks if the given objectid is valid.
| Returns | 1 if the object exists, 0 if not. |
(objectid)
| objectid | The objectid you want to validate. |
if ( IsValidObject( objectid ) ) { DoSomething( ); }
[edit]
DestroyObject
Destroys (removes) the given object.
(objectid)
| objectid | The objectid from the object you want to delete. |
DestroyObject( objectid );
[edit]
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)
| objectid | The objectid you want to move. |
| Float:X | The new X coordinate. |
| Float:Y | The new Y coordinate. |
| Float:Z | The new Z coordinate. |
| Float:Speed | The speed of which the object will be moved with. |
MoveObject( objectid, 2001.195679, 1547.113892, 10 );
[edit]
StopObject
Use this function to stop a moving object, for example after using MoveObject. To move a object in one time, use SetObjectPosition.
(objectid)
| objectid | The objectid of the object you want to stop moving. |
StopObject( objectid );
[edit]
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)
| playerid | The id of the player you want to set the object for. |
| modelid | The Model ID you want to use. |
| Float:X | The X coordinate. |
| Float:Y | The Y coordinate. |
| Float:Z | The Z coordinate. |
| Float:rX | The X rotation. |
| Float:rY | The Y rotation. |
objectid = CreatePlayerObject( playerid, 2587, 2001.195679, 1547.113892, 14.283400, 0, 0, 96 );
[edit]
SetPlayerObjectPos
Again, this function does the same as SetObjectPos but only for a specific player.
(playerid, objectid, Float:X, Float:Y, Float:Z)
| playerid | The id of the player you move the object for. |
| objectid | The objectid you want to move. |
| Float:X | The new X coordinate. |
| Float:Y | The new Y coordinate. |
| Float:Z | The new Z coordinate. |
SetPlayerObjectPos( playerid, objectid, 2001.195679, 1547.113892, 14.283400 );
[edit]
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)
| playerid | The playerid which is linked with the object. |
| objectid | The object's id of which you want the current location. |
| Float:X | The variable to store the X coordinate, passed by reference. |
| Float:Y | The variable to store the Y coordinate, passed by reference. |
| Float:Z | The variable to store the Z coordinate, passed by reference. |
GetPlayerObjectPos( playerid, objectid, x, y, z );
[edit]
SetPlayerObjectRot
Rotates an object in all directions.
(playerid, objectid, Float:RotX, Float:RotY, Float:RotZ)
| playerid | The playerid which is linked with the object. |
| objectid | The objectid of the object you want to rotate. |
| Float:RotX | The X rotation. |
| Float:RotY | The Y rotation. |
| Float:RotZ | The Z rotation. |
CreateObject( playerid, objectid, 0.12, 0 , 0 );
[edit]
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)
| playerid | The playerid of which is linked with the object. |
| objectid | The objectid of the object you want to get the rotation from. |
| Float:X | The variable to store the X rotation, passed by reference. |
| Float:Y | The variable to store the Y rotation, passed by reference. |
| Float:Z | The variable to store the Z rotation, passed by reference. |
GetPlayerObjectRot( playerid, objectid, RotX, RotY, RotZ );
[edit]
IsValidPlayerObject
Checks if the given objectid is valid object for the given playerid.
| Returns | 1 if the object is valid for that player, 0 if not. |
(playerid, objectid)
| playerid | The playerid which you want to know if it has access to the object. |
| objectid | The objectid you want to validate. |
if ( IsValidPlayerObject( playerid, objectid ) ) { DoSomething( ); }
[edit]
DestroyPlayerObject
use this function to destroy a object linked to a player created with CreatePlayerObject.
(playerid, objectid)
| playerid | The playerid which is linked with the object. |
| objectid | The objectid from the object you want to delete. |
DestroyPlayerObject( playerid, objectid );
[edit]
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)
| playerid | The playerid which is linked with the object. |
| objectid | The objectid you want to move. |
| Float:X | The new X coordinate. |
| Float:Y | The new Y coordinate. |
| Float:Z | The new Z coordinate. |
| Float:Speed | The speed of which the object will be moved with. |
MovePlayerObject( playerid, objectid, 2001.195679, 1547.113892, 14.283400, 10 );
[edit]
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)
| playerid | The playerid which is linked with the object. |
| objectid | The objectid of the object you want to stop moving. |
StopPlayerObject( playerid, objectid );
[edit]
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)
| objectid | The objectid you want to attach to the player. |
| playerid | The playerid which is linked with the object. |
| Float:OffsetX | The distance between the player and the object in the X direction. |
| Float:OffsetY | The distance between the player and the object in the Y direction. |
| Float:OffsetZ | The distance between the player and the object in the Z direction. |
| Float:RotX | The X rotation between the object and the player. |
| Float:RotY | The Y rotation between the object and the player. |
| Float:RotZ | The Z rotation between the object and the player. |
AttachObjectToPlayer( objectid, playerid, 1.5, 0.5, 0, 0, 1.5, 2 );
[edit]
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)
| objectplayer | The id of the player witch is linked with the object. |
| objectid | The objectid you want to attach to the player. |
| attachid | The id of the player you want to attach to the object. |
| Float:OffsetX | The distance between the player and the object in the X direction. |
| Float:OffsetY | The distance between the player and the object in the X direction. |
| Float:OffsetZ | The distance between the player and the object in the X direction. |
| Float:RotX | The X rotation. |
| Float:RotY | The Y rotation. |
| Float:RotZ | The Z rotation. |
AttachPlayerObjectToPlayer(bjectplayer, objectid, attachplayer, 1.5, 0.5, 0, 0, 1.5, 2 );
[edit]
Serverwindow functions
[edit]
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)
| Returns | This function always returns 0. |
clreol();
[edit]
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)
| Returns | This function always returns 0. |
clrscr();
[edit]
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)
| arg | The ID of the argument you want to know. |
| index=0 | Cell to read when the argument is a string. |
| Returns | This function returns one cell. |
getarg(0);
[edit]
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=0 | Do you want to echo the inputted character in the console window? |
| Returns | One cell with the inputted character. |
new char[1] = getchar(1);
[edit]
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=false | Do you want the string to be packed? |
getstring(string, 256, false);
[edit]
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=10 | The default radix to use. |
| end='\r' | The parameter to stop reading the value. |
| Returns | The requested value. |
new value = getvalue(10, '\r');
[edit]
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=1 | The x-position in the console to move the cursor to. |
| y=1 | The y-position in the console to move the cursor to. |
gotoxy(20,43);
[edit]
heapspace
Heapspace allows you to free the space on the heap, the shared memory area.
(No Parameters)
| Returns | The number of bytes the function saved. |
new sparedBytes = heapspace();
[edit]
numargs
This function returns the number of arguments given to a function with a dynamic number of arguments.
(No Parameters)
| Returns | The number of arguments given. |
new argumentCount = numargs();
[edit]
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.");
[edit]
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);
[edit]
setarg
Change the value of a given argument.
(arg,index=0,value)
| arg | The argument ID you want to change. |
| index=0 | The argument's cell. |
| value | The new value |
setarg(0, 3, "e");
[edit]
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)
| &x | The variable to store the x-position in, passed by reference. |
| &y | The variable to store the y-position in, passed by reference. |
| Returns | This function always returns 0. |
wherexy(x,y);
[edit]
Properties
[edit]
deleteproperty
This function allows you to delete an earlier set property.
(id=0,const name[]="",value=cellmin)
| id=0 | Defines which virtual machine to use. |
| const name[]="" | Defines if to use with call by name, you should keep this "". |
| value=cellmin | This identifys the variable. Use the hash-function to calculate it from a string. |
deleteproperty(0, "", 123984334);
[edit]
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=0 | The virtual machine to use, you should keep this zero. |
| const name[]="" | Use the property by its name, you should keep this "". |
| value=cellmin | The property's hash, probably generated by Adler 32. |
if(existproperty(0, "", 9384932)){
[edit]
getproperty
Get a specific property from the memory, the string is returned as a packed string!
(id=0,const name[]="",value=cellmin,&string[]="")
| id=0 | The virtual machine to use, you should keep this zero. |
| const name[]="" | The property's name, you should keep this "". |
| value=cellmin | The property's hash, can be generated via Adler 32. |
| &string[]="" | The variable to store the result in, passed by reference. |
getproperty(0, "", 93473413, value);
[edit]
setproperty
Use this function to save a value into a property.
(id=0,const name[]="",value=cellmin,const string[]="")
| id=0 | The virtual machine to use, should be kept zero. |
| const name[]="" | The name of the property, should be kept empty. |
| value=cellmin | The 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);
[edit]
UDP Broadcasting functions
[edit]
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)
| port | The portnumber used for listening. |
listenport(7778);
[edit]
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. |
| size | The 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);
[edit]
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");
[edit]
File functions (file.inc)
You may refer also on File tutorial for a tutorial on this.
[edit]
fblockread
This function allows you to read data from a file, without encoding and line terminators (binary format)
(handle,buffer[],size=sizeof buffer)
| handle | File handle to use, opened by fopen() |
| buffer[] | The buffer to save the read data in. |
| size=sizeof buffer | The number of cells to read. |
fblockread(gFile, string, 256);
[edit]
fblockwrite
Write data to a file in binary format, while ignoring line brakes and encoding.
(handle,const buffer[],size=sizeof buffer)
| handle | The File handle to use, opened by fopen(). |
| const buffer[] | The data to write to the file. |
| size=sizeof buffer | The number of cells to write. |
fblockwrite(gFile, "Save this data!", 15);
[edit]
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)
| handle | The File handle to close, opened by fopen(). |
fclose(gFile);
[edit]
fexist
Check if a specific file exists in your scriptfiles directory.
(const pattern[])
| const pattern[] | The filename to check if it exists. |
| Returns | 1 is the file exist, 0 if it doesn't. |
if(fexist("datafile.txt")){
[edit]
fgetchar
This function reads one character from the file, and saves it in the value variable, passed by reference.
(handle,&value,utf8=true)
| handle | The File handle to use, opened by fopen(). |
| &value | The variable to save the character in. |
| utf8=true | Read the character as UTF8. |
fgetchar(gFile, handle, false);
[edit]
flength
Check the length of a file which is already opened.
(handle)
| handle | The File handle to use, opened by fopen(). |
| Returns | The length of the file, in bytes. |
new fileLength = flength(gFile);
[edit]
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=0 | The offset to start searching. |
| size=sizeof name | The amount of characters to search in. |
fmatch("searchFile.txt", "Peter", 0);
[edit]
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_readwrite | The mode which you like to use for opening the file. |
| Returns | The File handle |
new File:gFile = fopen("exampleFile.txt", io_readwrite);
[edit]
fputchar
This function writes one character to the file.
(handle,value,utf8=true)
| handle | The File handle to use, earlier opened by fopen(). |
| value | The character you want to write. |
| utf8=true | Should the character be written as UTF8? |
fputchar(gFile, 'e', false);
[edit]
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)
| handle | The File handle to use, earlier opened by fopen(). |
| &string[] | The string you want to save the data in, passed by reference. |
| size=sizeof string | The number of bytes to read. |
| pack=false | Should the string reference be packed? |
fread(gFile, string, sizeof(string));
[edit]
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");
[edit]
fseek
Change the current position in the file. You can either seek forward or backward through the file.
(handle,position=0,whence=seek_start)
| handle | The File handle to use, earlier opened by fopen(). |
| position=0 | The position to place the file-cursor. |
| whence=seek_start | The way to seek within the file. |
fseek(gFile, 25);
[edit]
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)
| Returns | The File handle |
new File:gFile = ftemp();
[edit]
fwrite
Write a specific string or line to the file. Remember that the file has to be opened for writing.
(handle,const string[])
| handle | The 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!");
[edit]
Float functions (float.inc)
[edit]
float
This function converts an integer value to a float.
(value)
| value | The integer you want to convert to a float. |
new Float:fVar = float(122);
[edit]
floatabs
Returns the absolute value of a float.
(value)
| value | The float you want to check |
| Returns | The absolute value of the float. |
new Float:fAbs = floatabs(-123.54);
[edit]
floatadd
Calculate the sum of two floats, it's the same as Float1 + Float2.
(oper1,oper2)
| oper1 | The first float value. |
| oper2 | The value you want to add with the first argument. |
| Returns | The sum of the two floats. |
new Float:fSum = floatadd(123.45, 678.90);
[edit]
floatcmp
Compare two floats to each other.
(oper1,oper2)
| oper1 | The first float you want to compare. |
| oper2 | The second float you want to compare. |
| Returns | 1 if the first argument is larger, -1 is the second one is larger. |
new compare = floatcmp(127.45, 127.450);
[edit]
floatcos
Calculate the right cosine of a float, with a specific anglemode.
(value,anglemode=radian)
| value | The float you want to know the cosine of. |
| anglemode=radian | The Anglemode. |
| Returns | The cosine of the given float. |
new Float:fCos = floatcos(87.343, radian);
[edit]
floatdiv
Divide a float with a value specified by the divisor float.
(dividend,divisor)
| dividend | The float value you want to divide. |
| divisor | The (float) value you want to divide it with. |
| Returns | This function returns the divided value as a float. |
new Float:fDivide = floatdiv(128.00, 32.00);
[edit]
floatfract
Calculate and return the fractional part of a float.
(value)
| value | The float you want to know that fractional path of. |
| Returns | The fractional part of the float. |
new Float:fFract = floatfract(3249.34);
[edit]
floatlog
Use this function if you want to know the logarithm of a float.
(value,base=10.0)
| value | The float you want to know the log. of. |
| base=10.0 | The base value to use. |
| Returns | The logarithm value of the float. |
new Float:fLog = floatlog(128.0);
[edit]
floatmul
Multiply the two floats with eachother, and returns the product.
(oper1,oper2)
| oper1 | The first float you want to multiply. |
| oper2 | And the second one. |
| Returns | The product of the two floats. |
new Float:fMul = floatmul(128.1,7.9);
[edit]
floatpower
Raises the float to the power of the exponent float.
(value,exponent)
| value | The float you want to raise. |
| exponent | The exponent you want, as a float. |
| Returns | The float raised by the power of the exponent. |
new Float:fPower = floatpower(128.0, 8.0); // 1024
[edit]
floatround
Round the float values with the given method.
(value,:method=floatround_round)
| value | The float value you want to round. |
| :method=floatround_round | The float-round method you wish to use. |
| Returns | The rounded value as a integer. |
new round = floatround(128.9, floatround_floor);
[edit]
floatsin
Calculate the sinus of the given float, with the anglemode in radian, degrees or grads
(value,anglemode:mode=radian)
| value | The float you want to know the sinus of. |
| mode=radian | The Anglemode. |
| Returns | The sinus of the given float. |
new Float:fSin = floatsin(82.4);
[edit]
floatsqroot
Calculate the square root of the given float.
(value)
| value | The float you want to know the square root of. |
| Returns | The square root of the float. |
new Float:fSqroot = floatsqroot(743.34);
[edit]
floatsub
Decrease the first oper1 value with the float given in oper2.
(oper1,oper2)
| oper1 | The float you want to decrease with the second value. |
| oper2 | The value to decrease the first value with. |
| Returns | The leftover value of the first argument. |
new Float:fSub = floatsub(233.54, 23.34);
[edit]
floattan
Calculate the tangent of the given float in the first argument, using it on a radian, grads or degree basis.
(value,mode=radian)
| value | The float you want to know the tangent of. |
| mode=radian | The you Anglemode wish to use. |
| Returns | The tangent value of the float. |
new Float:fTan = floattan(87.4);
[edit]
floatstr
Convert a string to it's rightful float value.
(const string[])
| const string[] | The string you want to convert to a float. |
| Returns | The requested float. |
new Float:fFloat = floatstr("124.34");
[edit]
String functions (string.inc)
[edit]
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);
[edit]
ispacked
Check if the given string is packed, and return the result.
(const string[])
| const string[] | The string you want to check. |
| Returns | 1 if the string is packed, 0 if it's unpacked. |
if(ispacked(string)){
[edit]
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=0 | The offset within the source to copy. |
| numbytes | The number of bytes to copy. |
| maxlength=sizeof dest | The size of the destination argument. |
memcpy(playerNames[playerid], playerName, 0, MAX_PLAYER_NAME);
[edit]
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 dest | The maximum length of the destination. |
| Returns | The length of the new destination string. |
strcat(destination, "Hi, how are you?", sizeof(destination));
[edit]
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=false | Ignore capitals if true. |
| length=cellmax | The maximum number of cells to check. |
| Returns | 0 if the string are equal to each other. |
if(strcmp(cmdtext, "/me", true) == 0){
[edit]
strdel
This function deletes a part from a string.
(string[],start,end)
| string[] | The string you want to delete a part of. |
| start | The offset to start deleting. |
| end | The end, where to stop deleting (start + number of chars) |
strdel("Peter is cool", 8, 10);
[edit]
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=false | Ignore capitals if true. |
| pos=0 | The offset to start searching. |
| Returns | The occurance of the substr, returns -1 if it's not found. |
new instring = strfind("Are you in here?", "you", true);
[edit]
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. |
| pos | The position to start inserting. |
| maxlength=sizeof string | The maximum size to insert. |
strins("f3llah1n is a ", "silly boy", 15);
[edit]
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. |
| Returns | The length as an integer value. |
new stringLength = strlen("This is an example string.");
[edit]
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. |
| start | The position of the first character. |
| end | The position of the last character. |
| maxlength=sizeof dest | The maximum length of dest. |
strmid(string, "Grab the this word without !: HELLO!!!!", 30, 35); //string contains "HELLO"
[edit]
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 dest | The maximum size of dest to use. |
strpack(string, "Hi, how are you?");
[edit]
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 dest | The length of the destination string. |
strunpack(string, packedString);
[edit]
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. |
| Returns | The integer value of the string. |
new iValue = strval("250");
[edit]
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 dest | The maximum length of dest that can be used. |
uudecode(decodedString, encodedString);
[edit]
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. |
| numbytes | The number of bytes to encode, this should not exceed 45. |
| maxlength=sizeof dest | The maximum length of the dest[] array. |
uudecode(encodedString, normalString, 45);
[edit]
valstr
Converts an integer value to a string.
(dest[],value,pack=false)
| dest[] | The string to store the value in. |
| value | The integer value to convert to a string. |
| pack=false | Pack the string if true. |
valstr(string, 454);
[edit]
Misc functions
[edit]
getdate
Get the current server date, which will be stored in the variables &year, &month and &day.
(&year=0,&month=0,&day=0)
| &year=0 | The variable to store the year in, passed by reference. |
| &month=0 | The variable to store the month in, passed by reference. |
| &day=0 | The variable to store the day in, passed by reference. |
| Returns | The number of days since the start of the year. |
new Year, Month, Day;
getdate(Year, Month, Day);
printf("%02d/%02d/%d", Day, Month, Year);
[edit]
GetTickCount
Get the number of ticks, since the server's last restart. This function only works on Windows!
(No Parameters)
| Returns | The number of ticks since the servers last restart. |
new Ticks = GetTickCount();
[edit]
gettime
Get the current server time, which will be stored in the variables &hour, &minute and &second.
(&hour=0,&minute=0,&second=0)
| &hour=0 | The variable to store the hour in, passed by reference. |
| &minute=0 | The variable to store the minute in, passed by reference. |
| &second=0 | The variable to store the seconds in, passed by reference. |
| Returns | The number of seconds since midnight, 1 January 1970. |
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
printf("%02d:%02d:%02d, Hour, Minute, Second);
[edit]
KillTimer
Kill a specific timer, this is only necessary for timers that stay running.
(timerid)
| timerid | The ID of the timer you want to kill. |
KillTimer(gameTimerID);
[edit]
random
Get a pseudo-random number, which will be number different possibilities starting with 0, ending with the number one smaller then number.
(max)
| max | The maximum number for the random sequence. |
| Returns | A random number between 0 and max. |
new iRandomNumber = random(25); // random number between 0 and 24
[edit]
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. |
| interval | The interval to call the timer, in milliseconds. An interval of 1000 means every second. |
| repeating | false to run once, true to keep running. |
| Returns | The ID of the timer. |
new gameTimerID = SetTimer("ExitGameFunc", 600000, 0);
[edit]
sizeof
Returns the defined length of a variable.
(variable[])
| variable[] | The variable you want to know the length of.. |
| Returns | The length as number of cells. |
new string[256]; new length = sizeof(string); // length = 256
[edit]
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=0 | This is an indication of the accuracy of the function, passed by reference. |
| Returns | The number of ticks since the server's start-up. |
new iTickCount = tickcount();
