- Documentation
- Browser
Category
Browser
All Lua functions and events in the Browser category, on the server and the client.
Client functions 45
canChecks whether the browser history has a previous page.Browser Navigate Back canChecks whether the browser history has a next page.Browser Navigate Forward createCreates a browser: an HTML page rendered into a texture. Draw it withBrowser dxDrawImageand load the address only in theonClientBrowserCreatedevent.evaluateRuns JavaScript on a local page and returns its result to Lua. If the code returns a Promise, the function waits for it.Browser Javascript executeRuns JavaScript on the page. Works on local browsers only.Browser Javascript focusGives the keyboard to a browser. Typing goes to the page when one of its text fields is active and the cursor is shown.Browser nilremoves focus from all browsers.getReturns how many times per second the page is redrawn.Browser Frame Rate getReturns the opacity of a page pixel. Useful for letting clicks on transparent parts of a HUD go through to the game.Browser Pixel Alpha getReturns a browser property.Browser Property "mobile"(phone view) is supported.getReturns every browser created by scripts.Browsers getReturns the browser settings chosen by the player (ESC, Settings, Browser).Browser Settings getReturns the browser size in pixels.Browser Size getFetches the HTML of the current page and passes it to a function.Browser Source getReturns the page title (fromBrowser Title <title>).getReturns the page's current address.Browser URL getReturns one browser's volume or, with no argument, the volume of all browsers.Browser Volume getReturns the page zoom (Browser Zoom 1is 100%).injectTypes text into the page's active field, character by character (Browser Character keypress/inputevents), including accented letters and other UTF-8 characters.injectSends a key press or release to the page (e.g. Enter, Backspace, arrows), as if the player pressed it on the keyboard. The page gets normalBrowser Key keydown/keyupevents. UseinjectBrowserCharacterto type text.injectPresses a mouse button on the page at the position of the lastBrowser Mouse Down injectBrowserMouseMove. Two presses at the same spot within 0.5 s reach the page as a double click, three as a triple click (paragraph selection), like in Windows.injectMoves the mouse cursor on the page.Browser Mouse Move injectReleases a mouse button on the page.Browser Mouse Up injectScrolls the page with the mouse wheel. Negative values scroll down and right.Browser Mouse Wheel isChecks whether a domain (or address) is unavailable to web browsers: because of the blacklist, missing player consent or disabled remote pages.Browser Domain Blocked isChecks whether the browser has keyboard focus.Browser Focused isChecks whether pages are drawn by the graphics card.Browser GPUEnabled isChecks whether the page is still loading.Browser Loading isChecks whether the browser is local (resource files) rather than remote (internet).Browser Local isChecks whether page rendering is paused.Browser Rendering Paused isChecks whether the game can create browsers.Browser Supported loadLoads an address in the browser. A local browser opens resource files, a remote one opens pages from allowed domains.Browser URL navigateGoes to the previous page in the history.Browser Back navigateGoes to the next page in the history.Browser Forward reloadReloads the current page.Browser Page requestAsks the player for permission to open pages from the given domains. A domain must be on the server's list (Browser Domains browser_domainsinserver-config.json); others are rejected without asking. Consent is remembered.resizeChanges the browser size.Browser setAnswers page requests to a path from Lua, e.g.Browser Ajax Handler fetch("http://trilogy/local/api"). The function returns the response body and optionally a MIME type. With no function the handler is removed.setSets how many times per second the page redraws (1-240, default 60). Fewer frames mean less CPU work, for example for a HUD that rarely changes; more frames give smoother animations on monitors above 60 Hz.Browser Frame Rate setExposes a Lua function to a local page. In JavaScript you call it withBrowser Function await trilogy.call("name", ...)and get its result.setSets a browser property.Browser Property "mobile"is supported:"1"turns on the phone view.setPauses or resumes page rendering. A paused page does not load the CPU while it is hidden.Browser Rendering Paused setSets the volume of one browser or, when you pass just a number, of all browsers.Browser Volume setSets the page zoom (0.25-5,Browser Zoom 1is 100%).toggleOpens or closes the page's developer tools. RequiresBrowser Dev Tools setDevelopmentMode(true, true)and"browser_devtools": trueinserver-config.json.triggerSends an event from Lua to a local page. In JavaScript you receive it withBrowser Event trilogy.on("name", fn), without building code in a string.
Client events 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.