samp-node-lib
Version:
NodeJS library for Scripting San Andreas Multiplayer:SAMP depends on samp-node plugin
1,031 lines (1,009 loc) • 654 kB
TypeScript
// Type definitions for samp-node
// Project: @sa-mp/node
// Definitions by: pkfln <https://github.com/pkfln>
/*
* @class samp
*/
declare class samp {
/**
* Adds a new listener to OnGameModeInit
*
* @name samp.on
* @param {string} [eventName=OnGameModeInit] - Name of the event
* @param {function} func - Event callback
* @summary This callback is triggered when the gamemode starts.
* @see OnGameModeExit
* @see OnFilterScriptInit
* @see OnFilterScriptExit
* @remarks This function can also be used in a filterscript to detect if the gamemode changes with RCON commands like changemode or gmx, as changing the gamemode does not reload a filterscript.
* @returns {void}
*/
static on(eventName: 'OnGameModeInit', func: () => void): void;
/**
* Adds a new listener to OnGameModeExit
*
* @name samp.on
* @param {string} [eventName=OnGameModeExit] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a gamemode ends, either through 'gmx', the server being shut down, or GameModeExit.
* @see OnGameModeInit
* @see OnFilterScriptExit
* @see OnFilterScriptInit
* @see GameModeExit
* @remarks This function can also be used in a filterscript to detect if the gamemode changes with RCON commands like changemode or gmx, as changing the gamemode does not reload a filterscript.
* @remarks When using OnGameModeExit in conjunction with the 'rcon gmx' console command keep in mind there is a potential for client bugs to occur an example of this is excessive RemoveBuildingForPlayer calls during OnGameModeInit which could result in a client crash.
* @remarks This callback will NOT be called if the server crashes or the process is killed by other means, such as using the Linux kill command or pressing the close-button on the Windows console.
* @returns {void}
*/
static on(eventName: 'OnGameModeExit', func: () => void): void;
/**
* Adds a new listener to OnFilterScriptInit
*
* @name samp.on
* @param {string} [eventName=OnFilterScriptInit] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a filterscript is initialized (loaded). It is only called inside the filterscript which is starting.
* @see OnFilterScriptExit
* @see OnGameModeInit
* @see OnGameModeExit
* @returns {void}
*/
static on(eventName: 'OnFilterScriptInit', func: () => void): void;
/**
* Adds a new listener to OnFilterScriptExit
*
* @name samp.on
* @param {string} [eventName=OnFilterScriptExit] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a filterscript is unloaded. It is only called inside the filterscript which is unloaded.
* @see OnFilterScriptInit
* @see OnGameModeInit
* @see OnGameModeExit
* @returns {void}
*/
static on(eventName: 'OnFilterScriptExit', func: () => void): void;
/**
* Adds a new listener to OnPlayerConnect
*
* @name samp.on
* @param {string} [eventName=OnPlayerConnect] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player connects to the server.
* @see OnPlayerDisconnect
* @see OnIncomingConnection
* @see OnPlayerFinishedDownloading
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerConnect', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnPlayerDisconnect
*
* @name samp.on
* @param {string} [eventName=OnPlayerDisconnect] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player disconnects from the server.
* @see OnPlayerConnect
* @see OnIncomingConnection
* @see OnPlayerFinishedDownloading
* @remarks This callback can also be called by NPC.
* @remarks Some functions might not work correctly when used in this callback because the player is already disconnected when the callback is called. This means that you can't get unambiguous information from functions like GetPlayerIp and GetPlayerPos.
* @remarks
Reasons:
0 - timeout/Crash - the player's connection was lost. Either their game crashed or their network had a fault.
1 - quit - the player purposefully quit, either using the /quit (/q) command or via the pause menu.
2 - kick/ban - the player was kicked or banned by the server.
* @returns {void}
*/
static on(eventName: 'OnPlayerDisconnect', func: (playerid: number, reason: number) => void): void;
/**
* Adds a new listener to OnPlayerSpawn
*
* @name samp.on
* @param {string} [eventName=OnPlayerSpawn] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player spawns.(i.e. after caling SpawnPlayer function).
* @see OnPlayerDeath
* @see OnVehicleSpawn
* @see SpawnPlayer
* @see AddPlayerClass
* @see SetSpawnInfo
* @remarks This callback can also be called by NPC.
* @remarks The game sometimes deducts $100 from players after spawn.
* @returns {void}
*/
static on(eventName: 'OnPlayerSpawn', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnPlayerDeath
*
* @name samp.on
* @param {string} [eventName=OnPlayerDeath] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player dies, either by suicide or by being killed by another player.
* @see OnPlayerSpawn
* @see SendDeathMessage
* @see SetPlayerHealth
* @remarks
The reason will return 37 (flame thrower) from any fire sources (e.g. molotov, 18)
The reason will return 51 from any weapon that creates an explosion (e.g. RPG, grenade)
You do not need to check whether killerid is valid before using it in SendDeathMessage. INVALID_PLAYER_ID is a valid killerid ID parameter in that function.
playerid is the only one who can call the callback. (good to know for anti fake death)
* @returns {void}
*/
static on(eventName: 'OnPlayerDeath', func: (playerid: number, killerid: number, reason: number) => void): void;
/**
* Adds a new listener to OnVehicleSpawn
*
* @name samp.on
* @param {string} [eventName=OnVehicleSpawn] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a vehicle respawns.
* @see OnVehicleDeath
* @see OnPlayerSpawn
* @see SetVehicleToRespawn
* @see CreateVehicle
* @returns {void}
*/
static on(eventName: 'OnVehicleSpawn', func: (vehicleid: number) => void): void;
/**
* Adds a new listener to OnVehicleDeath
*
* @name samp.on
* @param {string} [eventName=OnVehicleDeath] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a vehicle is destroyed - either by exploding or becoming submerged in water.
* @see OnVehicleSpawn
* @see SetVehicleHealth
* @remarks This callback can also be called by NPC.
* @remarks This callback will also be called when a vehicle enters water, but the vehicle can be saved from destruction by teleportation or driving out (if only partially submerged). The callback won't be called a second time, and the vehicle may disappear when the driver exits, or after a short time.
* @returns {void}
*/
static on(eventName: 'OnVehicleDeath', func: (vehicleid: number, killerid: number) => void): void;
/**
* Adds a new listener to OnPlayerText
*
* @name samp.on
* @param {string} [eventName=OnPlayerText] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player sends a chat message.
* @see OnPlayerCommandText
* @see SendPlayerMessageToPlayer
* @see SendPlayerMessageToAll
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerText', func: (playerid: number, text: string) => void): void;
/**
* Adds a new listener to OnPlayerCommandText
*
* @name samp.on
* @param {string} [eventName=OnPlayerCommandText] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player enters a command into the client chat window. Commands are anything that start with a forward slash, e.g. /help.
* @see OnPlayerText
* @see OnRconCommand
* @see SendRconCommand
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerCommandText', func: (playerid: number, cmdtext: string) => void): void;
/**
* Adds a new listener to OnPlayerRequestClass
*
* @name samp.on
* @param {string} [eventName=OnPlayerRequestClass] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player changes class at class selection (and when class selection first appears).
* @see OnPlayerRequestSpawn
* @see AddPlayerClass
* @remarks This callback can also be called by NPC.
* @remarks This callback is also called when a player presses F4.
* @returns {void}
*/
static on(eventName: 'OnPlayerRequestClass', func: (playerid: number, classid: number) => void): void;
/**
* Adds a new listener to OnPlayerEnterVehicle
*
* @name samp.on
* @param {string} [eventName=OnPlayerEnterVehicle] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player starts to enter a vehicle, meaning the player is not in vehicle yet at the time this callback is called.
* @see OnPlayerExitVehicle
* @see OnPlayerStateChange
* @see PutPlayerInVehicle
* @see GetPlayerVehicleSeat
* @remarks This callback is called when a player BEGINS to enter a vehicle, not when they HAVE entered it. See OnPlayerStateChange.
* @remarks This callback is still called if the player is denied entry to the vehicle (e.g. it is locked or full).
* @returns {void}
*/
static on(eventName: 'OnPlayerEnterVehicle', func: (playerid: number, vehicleid: number, ispassenger: number) => void): void;
/**
* Adds a new listener to OnPlayerExitVehicle
*
* @name samp.on
* @param {string} [eventName=OnPlayerExitVehicle] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player starts to exit a vehicle.
* @see OnPlayerEnterVehicle
* @see OnPlayerStateChange
* @see RemovePlayerFromVehicle
* @see GetPlayerVehicleSeat
* @remarks Not called if the player falls off a bike or is removed from a vehicle by other means such as using SetPlayerPos.
* @remarks You must use OnPlayerStateChange and check if their old state is PLAYER_STATE_DRIVER or PLAYER_STATE_PASSENGER and their new state is PLAYER_STATE_ONFOOT.
* @returns {void}
*/
static on(eventName: 'OnPlayerExitVehicle', func: (playerid: number, vehicleid: number) => void): void;
/**
* Adds a new listener to OnPlayerStateChange
*
* @name samp.on
* @param {string} [eventName=OnPlayerStateChange] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player changes state. For example, when a player changes from being the driver of a vehicle to being on-foot.
* @see OnPlayerInteriorChange
* @see GetPlayerState
* @see GetPlayerSpecialAction
* @see SetPlayerSpecialAction
* @remarks This callback can also be called by NPC.
* @remarks
States:
PLAYER_STATE_NONE - empty (while initializing)
PLAYER_STATE_ONFOOT - player is on foot
PLAYER_STATE_DRIVER - player is the driver of a vehicle
PLAYER_STATE_PASSENGER - player is passenger of a vehicle
PLAYER_STATE_WASTED - player is dead or on class selection
PLAYER_STATE_SPAWNED - player is spawned
PLAYER_STATE_SPECTATING - player is spectating
PLAYER_STATE_EXIT_VEHICLE - player exits a vehicle
PLAYER_STATE_ENTER_VEHICLE_DRIVER - player enters a vehicle as driver
PLAYER_STATE_ENTER_VEHICLE_PASSENGER - player enters a vehicle as passenger
* @returns {void}
*/
static on(eventName: 'OnPlayerStateChange', func: (playerid: number, newstate: number, oldstate: number) => void): void;
/**
* Adds a new listener to OnPlayerEnterCheckpoint
*
* @name samp.on
* @param {string} [eventName=OnPlayerEnterCheckpoint] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player enters the checkpoint set for that player.
* @see OnPlayerLeaveCheckpoint
* @see OnPlayerEnterRaceCheckpoint
* @see OnPlayerLeaveRaceCheckpoint
* @see SetPlayerCheckpoint
* @see DisablePlayerCheckpoint
* @see IsPlayerInCheckpoint
* @see SetPlayerRaceCheckpoint
* @see DisablePlayerRaceCheckpoint
* @see IsPlayerInRaceCheckpoint
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerEnterCheckpoint', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnPlayerLeaveCheckpoint
*
* @name samp.on
* @param {string} [eventName=OnPlayerLeaveCheckpoint] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player leaves the checkpoint set for them by SetPlayerCheckpoint. Only one checkpoint can be set at a time.
* @see OnPlayerEnterCheckpoint
* @see OnPlayerEnterRaceCheckpoint
* @see OnPlayerLeaveRaceCheckpoint
* @see SetPlayerCheckpoint
* @see DisablePlayerCheckpoint
* @see IsPlayerInCheckpoint
* @see SetPlayerRaceCheckpoint
* @see DisablePlayerRaceCheckpoint
* @see IsPlayerInRaceCheckpoint
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerLeaveCheckpoint', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnPlayerEnterRaceCheckpoint
*
* @name samp.on
* @param {string} [eventName=OnPlayerEnterRaceCheckpoint] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player enters a race checkpoint.
* @see OnPlayerEnterCheckpoint
* @see OnPlayerLeaveCheckpoint
* @see OnPlayerLeaveRaceCheckpoint
* @see SetPlayerCheckpoint
* @see DisablePlayerCheckpoint
* @see IsPlayerInCheckpoint
* @see SetPlayerRaceCheckpoint
* @see DisablePlayerRaceCheckpoint
* @see IsPlayerInRaceCheckpoint
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerEnterRaceCheckpoint', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnPlayerLeaveRaceCheckpoint
*
* @name samp.on
* @param {string} [eventName=OnPlayerLeaveRaceCheckpoint] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player leaves the race checkpoint.
* @see OnPlayerEnterCheckpoint
* @see OnPlayerLeaveCheckpoint
* @see OnPlayerEnterRaceCheckpoint
* @see SetPlayerCheckpoint
* @see DisablePlayerCheckpoint
* @see IsPlayerInCheckpoint
* @see SetPlayerRaceCheckpoint
* @see DisablePlayerRaceCheckpoint
* @see IsPlayerInRaceCheckpoint
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerLeaveRaceCheckpoint', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnRconCommand
*
* @name samp.on
* @param {string} [eventName=OnRconCommand] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a command is sent through the server console, remote RCON, or via the in-game "/rcon command".
* @see IsPlayerAdmin
* @see OnRconLoginAttempt
* @remarks You will need to include this callback in a loaded filterscript for it to work in the gamemode!
* @remarks "/rcon" is not included in "cmd" when a player types a command.
* @remarks If you use the print function here, it will send a message to the player who typed the command in-game as well as the log.
* @remarks This callback is not called when the player is not logged in as RCON admin.
* @remarks When the player is not logged in as RCON admin and uses /rcon login, this callback will not be called and OnRconLoginAttempt is called instead. However, when the player is logged in as RCON admin, the use of this command will call this callback.
* @returns {void}
*/
static on(eventName: 'OnRconCommand', func: (cmd: string) => void): void;
/**
* Adds a new listener to OnPlayerRequestSpawn
*
* @name samp.on
* @param {string} [eventName=OnPlayerRequestSpawn] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player attempts to spawn via class selection either by pressing SHIFT or clicking the 'Spawn' button.
* @see OnPlayerSpawn
* @see OnPlayerRequestClass
* @remarks This callback can also be called by NPC.
* @remarks To prevent players from spawning with certain classes, the last viewed class must be saved in a variable in OnPlayerRequestClass.
* @returns {void}
*/
static on(eventName: 'OnPlayerRequestSpawn', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnObjectMoved
*
* @name samp.on
* @param {string} [eventName=OnObjectMoved] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when an object is moved after MoveObject (when it stops moving).
* @see MoveObject
* @see IsObjectMoving
* @see StopObject
* @see OnPlayerObjectMoved
* @remarks SetObjectPos does not work when used in this callback. To fix it, recreate the object.
* @returns {void}
*/
static on(eventName: 'OnObjectMoved', func: (objectid: number) => void): void;
/**
* Adds a new listener to OnPlayerObjectMoved
*
* @name samp.on
* @param {string} [eventName=OnPlayerObjectMoved] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player object is moved after MovePlayerObject (when it stops moving).
* @see OnObjectMoved
* @see MovePlayerObject
* @see IsPlayerObjectMoving
* @see StopPlayerObject
* @remarks This callback can also be called for NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerObjectMoved', func: (playerid: number, objectid: number) => void): void;
/**
* Adds a new listener to OnPlayerPickUpPickup
*
* @name samp.on
* @param {string} [eventName=OnPlayerPickUpPickup] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player picks up a pickup created with CreatePickup.
* @see CreatePickup
* @see DestroyPickup
* @returns {void}
*/
static on(eventName: 'OnPlayerPickUpPickup', func: (playerid: number, pickupid: number) => void): void;
/**
* Adds a new listener to OnVehicleMod
*
* @name samp.on
* @param {string} [eventName=OnVehicleMod] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a vehicle is modded.
* @see AddVehicleComponent
* @see OnEnterExitModShop
* @see OnVehiclePaintjob
* @see OnVehicleRespray
* @remarks This callback is NOT called by AddVehicleComponent.
* @returns {void}
*/
static on(eventName: 'OnVehicleMod', func: (playerid: number, vehicleid: number, componentid: number) => void): void;
/**
* Adds a new listener to OnEnterExitModShop
*
* @name samp.on
* @param {string} [eventName=OnEnterExitModShop] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player enters or exits a mod shop.
* @see OnVehicleMod
* @see OnVehicleRespray
* @see OnVehiclePaintjob
* @see AddVehicleComponent
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks Players collide when they get into the same mod shop.
* @returns {void}
*/
static on(eventName: 'OnEnterExitModShop', func: (playerid: number, enterexit: number, interiorid: number) => void): void;
/**
* Adds a new listener to OnVehiclePaintjob
*
* @name samp.on
* @param {string} [eventName=OnVehiclePaintjob] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player previews a vehicle paintjob inside a mod shop. Watch out, this callback is not called when the player buys the paintjob.
* @see ChangeVehiclePaintjob
* @see ChangeVehicleColor
* @see OnVehicleRespray
* @see OnVehicleMod
* @remarks This callback is not called by ChangeVehiclePaintjob.
* @returns {void}
*/
static on(eventName: 'OnVehiclePaintjob', func: (playerid: number, vehicleid: number, paintjobid: number) => void): void;
/**
* Adds a new listener to OnVehicleRespray
*
* @name samp.on
* @param {string} [eventName=OnVehicleRespray] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player exits a mod shop, even if the colors weren't changed. Watch out, the name is ambiguous, Pay 'n' Spray shops don't call this callback.
* @see ChangeVehicleColor
* @see ChangeVehiclePaintjob
* @see OnVehiclePaintjob
* @see OnVehicleMod
* @see OnEnterExitModShop
* @remarks Previewing a component inside a mod shop might call this callback.
* @remarks This callback is not called by ChangeVehicleColor.
* @returns {void}
*/
static on(eventName: 'OnVehicleRespray', func: (playerid: number, vehicleid: number, color1: number, color2: number) => void): void;
/**
* Adds a new listener to OnVehicleDamageStatusUpdate
*
* @name samp.on
* @param {string} [eventName=OnVehicleDamageStatusUpdate] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a vehicle element such as doors, tires, panels, or lights change their damage status.
* @see GetVehicleDamageStatus
* @see UpdateVehicleDamageStatus
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks This does not include vehicle health changes
* @returns {void}
*/
static on(eventName: 'OnVehicleDamageStatusUpdate', func: (vehicleid: number, playerid: number) => void): void;
/**
* Adds a new listener to OnUnoccupiedVehicleUpdate
*
* @name samp.on
* @param {string} [eventName=OnUnoccupiedVehicleUpdate] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player's client updates/syncs the position of a vehicle they're not driving. This can happen outside of the vehicle or when the player is a passenger of a vehicle that has no driver.
* @see OnTrailerUpdate
* @remarks This callback was added in SA-MP 0.3c R3 and will not work in earlier versions!
* @remarks This callback is called very frequently per second per unoccupied vehicle. You should refrain from implementing intensive calculations or intensive file writing/reading operations in this callback.
* @remarks GetVehiclePos will return the old coordinates of the vehicle before this update.
* @returns {void}
*/
static on(eventName: 'OnUnoccupiedVehicleUpdate', func: (vehicleid: number, playerid: number, passenger_seat: number, new_x: number, new_y: number, new_z: number, vel_x: number, vel_y: number, vel_z: number) => void): void;
/**
* Adds a new listener to OnPlayerSelectedMenuRow
*
* @name samp.on
* @param {string} [eventName=OnPlayerSelectedMenuRow] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player selects an item from a menu (ShowMenuForPlayer).
* @see OnPlayerExitedMenu
* @see OnDialogResponse
* @see CreateMenu
* @see DestroyMenu
* @see AddMenuItem
* @see ShowMenuForPlayer
* @see HideMenuForPlayer
* @remarks The menu ID is not passed to this callback. GetPlayerMenu must be used to determine which menu the player selected an item on.
* @returns {void}
*/
static on(eventName: 'OnPlayerSelectedMenuRow', func: (playerid: number, row: number) => void): void;
/**
* Adds a new listener to OnPlayerExitedMenu
*
* @name samp.on
* @param {string} [eventName=OnPlayerExitedMenu] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player exits a menu.
* @see OnPlayerSelectedMenuRow
* @see CreateMenu
* @see DestroyMenu
* @returns {void}
*/
static on(eventName: 'OnPlayerExitedMenu', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnPlayerInteriorChange
*
* @name samp.on
* @param {string} [eventName=OnPlayerInteriorChange] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player changes interior. Can be triggered by SetPlayerInterior or when a player enter/exits a building.
* @see SetPlayerInterior
* @see GetPlayerInterior
* @see LinkVehicleToInterior
* @see OnPlayerStateChange
* @returns {void}
*/
static on(eventName: 'OnPlayerInteriorChange', func: (playerid: number, newinteriorid: number, oldinteriorid: number) => void): void;
/**
* Adds a new listener to OnPlayerKeyStateChange
*
* @name samp.on
* @param {string} [eventName=OnPlayerKeyStateChange] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when the state of any supported key is changed (pressed/released). Directional keys do not trigger OnPlayerKeyStateChange (up/down/left/right).
* @see GetPlayerKeys
* @remarks This callback can also be called by NPC.
* @remarks
Useful macros:
// HOLDING(keys)
#define HOLDING(%0) ((newkeys & (%0)) == (%0))
// PRESSED(keys)
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
// PRESSING(keyVariable, keys)
#define PRESSING(%0,%1) (%0 & (%1))
// RELEASED(keys)
#define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
* @returns {void}
*/
static on(eventName: 'OnPlayerKeyStateChange', func: (playerid: number, newkeys: number, oldkeys: number) => void): void;
/**
* Adds a new listener to OnRconLoginAttempt
*
* @name samp.on
* @param {string} [eventName=OnRconLoginAttempt] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when someone attempts to log in to RCON in-game; successful or not.
* @see OnRconCommand
* @see IsPlayerAdmin
* @see SendRconCommand
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks This callback is only called when /rcon login is used in-game.
* @remarks This callback is only called when the player is not yet logged in. When the player is logged in, OnRconCommand is called instead.
* @returns {void}
*/
static on(eventName: 'OnRconLoginAttempt', func: (ip: string, password: string, success: number) => void): void;
/**
* Adds a new listener to OnPlayerUpdate
*
* @name samp.on
* @param {string} [eventName=OnPlayerUpdate] - Name of the event
* @param {function} func - Event callback
* @returns {void}
*/
static on(eventName: 'OnPlayerUpdate', func: (playerid: number) => void): void;
/**
* Adds a new listener to OnPlayerStreamIn
*
* @name samp.on
* @param {string} [eventName=OnPlayerStreamIn] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player is streamed by some other player's client.
* @see OnPlayerStreamOut
* @see OnActorStreamIn
* @see OnVehicleStreamIn
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerStreamIn', func: (playerid: number, forplayerid: number) => void): void;
/**
* Adds a new listener to OnPlayerStreamOut
*
* @name samp.on
* @param {string} [eventName=OnPlayerStreamOut] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player is streamed out from some other player's client.
* @see OnPlayerStreamIn
* @see OnActorStreamOut
* @see OnVehicleStreamOut
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnPlayerStreamOut', func: (playerid: number, forplayerid: number) => void): void;
/**
* Adds a new listener to OnVehicleStreamIn
*
* @name samp.on
* @param {string} [eventName=OnVehicleStreamIn] - Name of the event
* @param {function} func - Event callback
* @summary Called when a vehicle is streamed to a player's client.
* @see OnVehicleStreamOut
* @see OnPlayerStreamIn
* @see OnPlayerStreamOut
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnVehicleStreamIn', func: (vehicleid: number, forplayerid: number) => void): void;
/**
* Adds a new listener to OnVehicleStreamOut
*
* @name samp.on
* @param {string} [eventName=OnVehicleStreamOut] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a vehicle is streamed out for a player's client (it's so far away that they can't see it).
* @see OnVehicleStreamIn
* @see OnPlayerStreamIn
* @see OnPlayerStreamOut
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks This callback can also be called by NPC.
* @returns {void}
*/
static on(eventName: 'OnVehicleStreamOut', func: (vehicleid: number, forplayerid: number) => void): void;
/**
* Adds a new listener to OnActorStreamIn
*
* @name samp.on
* @param {string} [eventName=OnActorStreamIn] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when an actor is streamed in by a player's client.
* @see OnActorStreamOut
* @see OnPlayerStreamIn
* @remarks This function was added in SA-MP 0.3.7 and will not work in earlier versions!
* @remarks This callback can also be called by NPC.
* @remarks It is always called first in filterscripts.
* @returns {void}
*/
static on(eventName: 'OnActorStreamIn', func: (actorid: number, forplayerid: number) => void): void;
/**
* Adds a new listener to OnActorStreamOut
*
* @name samp.on
* @param {string} [eventName=OnActorStreamOut] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when an actor is streamed out by a player's client.
* @see OnActorStreamIn
* @see OnPlayerStreamOut
* @remarks This function was added in SA-MP 0.3.7 and will not work in earlier versions!
* @remarks This callback can also be called by NPC.
* @remarks It is always called first in filterscripts.
* @returns {void}
*/
static on(eventName: 'OnActorStreamOut', func: (actorid: number, forplayerid: number) => void): void;
/**
* Adds a new listener to OnDialogResponse
*
* @name samp.on
* @param {string} [eventName=OnDialogResponse] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player responds to a dialog shown using ShowPlayerDialog by either clicking a button, pressing ENTER/ESC or double-clicking a list item (if using a list style dialog).
* @see ShowPlayerDialog
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks A player's dialog doesn't hide when the gamemode restarts, causing the server to print "Warning: PlayerDialogResponse PlayerId: 0 dialog ID doesn't match last sent dialog ID" if a player responded to this dialog after restart.
* @remarks Parameters can contain different values, based on dialog's style.
* @returns {void}
*/
static on(eventName: 'OnDialogResponse', func: (playerid: number, dialogid: number, response: number, listitem: number, inputtext: string) => void): void;
/**
* Adds a new listener to OnPlayerTakeDamage
*
* @name samp.on
* @param {string} [eventName=OnPlayerTakeDamage] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player takes damage.
* @see OnPlayerGiveDamage
* @see OnPlayerWeaponShot
* @remarks This callback was added in SA-MP 0.3d and will not work in earlier versions!
* @remarks GetPlayerHealth and GetPlayerArmour will return the old amounts of the player before this callback.
* @remarks
The weaponid will return 37 (flame thrower) from any fire sources (e.g. molotov, 18).
The weaponid will return 51 from any weapon that creates an explosion (e.g. RPG, grenade)
playerid is the only one who can call the callback.
The amount is always the maximum damage the weaponid can do, even when the health left is less than that maximum damage. So when a player has 100.0 health and gets shot with a Desert Eagle which has a damage value of 46.2, it takes 3 shots to kill that player. All 3 shots will show an amount of 46.2, even though when the last shot hits, the player only has 7.6 health left.
* @returns {void}
*/
static on(eventName: 'OnPlayerTakeDamage', func: (playerid: number, issuerid: number, amount: number, weaponid: number, bodypart: number) => void): void;
/**
* Adds a new listener to OnPlayerGiveDamage
*
* @name samp.on
* @param {string} [eventName=OnPlayerGiveDamage] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player gives damage to another player.
* @see OnPlayerTakeDamage
* @remarks This callback was added in SA-MP 0.3d and will not work in earlier versions!
* @remarks
Keep in mind this function can be inaccurate in some cases.
If you want to prevent certain players from damaging eachother, use SetPlayerTeam.
The weaponid will return 37 (flame thrower) from any fire sources (e.g. molotov, 18)
The weaponid will return 51 from any weapon that creates an explosion (e.g. RPG, grenade)
playerid is the only one who can call the callback.
The amount is always the maximum damage the weaponid can do, even when the health left is less than that maximum damage. So when a player has 100.0 health and gets shot with a Desert Eagle which has a damage value of 46.2, it takes 3 shots to kill that player. All 3 shots will show an amount of 46.2, even though when the last shot hits, the player only has 7.6 health left.
* @returns {void}
*/
static on(eventName: 'OnPlayerGiveDamage', func: (playerid: number, damagedid: number, amount: number, weaponid: number, bodypart: number) => void): void;
/**
* Adds a new listener to OnPlayerGiveDamageActor
*
* @name samp.on
* @param {string} [eventName=OnPlayerGiveDamageActor] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player gives damage to an actor.
* @see CreateActor
* @see SetActorInvulnerable
* @see SetActorHealth
* @see GetActorHealth
* @see IsActorInvulnerable
* @see IsValidActor
* @see OnActorStreamOut
* @see OnPlayerStreamIn
* @remarks This callback was added in SA-MP 0.3.7 and will not work in earlier versions!
* @remarks This function does not get called if the actor is set invulnerable (WHICH IS BY DEFAULT). See SetActorInvulnerable.
* @returns {void}
*/
static on(eventName: 'OnPlayerGiveDamageActor', func: (playerid: number, damaged_actorid: number, amount: number, weaponid: number, bodypart: number) => void): void;
/**
* Adds a new listener to OnPlayerClickMap
*
* @name samp.on
* @param {string} [eventName=OnPlayerClickMap] - Name of the event
* @param {function} func - Event callback
* @summary OnPlayerClickMap is called when a player places a target/waypoint on the pause menu map (by right-clicking).
* @see SetPlayerPos
* @see SetPlayerPosFindZ
* @see GetPlayerPos
* @remarks This callback was added in SA-MP 0.3d and will not work in earlier versions!
* @remarks The Z value returned will be 0 (invalid) if it is far away from the player; use the MapAndreas plugin to get a more accurate Z coordinate.
* @returns {void}
*/
static on(eventName: 'OnPlayerClickMap', func: (playerid: number, fX: number, fY: number, fZ: number) => void): void;
/**
* Adds a new listener to OnPlayerClickTextDraw
*
* @name samp.on
* @param {string} [eventName=OnPlayerClickTextDraw] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player clicks on a textdraw or cancels the select mode with the Escape key.
* @see OnPlayerClickPlayerTextDraw
* @see OnPlayerClickPlayer
* @remarks This callback was added in SA-MP 0.3e and will not work in earlier versions!
* @remarks The clickable area is defined by TextDrawTextSize. The x and y parameters passed to that function must not be zero or negative.
* @remarks Do not use CancelSelectTextDraw unconditionally within this callback. This results in an infinite loop.
* @returns {void}
*/
static on(eventName: 'OnPlayerClickTextDraw', func: (playerid: number, clickedid: number) => void): void;
/**
* Adds a new listener to OnPlayerClickPlayerTextDraw
*
* @name samp.on
* @param {string} [eventName=OnPlayerClickPlayerTextDraw] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player clicks on a player-textdraw. It is not called when player cancels the select mode (ESC) - however, OnPlayerClickTextDraw is.
* @see PlayerTextDrawSetSelectable
* @see OnPlayerClickTextDraw
* @see OnPlayerClickPlayer
* @remarks This callback was added in SA-MP 0.3e and will not work in earlier versions!
* @remarks When a player presses ESC to cancel selecting a textdraw, OnPlayerClickTextDraw is called with a textdraw ID of INVALID_TEXT_DRAW. OnPlayerClickPlayerTextDraw won't be called also.
* @returns {void}
*/
static on(eventName: 'OnPlayerClickPlayerTextDraw', func: (playerid: number, playertextid: number) => void): void;
/**
* Adds a new listener to OnIncomingConnection
*
* @name samp.on
* @param {string} [eventName=OnIncomingConnection] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when an IP address attempts a connection to the server. To block incoming connections, use BlockIpAddress.
* @see OnPlayerConnect
* @see OnPlayerDisconnect
* @see OnPlayerFinishedDownloading
* @see BlockIpAddress
* @see UnBlockIpAddress
* @remarks This callback was added in SA-MP 0.3z R2-2 and will not work in earlier versions!
* @returns {void}
*/
static on(eventName: 'OnIncomingConnection', func: (playerid: number, ip_address: string, port: number) => void): void;
/**
* Adds a new listener to OnTrailerUpdate
*
* @name samp.on
* @param {string} [eventName=OnTrailerUpdate] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player sent a trailer update.
* @see OnUnoccupiedVehicleUpdate
* @see GetVehicleTrailer
* @see IsTrailerAttachedToVehicle
* @see AttachTrailerToVehicle
* @see DetachTrailerFromVehicle
* @remarks This callback was added in SA-MP 0.3z R4 and will not work in earlier versions!
* @remarks This callback is called very frequently per second per trailer. You should refrain from implementing intensive calculations or intensive file writing/reading operations in this callback.
* @returns {void}
*/
static on(eventName: 'OnTrailerUpdate', func: (playerid: number, vehicleid: number) => void): void;
/**
* Adds a new listener to OnVehicleSirenStateChange
*
* @name samp.on
* @param {string} [eventName=OnVehicleSirenStateChange] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a vehicle's siren is toggled.
* @see GetVehicleParamsSirenState
* @remarks This callback was added in SA-MP 0.3.7 and will not work in earlier versions!
* @remarks This callback can also be called by NPC.
* @remarks This callback is only called when a vehicle's siren is toggled on or off, NOT when the alternate siren is in use (holding horn).
* @returns {void}
*/
static on(eventName: 'OnVehicleSirenStateChange', func: (playerid: number, vehicleid: number, newstate: number) => void): void;
/**
* Adds a new listener to OnPlayerFinishedDownloading
*
* @name samp.on
* @param {string} [eventName=OnPlayerFinishedDownloading] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player finishes downloading custom models. For more information on how to add custom models to your server, see the release thread and this tutorial.
* @see OnPlayerConnect
* @see OnPlayerDisconnect
* @see OnIncomingConnection
* @remarks This callback was added in SA-MP 0.3DL and will not work in earlier versions!
* @remarks This callback is called every time a player changes virtual worlds, even if there are no custom models present in that world.
* @returns {void}
*/
static on(eventName: 'OnPlayerFinishedDownloading', func: (playerid: number, virtualworld: number) => void): void;
/**
* Adds a new listener to OnPlayerClickPlayer
*
* @name samp.on
* @param {string} [eventName=OnPlayerClickPlayer] - Name of the event
* @param {function} func - Event callback
* @summary Called when a player double-clicks on a player on the scoreboard.
* @see OnPlayerClickTextDraw
* @remarks This callback was added in SA-MP 0.3a and will not work in earlier versions!
* @remarks There is currently only one (0 - CLICK_SOURCE_SCOREBOARD). The existence of this argument suggests that more sources may be supported in the future.
* @returns {void}
*/
static on(eventName: 'OnPlayerClickPlayer', func: (playerid: number, clickedplayerid: number, source: number) => void): void;
/**
* Adds a new listener to OnPlayerSelectObject
*
* @name samp.on
* @param {string} [eventName=OnPlayerSelectObject] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player finishes editing an object (EditObject/EditPlayerObject).
* @summary This callback is called when a player ends attached object edition mode.
* @summary This callback is called when a player selects an object after SelectObject has been used.
* @see EditObject
* @see CreateObject
* @see DestroyObject
* @see MoveObject
* @see EditAttachedObject
* @see SetPlayerAttachedObject
* @see SelectObject
* @remarks This callback was added in SA-MP 0.3e and will not work in earlier versions!
* @remarks When using EDIT_RESPONSE_UPDATE be aware that this callback will not be called when releasing an edit in progress resulting in the last update of EDIT_RESPONSE_UPDATE being out of sync of the objects current position.
* @remarks This callback was added in SA-MP 0.3e and will not work in earlier versions!
* @remarks Editions should be discarded if response was 0 (cancelled). This must be done by storing the offsets etc. in an array BEFORE using EditAttachedObject.
* @remarks This function was added in SA-MP 0.3e and will not work in earlier versions!
* @returns {void}
*/
static on(eventName: 'OnPlayerSelectObject', func: (playerid: number, type: number, objectid: number, modelid: number, fX: number, fY: number, fZ: number) => void): void;
/**
* Adds a new listener to OnPlayerWeaponShot
*
* @name samp.on
* @param {string} [eventName=OnPlayerWeaponShot] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a player fires a shot from a weapon. Only bullet weapons are supported. Only passenger drive-by is supported (not driver drive-by, and not sea sparrow / hunter shots).
* @see OnPlayerGiveDamage
* @see GetPlayerLastShotVectors
* @remarks This callback was added in SA-MP 0.3z and will not work in earlier versions!
* @remarks
BULLET_HIT_TYPE_NONE(0)
BULLET_HIT_TYPE_PLAYER(1)
BULLET_HIT_TYPE_VEHICLE(2)
BULLET_HIT_TYPE_OBJECT(3)
BULLET_HIT_TYPE_PLAYER_OBJECT(4)
* @remarks BULLET_HIT_TYPE_PLAYER is also called for NPCs. Actors are ignored by this callback and detects as BULLET_HIT_TYPE_NONE.
* @remarks This callback is only called when lag compensation is enabled.
* @remarks
If hittype is:
- BULLET_HIT_TYPE_NONE: the fX, fY and fZ parameters are normal coordinates, will give 0.0 for coordinates if nothing was hit (e.g. far object that the bullet can't reach);
- Others: the fX, fY and fZ are offsets relative to the hitid.
* @remarks
Isn't called if you fired in vehicle as driver or if you are looking behind with the aim enabled (shooting in air).
It is called as BULLET_HIT_TYPE_VEHICLE with the correct hitid (the hit player's vehicleid) if you are shooting a player which is in a vehicle. It won't be called as BULLET_HIT_TYPE_PLAYER at all.
Partially fixed in SA-MP 0.3.7: If fake weapon data is sent by a malicious user, other player clients may freeze or crash. To combat this, check if the reported weaponid can actually fire bullets.
* @remarks
* @remarks GetPlayerLastShotVectors can be used in this callback for more detailed bullet vector information.
* @returns {void}
*/
static on(eventName: 'OnPlayerWeaponShot', func: (playerid: number, weaponid: number, hittype: number, hitid: number, fX: number, fY: number, fZ: number) => void): void;
/**
* Adds a new listener to OnClientCheckResponse
*
* @name samp.on
* @param {string} [eventName=OnClientCheckResponse] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a SendClientCheck request comletes
* @see SendClientCheck
* @returns {void}
*/
static on(eventName: 'OnClientCheckResponse', func: (playerid: number, actionid: number, memaddr: number, retndata: number) => void): void;
/**
* Adds a new listener to OnScriptCash
*
* @name samp.on
* @param {string} [eventName=OnScriptCash] - Name of the event
* @param {function} func - Event callback
* @returns {void}
*/
static on(eventName: 'OnScriptCash', func: (playerid: number, amount: number, source: number) => void): void;
/**
* Adds a new listener to OnGameModeInit
*
* @name samp.addListener
* @alias samp.on
* @param {string} [eventName=OnGameModeInit] - Name of the event
* @param {function} func - Event callback
* @summary This callback is triggered when the gamemode starts.
* @see OnGameModeExit
* @see OnFilterScriptInit
* @see OnFilterScriptExit
* @remarks This function can also be used in a filterscript to detect if the gamemode changes with RCON commands like changemode or gmx, as changing the gamemode does not reload a filterscript.
* @returns {void}
*/
static addListener(eventName: 'OnGameModeInit', func: () => void): void;
/**
* Adds a new listener to OnGameModeExit
*
* @name samp.addListener
* @alias samp.on
* @param {string} [eventName=OnGameModeExit] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a gamemode ends, either through 'gmx', the server being shut down, or GameModeExit.
* @see OnGameModeInit
* @see OnFilterScriptExit
* @see OnFilterScriptInit
* @see GameModeExit
* @remarks This function can also be used in a filterscript to detect if the gamemode changes with RCON commands like changemode or gmx, as changing the gamemode does not reload a filterscript.
* @remarks When using OnGameModeExit in conjunction with the 'rcon gmx' console command keep in mind there is a potential for client bugs to occur an example of this is excessive RemoveBuildingForPlayer calls during OnGameModeInit which could result in a client crash.
* @remarks This callback will NOT be called if the server crashes or the process is killed by other means, such as using the Linux kill command or pressing the close-button on the Windows console.
* @returns {void}
*/
static addListener(eventName: 'OnGameModeExit', func: () => void): void;
/**
* Adds a new listener to OnFilterScriptInit
*
* @name samp.addListener
* @alias samp.on
* @param {string} [eventName=OnFilterScriptInit] - Name of the event
* @param {function} func - Event callback
* @summary This callback is called when a filterscript is initialized (loaded). It is only called inside the filterscript which is starting.
* @see OnFilterScriptExit
* @see OnGameModeInit
* @see OnGameModeExit
* @returns {void}
*/
static addListener(eventName: 'OnFilterScriptInit', func: () => void): void;
/**
* Adds a new listener to OnFilterScriptExit
*
* @name samp.addListener
* @alias samp.on
* @param {string} [eventName=OnFilterScriptExit] - Name of the event
* @param {functi