- Documentation
- World
Category
World
All Lua functions and events in the World category, on the server and the client.
Server functions 72
createCreates a water element as an area with three or four corners. A finalWater trueargument means shallow water.getReturns the garage rectangle calculated fromGarage Bounding Box setGarageBounds: west, east, south and north limits.getReturns the garage position given withGarage Position setGarageBounds.getReturns the garage size given withGarage Size setGarageBounds.getReturns the value fromJetpack Weapon Enabled setJetpackWeaponEnabled(falseby default).getReturns the height of the lowest obstacle above a point (whether there is a roof overhead), according to the server's model: only script objects, without map buildings.Roof Position getReturns the position of a water element's corner.Water Vertex Position getReturns the numbers stored under a name withWorld Property setWorldProperty.isReturns whether an ambient sound type is enabled (yes by default).Ambient Sound Enabled isReturns whetherGame World Removed removeGameWorldwas called (and not undone).isReturns whether a glitch was enabled withGlitch Enabled setGlitchEnabled(all off by default).isChecks whether the game clock is stopped withTime Frozen setTimeFrozen.isReturns whether a world sound was not muted withWorld Sound Enabled setWorldSoundEnabled(also checks muting of the whole group).processChecks whether a segment crosses one specific element, treating it as a sphere of its radius (a server-side simplification). Returns the point on the segment closest to the element's centre.Line Against Mesh removeStores hiding the whole San Andreas map (for servers with their own map).Game World resetRestores all ambient sounds (clears settings fromAmbient Sounds setAmbientSoundEnabled).resetRestores the default valueBirds Enabled trueof the birds setting.resetRestores the default blur (36).Blur Level resetRestores the default value (Corona Reflections Enabled false) of light reflections.resetRestores the default grain (0).Grain Level resetRestores the default grain multiplier (1).Grain Multiplier resetClears the settings fromHeat Haze setHeatHaze.resetRestores the default value (Interior Furniture Enabled true) of interior furniture.resetRestores the default camera near clip (0.3).Near Clip Distance resetRestores the default ped drawing distance (60).Peds LODDistance resetClears the sun colour fromSun Color setSunColor.resetRestores the default sun size (1).Sun Size resetRestarts a stopped game clock; the same asTime Frozen setTimeFrozen(false).resetRestores the default vehicle drawing distance (500).Vehicles LODDistance resetAn alias ofVolumetric Shadows resetVolumetricShadowsEnabled.resetRestores the default value (Volumetric Shadows Enabled false) of volumetric shadows.resetClears the water colour fromWater Color setWaterColor.resetRestores the default value (Water Drawn Last false) ofsetWaterDrawnLast.resetClears the water level set withWater Level setWaterLevel.resetClears the wind set withWind Velocity setWindVelocity.resetClears most world settings stored by scripts at once: named properties, colour filter, fog, sun and moon size, rain, grain, blur, drawing distances, waves, birds, reflections, shadows, furniture, muted sounds, game speed and minute length. Unless you passWorld Properties false, it also clears special properties, garages, glitches and the jetpack weapon setting.resetClears one named property fromWorld Property setWorldProperty.resetClears all muting fromWorld Sounds setWorldSoundEnabled.restoreUndoesGame World removeGameWorld.setAllows or forbids aim assist for every player.Aim Assist Enabled falseforces free aim (the crosshair does not snap to targets) and the game menu option is locked. Useful on PvP servers where controller and mouse players should be on equal terms.setStores turning ambient sounds on or off:Ambient Sound Enabled "gunfire"(distant gunshots in dangerous areas) or"general"(other background noises).setStores whether birds should fly over the map (yes by default).Birds Enabled setStores the motion blur strength at high speed (0-255, 36 by default in the game).Blur Level setStores whether lights (street lamps, headlights) should reflect on wet roads (off by default).Corona Reflections Enabled setProvides a garage's position and size so thatGarage Bounds getGaragePosition,getGarageSizeandgetGarageBoundingBoxwork (the server does not know the game's garage data).setStores whether a game garage (Pay'n'Spray, mission garages, numbers 0-49) should be open. The state is sent to players and read withGarage Open isGarageOpenon both sides.setTurns a known game glitch allowed on many servers on or off. Available names:Glitch Enabled quickreload,fastfire(faster firing by cancelling the animation),fastmove(fast crouched movement),crouchbug(shoot-crouch),closedamage(close-range damage),hitanim(hit animation),fastsprint(fast sprint by tapping),baddrivebyhitbox(wrong hitbox in drive-bys),quickstand,kickoutofvehicle_onmodelreplace.setAdds film-like grain to the game image for all players (0 = none, 255 = strongest). The strength is multiplied byGrain Level setGrainMultiplier.setA multiplier for the grain strength fromGrain Multiplier setGrainLevel(0-10, 1 by default). Grain does not exceed its maximum strength.setChanges the gravity strength in the game world for every player. The default is 0.008; a smaller value gives higher jumps and longer car flights (e.g. 0.004 = half of Earth's). The game accepts values above 0 and below 1.Gravity setStores heat haze settings (the shimmering hot air over desert asphalt).Heat Haze setStores whether interiors (houses, shops) should have furniture (yes by default). Useful when you place your own furnishings inside.Interior Furniture Enabled setStores a general permission to fire weapons while flying a jetpack (off by default). It takes one value for all weapons.Jetpack Weapon Enabled setStores the camera near clip distance: things closer to the camera than this are not drawn (0.1-20 m, 0.3 by default).Near Clip Distance setStores the distance beyond which peds stop being drawn (0-500 m, 60 by default).Peds LODDistance setStores the sun colour: core and glow (corona), each RGB 0-255. Without the last three numbers the glow gets the core colour.Sun Color setStores the sun disc size (0-100, 1 by default).Sun Size setStops or restarts the game clock for every player. A stopped clock keeps a constant time of day (e.g. eternal noon on a racing server).Time Frozen setTimecan still change the hour.setStores whether the traffic lights should be locked in their current state (no automatic changes).Traffic Lights Locked setStores the state of the traffic lights at junctions (0-9).Traffic Light State setStores the distance beyond which vehicles stop being drawn (0-500 m, 500 by default).Vehicles LODDistance setStores whether peds and vehicles should have volumetric shadows (off by default).Volumetric Shadows Enabled setStores the water colour (RGB 0-255) and its opacity (200 by default).Water Color setStores whether water should be drawn last (this affects how transparent objects under water look).Water Drawn Last setStores the water level: with just a number for the whole world, with a water element for that element.Water Level setMoves a corner of a water element fromWater Vertex Position createWater.setStores the height of waves on water (0-100, 0 by default).Wave Height setStores the wind direction and strength. The value is sent to players and read withWind Velocity getWindVelocityon the client, e.g. for your own effects.setStores a named world property of up to three numbers, e.g. a colour or an effect intensity from the list (World Property AmbientColor,LightsOnGround,SpriteBrightness, etc.). The name is case-insensitive.setStores muting of world sounds by groups and indexes (e.g. group 0 = people, 5 = birds). Index -1 means the whole group; a two-argument call (World Sound Enabled group, enabled) also affects the whole group.setTurns a special world property on or off:World Special Property Enabled hovercars,aircars,extrabunny,extrajump,randomfoliage,snipermoon,extraairresistance,underworldwarp,vehiclesunglare,coronaztest,watercreatures,burnflippedcars,fireballdestruct,roadsignstext,extendedwatercannons,tunnelweatherblend,ignorefirestate,flyingcomponents,vehicleburnexplosions,vehicle_engine_autostart.vehicle_engine_autostartreally works: turned off, a car engine does not start by itself when a driver gets in and must be turned on withsetVehicleEngineState.testChecks whether a sphere at the given point overlaps any element (vehicle, ped, object) according to the server's simplified model (elements as spheres, no map buildings). Useful e.g. to check that a spot is free before creating a car.Sphere Against World
Client functions 10
getReturns the value of an image effect set withPost Effect setPostEffector by the server (the colour filter as"tint", grain as"grain").getReturns the list of image effect names accepted byPost Effect Names setPostEffect.getConverts a point on the screen into a point in the 3D world at the given distance from the camera. Useful e.g. for placing objects with the mouse cursor.World From Screen Position getNewFinds a San Andreas map model without collision that the segment passes through: graffiti, car wash brushes, meshes with transparency.World Model On Line processLineOfSightdoes not see such models because it passes through them. When the segment crosses several of them, the smallest one wins (e.g. graffiti on a building wall). Models with collision are skipped, sinceprocessLineOfSightfinds those. The result fitsremoveWorldModeldirectly.getReturns a copy of all world settings the server sent to this player (weather, wind, settings stored with world functions, etc.) as a key → value table. Useful for diagnostics and your own effects that depend on server settings.World Settings isChecks whether the Trilogy Hub loading screen has gone and the player stands in the game world. Useful to show a welcome window or a camera shot only when the player can actually see it.World Loaded resetEnds the local minute length set withMinute Duration setMinuteDurationin a client script: the clock goes back to the server's time and pace.resetRemoves one image effect set withPost Effect setPostEffect. If the server also sets this effect (colour filter, grain), the server value comes back.resetRemoves all image effects set withPost Effects setPostEffectin this game.setSets an image effect for this player, computed by the game engine over the whole world image (without script texts and windows). The effect stays untilPost Effect resetPostEffector leaving the server. Available effects:"saturation"(0-2, 1 = unchanged, 0 = black and white),"contrast"(0-2),"gamma"(0.1-4),"gain"(colour brightness gain, 0-4),"offset"(colour offset, -1-1, 0 = unchanged),"tint"(image tint: r, g, b 0-255),"temperature"(white temperature in kelvins, 1500-15000, 6500 = neutral),"grain"(grain 0-1),"grainJitter"(grain jitter 0-1),"vignette"(darkened edges 0-1),"bloom"(glow of bright areas 0-8),"fringe"(colour fringing at the edges 0-5),"exposure"(-8-8, 0 = unchanged, +1 = twice as bright).
Shared functions 48
areReturns the value stored withTraffic Lights Locked setTrafficLightsLocked(falseby default).getReturns the value fromBirds Enabled setBirdsEnabled(trueby default).getReturns the value fromBlur Level setBlurLevel(36 by default).getReturns the map region name at a point (City Name "Los Santos","San Fierro","Las Venturas","Red County","Flint County","Whetstone","Bone County","Tierra Robada"); the same asgetZoneName(x, y, z, true).getReturns the colour filter set withColor Filter setColorFilter. On the client it returns the local filter, or the server filter without it.getReturns the value fromCorona Reflections Enabled setCoronaReflectionsEnabled(falseby default).getReturns the value fromGrain Level setGrainLevel(0 by default).getReturns the value fromGrain Multiplier setGrainMultiplier(1 by default).getReturns the world gravity strength (0.008 by default).Gravity getReturns the ground height under a point. On the client it asks the game (real terrain and buildings). The server does not know the map terrain, so there it only considers script objects and the water level; it often returnsGround Position false.getReturns the heat haze settings stored withHeat Haze setHeatHaze.getReturns the value fromInterior Furniture Enabled setInteriorFurnitureEnabled(trueby default).getReturns the value fromNear Clip Distance setNearClipDistance(0.3 by default).getReturns the value fromPeds LODDistance setPedsLODDistance(60 by default).getReturns the sky colours stored withSky Gradient setSkyGradient.getReturns the sun colour stored withSun Color setSunColor.getReturns the sun size stored withSun Size setSunSize(1 by default).getReturns the current game hour and minute on the server (the same that players see).Time getReturns the traffic light state stored withTraffic Light State setTrafficLightState(0 by default).getReturns the value fromVehicles LODDistance setVehiclesLODDistance(500 by default).getReturns the water colour stored withWater Color setWaterColor.getReturns the water level stored withWater Level setWaterLevel; when not set, for a given point it returns 0 (sea level).getReturns the wave height stored withWave Height setWaveHeight.getReturns the current weather and the weather a smooth change fromWeather setWeatherBlendedis heading towards (ornil).getReturns the wind stored withWind Velocity setWindVelocity. On the serverfalsewhen not set; on the client 0, 0, 0 then.getReturns the box enclosing a whole zone (all its parts) with the given name: minimum and maximum coordinates. When there is no such district it looks for a region.Zone Bounds getReturns the centre of the zone box fromZone Center getZoneBounds. Useful e.g. to place a "Go to Idlewood" marker. The centre need not be on the ground, or inside the zone itself if its shape is irregular.getReturns the number of zone (district) rectangles and region rectangles in the map data.Zone Count getReturns the name of the district (map zone) at a point, e.g.Zone Name "Grove Street","Idlewood","Downtown Los Santos"- what the game shows on screen when you enter a new area. WithcitiesOnly = trueit returns the region name ("Los Santos","San Fierro","Las Venturas","Red County"…). Works on both sides on the data of the game's 356 zones, without asking a client.getReturns a sorted list of all district names (without duplicates) or, withZone Names citiesOnly = true, region names. Good for selection lists in panels.isChecks whether aim assist is allowed (Aim Assist Enabled setAimAssistEnabledon the server). On the client it tells whether the server allows it.isReturns whether a garage was marked as open withGarage Open setGarageOpen. Works on both sides.isChecks whether a point lies in a zone or region with the given name (case-insensitive). A zone can consist of many rectangles; each of them counts.Inside Zone isChecks whether nothing blocks the segment between two points. On the client it asks the game (terrain, buildings, objects, vehicles, peds, collisions from .col files). On the server it uses a simplified model: script elements as spheres, without map terrain and buildings, so it is only an approximation.Line Of Sight Clear isReturns the value fromVolumetric Shadows Enabled setVolumetricShadowsEnabled(falseby default).isReturns the value fromWater Drawn Last setWaterDrawnLast(falseby default).isReturns whether a special world property is enabled: the value fromWorld Special Property Enabled setWorldSpecialPropertyEnabledor the default (e.g.randomfoliageandvehicle_engine_autostarton by default,hovercarsoff).processFinds the first obstacle on the segment between two points and returns the hit details. On the client it asks the game (terrain, buildings, objects, cars, peds, collisions from .col files) and returns plenty of data: hit point, element, surface normal, material, lighting, body or vehicle part, and on request the map object model with its position. Each call waits about one game frame; while the world is still loading (loading screen) it returnsLine Of Sight falseat once. On the server it uses a simplified model (element spheres, no terrain or buildings).removeStores the removal of San Andreas map objects with a given model within a sphere of the given radius. Can be called many times; each call adds an entry. If called before the game has loaded its models (e.g. while the player joins), it waits and applies once loading finishes.World Model resetRemoves the colour filter. On the server for all players; on the client it removes the local filter, and the server filter (if any) stays.Color Filter resetClears the sky colours fromSky Gradient setSkyGradient.restoreRemovesWorld Model removeWorldModelentries for a model whose sphere touches the given sphere. Without coordinates it removes all entries of that model. It removes the calling resource's own entries first, and other resources' entries only when it has none of its own.setApplies a colour filter to the game image: two RGBA layers multiply the colours of the world, each to the degree of its alpha (alpha 0 = the layer changes nothing, 255 = the full layer colour). On the server every player gets the filter, on the client only this player (it takes priority over the server filter). Script texts and windows are not tinted.Color Filter setStores the sky colours: top (zenith) and bottom (near the horizon), each RGB 0-255.Sky Gradient setSets the in-game time for every player. From then on the clock keeps running by itself (unless it is stopped withTime setTimeFrozen); one game minute lasts one second by default (setMinuteDuration). The time of day changes the lighting, the sky colour and whether it is dark.setChanges the weather immediately for every player. Numbers 0-22 are San Andreas weathers, e.g. 0 extra sunny, 1-7 different mixes of sun and clouds, 8 storm, 9 fog, 16 rain, 19 sandstorm. It stops a smooth change started withWeather setWeatherBlended.setSchedules a smooth weather change: the server switches to the new weather after about two game hours.Weather Blended testChecks whether a segment crosses the water surface (by the level fromLine Against Water getWaterLevel) and returns the crossing point.
Client events 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