Skip to content

Commit

Permalink
feat: London Studios SmartMotorways integration
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Sep 30, 2023
1 parent 88e780b commit a11f6ad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.0

- London Studios SmartMotorways support.

## 0.1.1

- Proper versioning
Expand Down
25 changes: 23 additions & 2 deletions integration/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,42 @@ io.on("connection", (socket) => {
socket.on("sna-live-map:update-smart-sign", (data) => {
console.log(
"[sna-live-map]",
"Request received to update smart sign",
"Request received to update Smart Motorway sign",
data.id,
data.defaultText,
);

emit("SmartSigns:updateSign", data.id, [
emit("smartmotorways:updateSign", data.id, [
data.defaultText.firstLine,
data.defaultText.secondLine,
data.defaultText.thirdLine,
]);
});

const smartMotorwaySigns = exports.SmartMotorways["getSigns"]?.();
io.sockets.emit("sna-live-map:smart-motorways-signs", { smartMotorwaySigns });

socket.on("sna-live-map:update-smart-motorway-sign", (data) => {
console.log(
"[sna-live-map]",
"Request received to update Smart Motorway sign",
data.id,
data.defaultText,
);

console.log({ data });

emit("smartmotorways:updateSign", data.id, data.speeds);
});
});

on("SmartSigns:updateSignExternal", () => {
const smartSigns = exports.SmartSigns["SmartSigns:GetSigns"]?.();
io.sockets.emit("sna-live-map:smart-signs", { smartSigns });
});

// todo: sync

onNet(Events.CFXResourceStarted, (name: string) => {
const playerCount = GetNumPlayerIndices();

Expand All @@ -50,6 +68,9 @@ onNet(Events.CFXResourceStarted, (name: string) => {

const smartSigns = exports.SmartSigns["SmartSigns:GetSigns"]?.();
io.sockets.emit("sna-live-map:smart-signs", { smartSigns });

const smartMotorwaySigns = exports.SmartMotorways["getSigns"]?.();
io.sockets.emit("sna-live-map:smart-motorways-signs", { smartMotorwaySigns });
});

onNet(Events.CFXPlayerDropped, () => {
Expand Down

0 comments on commit a11f6ad

Please sign in to comment.