World
constWorld:object
Defined in: server/api.d.ts:921
Controls replicated world state and exposes collections of connected players and spawned vehicles.
Type Declaration
Section titled “Type Declaration”players
Section titled “players”
readonlyplayers:EntityCollection<Player>
Connected players visible to scripts; walk it with forEach, or filter and map for an array.
vehicles
Section titled “vehicles”
readonlyvehicles:EntityCollection<Vehicle>
Spawned vehicles visible to scripts; walk it with forEach, or filter and map for an array.
createExplosion()
Section titled “createExplosion()”createExplosion(
x,y,z,weaponId?,owner?):void
Detonates an explosion at a world-space position on every client.
Parameters
Section titled “Parameters”number
World-space X coordinate of the blast.
number
World-space Y coordinate of the blast.
number
World-space Z coordinate of the blast.
weaponId?
Section titled “weaponId?”number
Optional explosive weapon whose blast to reproduce: 20 Grenade MkII (default), 21 Molotov, 19 Bazooka, 7 Sicily grenade, 16 Stielhandgranate.
owner?
Section titled “owner?”number | Player
Optional player credited with any kill the blast causes.
Returns
Section titled “Returns”void
cycleTrafficLights()
Section titled “cycleTrafficLights()”cycleTrafficLights():
number
Advances the replicated traffic-light cycle by one epoch.
Returns
Section titled “Returns”number
The new monotonically increasing traffic epoch.
getDrivingCoeff()
Section titled “getDrivingCoeff()”getDrivingCoeff():
number
Returns the replicated arcade driving coefficient.
Returns
Section titled “Returns”number
A value from 0 for simulation handling to 1 for arcade handling.
getDrivingMode()
Section titled “getDrivingMode()”getDrivingMode():
"arcade"|"simulation"|"custom"
Returns the named driving-mode category for the current coefficient.
Returns
Section titled “Returns”"arcade" | "simulation" | "custom"
Arcade at coefficient 1, simulation at 0, or custom for an intermediate value.
getLightGroup()
Section titled “getLightGroup()”getLightGroup(
group):number
Returns the level this server drives for a light group.
Parameters
Section titled “Parameters”string | number
Light group name or index.
Returns
Section titled “Returns”number
The level from 0 to 1, or -1 when the group is left to the game’s own day/night lighting.
getOutdoorAmbient()
Section titled “getOutdoorAmbient()”getOutdoorAmbient():
OutdoorAmbientColor|null
Returns the replicated outdoor ambient colour override.
Returns
Section titled “Returns”OutdoorAmbientColor | null
The overriding colour, or null when the outdoor ambient is left to the weather template.
getPlayersWithinRange()
Section titled “getPlayersWithinRange()”getPlayersWithinRange(
x,y,z,range,virtualWorld?):Player[]
Lists the players whose replicated position is within range of a point. This is a distance test, not a trigger volume – for containment and enter/exit events use Volume, which runs on the game’s own physics sensors.
Parameters
Section titled “Parameters”number
World-space X coordinate of the query centre.
number
World-space Y coordinate of the query centre.
number
World-space Z coordinate of the query centre.
number
Radius in world units.
virtualWorld?
Section titled “virtualWorld?”number
Restrict the answer to one virtual world; every world by default.
Returns
Section titled “Returns”Player[]
The players in range.
getRainIntensity()
Section titled “getRainIntensity()”getRainIntensity():
number
Returns the replicated rain-intensity override.
Returns
Section titled “Returns”number
A value from 0 to 100, or -1 when no override is active.
getSeason()
Section titled “getSeason()”getSeason():
"summer"|"winter"
Returns the season this server declares in its mod.season configuration.
Returns
Section titled “Returns”"summer" | "winter"
The active season; the world’s ground, city and vehicle models are fixed to it, so weather templates should match.
getTime()
Section titled “getTime()”getTime():
WorldTime
Returns the current replicated game time as clock components.
Returns
Section titled “Returns”The current hour and minute.
getTimeNormalized()
Section titled “getTimeNormalized()”getTimeNormalized():
number
Returns the current game time in the engine’s normalized representation.
Returns
Section titled “Returns”number
A value from 0 inclusive to 1 exclusive, where 0 is midnight and 0.5 is noon.
getTimeScale()
Section titled “getTimeScale()”getTimeScale():
number
Returns the current game-clock speed multiplier.
Returns
Section titled “Returns”number
The non-negative replicated time scale.
getTrafficEpoch()
Section titled “getTrafficEpoch()”getTrafficEpoch():
number
Returns the current replicated traffic-light epoch.
Returns
Section titled “Returns”number
The current traffic cycle counter.
getWeather()
Section titled “getWeather()”getWeather():
string
Returns the active replicated weather template.
Returns
Section titled “Returns”string
The configured template name, or an empty string when world state is unavailable.
policeDispatch()
Section titled “policeDispatch()”policeDispatch(
event,x?,y?,z?,range?):void
Broadcasts a police radio event globally or around a world-space position.
Parameters
Section titled “Parameters”string | number
Police radio event name or numeric event identifier.
number
Optional world-space X coordinate; all four location arguments must be supplied together.
number
Optional world-space Y coordinate.
number
Optional world-space Z coordinate.
range?
Section titled “range?”number
Optional dispatch radius around the supplied position.
Returns
Section titled “Returns”void
resetLightGroup()
Section titled “resetLightGroup()”resetLightGroup(
group):void
Hands one light group back to the game’s day/night lighting. The group keeps its current appearance until the next in-game weather or time change.
Parameters
Section titled “Parameters”string | number
Light group name or index.
Returns
Section titled “Returns”void
resetLighting()
Section titled “resetLighting()”resetLighting():
void
Drops every light-group and outdoor-ambient override, handing the whole city back to the game’s day/night lighting.
Returns
Section titled “Returns”void
setBlackout()
Section titled “setBlackout()”setBlackout(
enabled?):void
Switches every fixed city light group at once: lampsOther, signalLights, advertLights, shopLights, lamps and trafficLights. Vehicle headlights and the outdoor ambient colour are left alone.
Parameters
Section titled “Parameters”enabled?
Section titled “enabled?”boolean
True to black the city out, false to switch it back on; defaults to true.
Returns
Section titled “Returns”void
setDrivingMode()
Section titled “setDrivingMode()”setDrivingMode(
mode):void
Sets the replicated vehicle driving model.
Parameters
Section titled “Parameters”number | "arcade" | "simulation"
Arcade, simulation (or sim), or a custom arcade coefficient from 0 to 1; numeric values are clamped.
Returns
Section titled “Returns”void
setLightGroup()
Section titled “setLightGroup()”setLightGroup(
group,level):void
Drives one city light group. The group stays under server control, surviving the game’s own weather updates, until it is released with resetLightGroup or resetLighting.
Parameters
Section titled “Parameters”string | number
Light group to drive, as a name or its index: lampsOther (0), signalLights (1), advertLights (2), shopLights (3), lamps (4), headlights (5), trafficLights (6), group7 (7), outdoorAmbient (8).
number | boolean
True or false to switch the whole group, or a number from 0 to 1 to light that fraction of it at random; the fraction also applies to lights that stream in later.
Returns
Section titled “Returns”void
setOutdoorAmbient()
Section titled “setOutdoorAmbient()”setOutdoorAmbient(
r,g,b):void
Overrides the global outdoor ambient colour, including outdoor lights that stream in afterwards.
Parameters
Section titled “Parameters”number
Red channel from 0 to 1; values outside the range are clamped.
number
Green channel from 0 to 1.
number
Blue channel from 0 to 1.
Returns
Section titled “Returns”void
setRainIntensity()
Section titled “setRainIntensity()”setRainIntensity(
value):void
Sets or disables the replicated rain-intensity override.
Parameters
Section titled “Parameters”number
Rain override from 0 to 100; a negative value disables the override.
Returns
Section titled “Returns”void
setTime()
Section titled “setTime()”setTime(
hour,minute?):void
Sets the replicated game time.
Parameters
Section titled “Parameters”number
Hour of day; the combined time is clamped to the valid 24-hour range.
minute?
Section titled “minute?”number
Minute of the hour; defaults to zero.
Returns
Section titled “Returns”void
setTimeScale()
Section titled “setTimeScale()”setTimeScale(
scale):void
Sets how quickly replicated game time advances.
Parameters
Section titled “Parameters”number
Game-clock speed multiplier; negative values are clamped to zero.
Returns
Section titled “Returns”void
setWeather()
Section titled “setWeather()”setWeather(
templateName):void
Sets the active replicated weather template.
Parameters
Section titled “Parameters”templateName
Section titled “templateName”string
Mafia II weather template name to replicate to clients.
Returns
Section titled “Returns”void
