diff --git a/integrations/sync/client/flows/911-call-attach.ts b/integrations/sync/client/flows/911-call-attach.ts index 4289c36..a29ac67 100644 --- a/integrations/sync/client/flows/911-call-attach.ts +++ b/integrations/sync/client/flows/911-call-attach.ts @@ -28,3 +28,29 @@ onNet( SetNuiFocus(true, true); }, ); + +const POSTAL_COMMAND = GetConvar("snailycad_postal_command", "null"); +onNet(ClientEvents.AutoPostalOnAttach, (postal: string) => { + const postalCodeAsInt = parseInt(postal); + + if (POSTAL_COMMAND === "null") { + console.info(` +--------------------------------------- + +[${GetCurrentResourceName()}] Not automatically setting postal code for call. There was no postal command set.: +\`setr snailycad_postal_command "" \` + +---------------------------------------`); + return; + } + + if (postalCodeAsInt > 0) { + ExecuteCommand(`${POSTAL_COMMAND} ${postalCodeAsInt}`); + } else { + emit("chat:addMessage", { + color: [255, 0, 0], + multiline: true, + args: ["SnailyCAD", "An error occured while making route to call postal"], + }); + } +}); diff --git a/integrations/sync/server/flows/911-call-attach.ts b/integrations/sync/server/flows/911-call-attach.ts index 2c460cd..8d37f48 100644 --- a/integrations/sync/server/flows/911-call-attach.ts +++ b/integrations/sync/server/flows/911-call-attach.ts @@ -109,6 +109,7 @@ onNet( ), ], }); + emitNet(ClientEvents.AutoPostalOnAttach, source, updatedCall.postal); } else { emitNet("chat:addMessage", source, { args: [ diff --git a/package.json b/package.json index 464164a..31b9759 100644 --- a/package.json +++ b/package.json @@ -51,4 +51,4 @@ "printWidth": 100, "tabWidth": 2 } -} \ No newline at end of file +} diff --git a/src/types/events.ts b/src/types/events.ts index 69e3979..d15e555 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -99,6 +99,8 @@ export enum ClientEvents { RequestTrafficStopFlow = "sna-sync:request-traffic-stop-flow", CreateNotification = "sna-sync:create-notification", + + AutoPostalOnAttach = "sna-sync:attach-postal", } export enum NuiEvents {