Scripting Callbacks

From SA-MP

Jump to: navigation, search

Contents

OnGameModeInit

No parameters.

OnGameModeExit

No parameters.


OnFilterScriptInit

No parameters.


OnFilterScriptExit

No parameters.


OnPlayerConnect

(playerid)
playeridID of player connecting.


Tutorial to make Join & Leave messages: http://wiki.sa-mp.com/index.php/Creating_Join_and_Leave_Messages

OnPlayerDisconnect

(playerid, reason)
playeridID of player disconnecting.


Tutorial to make Join & Leave messages: http://wiki.sa-mp.com/index.php/Creating_Join_and_Leave_Messages

OnPlayerSpawn

(playerid)
playeridID of player spawning.


OnPlayerDeath

(playerid, killerid, reason)
playeridID of player who died.
killerID of person who killed playerid. INVALID_PLAYER_ID if the player committed suicide.
reasonUnique ID specifying how the player died. Listed on WeaponID.


OnVehicleSpawn

(vehicleid)
vehicleidID of vehicle spawning


OnVehicleDeath

(vehicleid, killerid)
vehicleidID of vehicle which was destroyed
killeridID of the killer


OnPlayerText

(playerid, text[])
playeridID of player talking
text[]Text which player sent.
Return 0 to stop processing (i.e. mute the player)


OnPlayerCommandText

(playerid, cmdtext[])
playeridID of player who sent command.
cmdtext[]Command text.
Return 1 if the command has successfully processed. Returning 0 will result in a "SERVER: Unknown Command."-Message.

Notes: This function is called when a player types a message beginning with a forward slash (/).

OnPlayerInfoChange

(playerid)
playeridID of player whose info changed


OnPlayerRequestClass

(playerid, classid)
playeridID of player whose requested the class.
classidID of class which player requested.


OnPlayerEnterVehicle

(playerid, vehicleid, ispassenger)
playeridID of player who entered the vehicle.
vehicleidVehicle ID which player entered.
ispassengerBoolean or numeric variable indicating if the user is a passenger or driver. 1/True indicates passenger, and 0/False indicates driver.


OnPlayerExitVehicle

(playerid, vehicleid)
playeridID of player who exited the vehicle.
vehicleidVehicle ID which player exited.


OnPlayerStateChange

(playerid, newstate, oldstate)
playeridID of player whose state changed.
newstateThe new state ID.
oldstateThe old state ID.


States - PLAYER_STATE_DRIVER, PLAYER_STATE_ONFOOT,...

Notes: States are detemined by what the player is currently doing, for example: Loading, walking, driving, etc.


OnPlayerEnterCheckpoint

(playerid)
playeridID of player who entered a checkpoint.


OnPlayerLeaveCheckpoint

(playerid)
playeridID of player who left a checkpoint.


OnPlayerEnterRaceCheckpoint

(playerid)
playeridID of player who entered a race checkpoint.


OnPlayerLeaveRaceCheckpoint

(playerid)
playeridID of player who left a race checkpoint.


OnRconCommand

(cmd[])
cmdThe command sent via rcon.


OnPlayerPrivmsg

(playerid, recieverid, text[])
playeridID of player who sent the private message.
recieveridID of player the private message was sent to.


textThe message that was inside the private message.


OnPlayerRequestSpawn

(playerid)
playeridThe ID of the player requesting to spawn.


OnObjectMoved

(objectid)
objectidID of an object which has reached its target position given by MoveObject.


OnPlayerObjectMoved

(playerid, objectid)
playeridThe playerid the object is associated with
objectidCalled when an object has reached its target position given by MoveObject.


OnPlayerPickUpPickup

(playerid, pickupid)
playeridID of the player who picked up something.
pickupidID of the pickup.



OnVehiclePaintjob

(vehicleid, paintjobid)
vehicleidID of the vehicle which has been painted.
paintjobidID of the paintjob the user has applied. (0-5)


OnVehicleRespray

(vehicleid, color1, color2)
vehicleidID of the vehicle which has been resprayed.
color1Primary Color
color2Secondary Color

See Color Chart.

OnVehicleMod

(vehicleid, componentid)
vehicleidID of the vehicle which has been painted.
componentidID of the component which has been applied.


OnPlayerSelectedMenuRow

(playerid, row)
playeridThe player who selected something.
rowThe row in the menu the player selected. First row is 0.

Notes: Never forget to check which menu is currently displayed using GetPlayerMenu.

OnPlayerExitedMenu

(playerid)
playeridID of the player who cancelled the menu without selecting anything.


OnPlayerInteriorChange

(playerid, newinteriorid, oldinteriorid)
playeridID of the player who changed Interior.
newinterioridThe ID of the interior the player has changed to.
oldinterioridThe ID of the interior the player comes from.


OnPlayerKeyStateChange

(playerid, newkeys, oldkeys)
playeridID of the player who pressed a key.
newkeysThe sum of the IDs of keys currently pressed - see here.
oldkeysThe sum of the IDs of keys last pressed - see here.
Personal tools
In other languages