Commands#
Downtown Mechanic registers a single command. In chat it needs the ACE permission command.mechanicmap (see Granting the Command); in the server console and txAdmin it always works, written without the slash.
Command | Where | Description |
|---|---|---|
| Chat · console | The workshop alone. Unloads the event and food layers for everyone. |
| Chat · console | The workshop with the event layer: gazebo, barbecue, tables and chairs. |
| Chat · console | The workshop with the event layer and the food layer on top. |
Every valid call saves the layer to map_state.json, sends it to every connected player and prints [MECHANIC MAP] State updated: <n> in the server console. Anything else — no number, a word, 3, -1 — changes nothing and prints the usage line.
Exports#
Downtown Mechanic has no exports, on purpose. The command already validates the value, saves it and syncs every player in one call, so it is the API — another resource drives the map by running it.
Switching the layer from a server resource
-- server side, in your own resource
ExecuteCommand('mechanicmap 2') -- open the meet, with food
ExecuteCommand('mechanicmap 1') -- clear the food, keep the meet
ExecuteCommand('mechanicmap 0') -- back to a normal working dayA resource running a restricted command needs its own ACE in server.cfg, or the call is refused. Use your resource's folder name:
add_ace resource.my_events command.mechanicmap allowA weekly event, on a schedule
Opens the meet with food every Friday from 20:00 until 02:00, in the server's local time, and closes it afterwards. It only runs the command when the layer should change, so an admin can still switch it by hand in between.
-- server side, in your own resource
local function wantedLayer()
local t = os.date('*t') -- wday: 1 = Sunday … 6 = Friday, 7 = Saturday
if (t.wday == 6 and t.hour >= 20) or (t.wday == 7 and t.hour < 2) then
return 2
end
return 0
end
CreateThread(function()
local current
while true do
local layer = wantedLayer()
if layer ~= current then
ExecuteCommand(('mechanicmap %d'):format(layer))
current = layer
end
Wait(60000)
end
end)Start it after ensure qs_downtown_mechanic so the command exists when it first runs, and give it the same add_ace resource.<name> command.mechanicmap allow line. On start it applies the layer the clock calls for, overriding the one saved in map_state.json.
Events#
Two network events carry the layer between the server and each player. They are listed so you can listen to them, not so you can fire them.
Event | Direction | Description |
|---|---|---|
| Client → server | No arguments. Each client sends it once, half a second after the map starts on its side. The server answers that client only, with |
| Server → client | One argument, |
Reacting when the meet opens
Any client script can register the same event and run alongside the map's own handler — to show a blip, start music, open a food stall or post a phone notification:
-- client side, in your own resource
RegisterNetEvent('mechanicmap:setState', function(mapId)
local layer = mapId or 0 -- nil means the workshop alone
if layer >= 1 then
-- the meet is open (2 = with food)
else
-- back to a normal working day
end
end)It fires for every player when the command runs, and once more for each player as they join.



