World and CullZone¶
World¶
From server.world(id). Every player, vehicle and ped
is in a virtual world (0 by default). Worlds share world 0's time and
weather until given their own.
Properties¶
| Name | Type | Access | Description |
|---|---|---|---|
id |
number |
read | |
population |
Population |
read/write | Its ambient population; setting only some fields keeps the rest. |
synced |
boolean |
read/write | Follows world 0's time and weather (always true for world 0). |
time |
{ hour, minute, frozen } |
read/write | Its in-game time (set { hour, minute }). |
trafficLights |
TrafficLights |
read | Its traffic lights. |
weather |
number |
read/write | Weather, or Weather.GameCycle for each game's own. |
const arena = server.world(3);
arena.time = { hour: 0, minute: 0 };
arena.freezeTime();
arena.weather = Weather.CloudySF;
arena.population = { peds: false, traffic: false };
freezeTime(), unfreezeTime()¶
Stops or starts this world's clock.
view(target, visible?)¶
This world sees target (one way): see
server.setWorldView.
| Parameter | Type | Description |
|---|---|---|
target |
number |
The world it sees. |
visible |
boolean |
Default true. |
TrafficLights¶
From world.trafficLights, or server.trafficLights for world 0's. The
traffic lights are the same for everyone in a world: they change together
on every screen, and traffic stops for them alike (in single-player each
game runs its own). Like time and weather, a world uses world 0's until
it's given its own: changing them in a world gives it its own.
SA's lights all run on one round, with two directions: every light faces north-south or east-west. North-south goes green then yellow, then east-west does, then every car waits while pedestrians cross, and then their "don't walk" flashes. There's no per-junction control: holding the lights holds every junction in the world.
| Member | |
|---|---|
state |
read: the lights now, { northSouth, eastWest, pedestrians }, each a TrafficLight. |
frozen |
read: held by freeze or set, not going round. |
freeze() |
Holds them as they are now. |
set(states) |
Holds them with these set ({ northSouth?, eastWest?, pedestrians? }); the others stay as they are now. |
resume() |
Back to going round, from where they were held. |
isRedFor(what, radius?) |
Whether a vehicle (or { position, heading }) is at a red light: within radius m (default 25) of a junction with lights (every city's, from the map), the lights its way red or amber. |
timing |
read/write: { green, yellow, walk, flashing } in ms (each direction's green and yellow, then pedestrians' walk and their flashing "don't walk"). Setting some keeps the rest; each at least 500. Default 10000, 2000, 6766, 2002, as single-player. |
A TrafficLight is "green", "yellow", "red", "off" or
"flashing". "off" and "flashing" (yellow, on and off, as in the
riots) let traffic through. For pedestrians, "yellow" is the flashing
"don't walk".
server.trafficLights.timing = { green: 15000 }; // longer greens
server.trafficLights.freeze(); // held as they are
server.trafficLights.set({ northSouth: "green", eastWest: "red", pedestrians: "red" });
server.trafficLights.set({ northSouth: "flashing", eastWest: "flashing" }); // a power cut
server.trafficLights.resume();
Client scripts read them with sagl.world.trafficLights().
Population¶
| Field | Type | Default | Description |
|---|---|---|---|
peds |
boolean |
false |
Peds on foot. |
traffic |
boolean |
false |
Cars with drivers. |
density |
number |
1 |
0-3; 1 is single-player's. |
gangs |
boolean |
false |
Gang members and cars in their territories. |
police |
boolean |
false |
Patrols, and cops responding to wanted players. Off: no cop ever appears. |
ambulance |
boolean |
false |
Medics sent to the injured. |
fire |
boolean |
false |
Fire trucks sent to fires. |
wanted |
boolean |
false |
Crimes make players wanted, as in single-player. |
evadeSeconds |
number |
0 |
Losing the cops: with no police (cops or their vehicles) within evadeDistance for this long, a star goes, then the next. 0: only the game's own rules, under which a city never lets more than one star go (that takes a Pay 'n' Spray). |
evadeDistance |
number |
60 |
How near police must be (m) to keep the stars. |
indicators |
boolean |
true |
Drivers signal before turning at junctions, and put their hazards on when their car has broken down. This covers traffic and server peds driving. Everyone sees the same signals. |
CullZone¶
From server.createCullZone(): an area
with the game's interior effects (music, no rain, camera close-in, a
mirror).
| Name | Type | Description |
|---|---|---|
id |
number |
|
exists |
boolean |
False once destroyed. |