- Documentation
- Client events
Client events
Events triggered in the player's game. Handle them with addEventHandler in a client script.
New functions and events! 1
Browser 27
onThe page wrote something to the JavaScript console (Client Browser Console Message console.log). Useful for finding page bugs.onThe page process crashed. The browser restarts it by itself.Client Browser Crashed onThe browser is ready (the page process started) and you can load an address in it.Client Browser Created onThe page changed the cursor shape (e.g. a hand over a link).Client Browser Cursor Change onThe page in the browser has loaded. A good place forClient Browser Document Ready executeBrowserJavascript.onA text field on the page got or lost focus. Useful for turning on the keyboard for the browser.Client Browser Input Focus Changed onA page failed to load.Client Browser Loading Failed onThe browser starts loading a page.Client Browser Loading Start onThe browser is navigating to a new address (e.g. after a link click).Client Browser Navigate isBlockedtells whether the address is blocked.onA page tries to open a new window (a popup). New windows are not opened; you can load the address in the same browser instead.Client Browser Popup onThe page wanted to load something from a blocked address. Reason:Client Browser Resource Blocked 0a domain without the player's consent,1a blacklist or a local network,2a forbidden protocol or address.onThe page wants to show a tooltip (theClient Browser Tooltip titleattribute).onThe player allowed new domains for the browser (afterClient Browser Whitelist Change requestBrowserDomains).onThe cursor moved (only while it is visible; at most once per frame).Client Cursor Move onAn element entered a marker, in this game. Works for markers from the server and ones created on the client. Players, vehicles, peds, objects, pickups and other markers are checked every 100 ms. AClient Marker Hit checkpointmarker is a circle with no height limit, the other types are a sphere with a radius equal to the marker size.onAn element left a marker, in this game. It also happens when the element disappears or is moved out of the marker.Client Marker Leave onThe game window was minimized or lost the foreground (e.g. Alt+Tab).Client Minimize onAn NPC took damage in your game (e.g. from your weapon) before the hit goes to the server.Client Ped Damage cancelEvent()blocks the hit: it is not sent to the server and the NPC's health returns to the server value.onEvery frame, right after all peds' animations and bones are updated and beforeClient Peds Processed onClientPreRender. HeregetPedBonePositionandgetPedBoneMatrixreturn this frame's positions, so manually attached objects and effects do not lag a frame behind.onYour own ped took damage: a hit from another player or game damage (fall, fire, explosion, car, drowning). Informational - the server decides about damage, soClient Player Damage cancelEvent()blocks nothing here; to block damage usecancelEvent()in the server'sonPlayerDamageandsetPedDamageProof.onA player entered a marker, in this game. The same asClient Player Marker Hit onClientMarkerHit, but the source is the player, so you can attach the handler tolocalPlayer.onA player left a marker, in this game. The source is the player.Client Player Marker Leave onA player started talking through voice chat (for the local player: their microphone started transmitting). You can block another player's utterance: then this player does not hear it until they stop talking.Client Player Voice Start onA player stopped talking through voice chat.Client Player Voice Stop onThe game window came back to the foreground after being minimized or Alt+Tab.Client Restore onThe vehicle this player drives hit something (a sudden change of speed, at least 2.5 m/s in one frame). Teleports andClient Vehicle Collision setElementVelocityfrom scripts do not count.onThe game recomputed the GPS route to the waypoint (the line on the radar), or the route disappeared.Client Waypoint Route Update getPlayerWaypointRoutegives the route's points.
Chat and console 2
Collision shapes 4
onAn element entered a client-created shape. Attach the handler to that shape or toClient Col Shape Hit root(the event does not pass through parents).onAn element left a client-created shape.Client Col Shape Leave onAn element entered a collision shape (the element-side version, on the client).Client Element Col Shape Hit onAn element left a collision shape (the element-side version, on the client).Client Element Col Shape Leave
Drawing (dx) 3
onArrives every frame beforeClient Pre Render onClientRender, without drawing. It gets the time since the previous frame, so it suits smooth movement (cameras, animations).onTriggered every game frame. This is where you draw everything that should stay on screen: HUD, counters, text.Client Render onThe game resolution or window size changed. Recompute interface positions then.Client Screen Size Change
Elements 5
onNewAn element's data changed - through setElementData on the server or in a client script.Client Element Data Change onAn element moved to another dimension.Client Element Dimension Change onAn element moved to another interior.Client Element Interior Change onAn element appeared near the player (the game loaded it and draws it).Client Element Stream In onAn element moved away and the game stopped drawing it.Client Element Stream Out
Fire 1
Input and controls 3
onThe player typed a character (a letter respecting the keyboard layout and accented characters). For your own text fields drawn withClient Character dx.onThe player clicked the mouse with the cursor visible (outside GUI windows).Client Click onThe player pressed or released a key. The event sees every key, including the ones the game uses.Client Key
Interface (GUI) 16
onThe player confirmed a GUI edit box with Enter.Client GUIAccepted onA GUI control lost focus.Client GUIBlur onThe text in a GUI edit box or memo changed.Client GUIChanged onThe player clicked a GUI control (a button, a field, a list).Client GUIClick onThe player closed a GUI window with the close button.Client GUIClose onThe player picked an item from a GUI combo box.Client GUICombo Box Accepted onThe player double-clicked a GUI control (e.g. a list row).Client GUIDouble Click onA GUI control got focus (e.g. an edit box the player clicks into).Client GUIFocus onThe player pressed a mouse button over a GUI control.Client GUIMouse Down onThe player released a mouse button over a GUI control.Client GUIMouse Up onThe player moved a GUI window.Client GUIMove onA GUI scroll bar was moved.Client GUIScroll onThe player resized a GUI window.Client GUISize onThe player switched a tab in a GUI tab panel.Client GUITab Switched onThe cursor moved over a GUI control. Useful for highlights and tooltips.Client Mouse Enter onThe cursor left a GUI control.Client Mouse Leave
Objects 1
Players 7
onAnother player's animation. The event is registered, but the current client does not send these reports yet, so it does not arrive for now.Client Player Anim onAnother player's game reported a hit: aClient Player Hit datatable with the target element number (target), damage (damage), weapon (w) and body part (bp).onAnother player joined the server.Client Player Join onAnother player left the server.Client Player Quit onA player (local or another) appeared in the world.Client Player Spawn onA player (local or another) died.Client Player Wasted onA player fired a firearm: you or another nearby player whose shots are shown in your game. It arrives once per bullet, with the muzzle point and the hit point. The game collects shots only while some script listens to this event.Client Player Weapon Fire
Resources 4
onA download fromClient File Download Complete downloadFilefinished (a<file download="false">file). It always arrives asynchronously, also when the file was already downloaded.onA resource started in the player's game (client scripts are loaded). Attached toClient Resource Start resourceRootit only arrives for your own resource.onA resource is stopping in the player's game.Client Resource Stop onFile download progress (a resource start orClient Transfer Box Progress Change downloadFile), at most about 10 times per second. Useful for your own download bar.
Sound (client) 1
Vehicles 2
onA vehicle lost health in your game: from a crash, gunfire, an explosion, fire or a health change from a script. It covers every vehicle your game knows, including other players' cars. The game checks vehicle health 10 times per second and only while some script listens to this event; several quick hits in that time arrive as one loss.Client Vehicle Damage onA vehicle exploded (Client Vehicle Explode blowVehicleor an explosion reported by its owner). It arrives at the same moment for everyone, right beforeonClientExplosion.
Weapons 1
World 6
onThe server enabled or disabled the ESC map (Client Map Enabled Change setMapEnabled,setPlayerMapEnabled).onThe connection to the server stalled or came back. When no data arrives for 2.5 s, the game shows "NETWORK TROUBLE" in the middle of the screen, your character stops andClient Player Network Status status=0arrives; when data comes back,status=1arrives.onThe local player's GPS waypoint disappeared: removed on the map, by a script or the player arrived.Client Waypoint Remove onThe local player has a new game GPS waypoint: from the map (Client Waypoint Set "map") or from a script ("script").onThe world was revealed after the loading screen. From now on the player sees the game.Client World Loaded onA world sound from another player. The event is registered, but the current client does not send these reports yet, so it does not arrive for now.Client World Sound