- Update system to 1.2.1

- Add dialer for SecuriNet
This commit is contained in:
Christopher Cookman 2024-08-01 21:28:06 -06:00
parent 7b5c2c6485
commit 84d8a0ff54
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
3 changed files with 122 additions and 5 deletions

Binary file not shown.

107
Scripts/Dialer.lua Normal file
View file

@ -0,0 +1,107 @@
--- DONT TOUCH ---
local HttpService = game:GetService("HttpService")
local indicator = script.Parent.housing.logo.Logo.Model.ThreeDTextObject.uni0069
local acct = script.Parent.accountNumber.Value
local data = script.Parent.Parent.Reporting
local GetName = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
local placeName = GetName.Name
local dialing = false
local sent = false
local fail = false
local url = "http://pbx.litenet.tel:3000/api/v1/webhook/kca/" .. acct
task.spawn(function()
local state = false
if not indicator then return end
while true do
wait()
if not HttpService.HttpEnabled then
indicator.Color = Color3.new(1,1,0)
return
end
if dialing then
if state then
state = false
indicator.Color = Color3.new(1, 1, 1)
indicator.Material = Enum.Material.SmoothPlastic
wait(.1)
else
state = true
indicator.Color = Color3.new(0, 1, 1)
indicator.Material = Enum.Material.Neon
wait(.1)
end
elseif sent then
indicator.Color = Color3.new(0,1,0)
indicator.Material = Enum.Material.Neon
wait(1)
indicator.Color = Color3.new(1, 1, 1)
indicator.Material = Enum.Material.SmoothPlastic
sent = false
elseif fail then
indicator.Color = Color3.new(1,1,0)
indicator.Material = Enum.Material.Neon
wait(1)
indicator.Color = Color3.new(1, 1, 1)
indicator.Material = Enum.Material.SmoothPlastic
sent = false
end
end
end)
function generateTransactionId()
-- generate a 10 digit random number
local transactionId = ""
for i = 1, 10 do
transactionId = transactionId .. tostring(math.random(0, 9))
end
return transactionId
end
-- Watch for updates to script.Parent.Parent.Reporting.armState.Value
script.Parent.Parent.Reporting.armState.Changed:Connect(function(val)
if val == 3 then -- We've gone into alarm
-- Prepare an HTTP POST request JSON data
local postData = {
["event"] = "alarm",
["transaction"] = generateTransactionId(),
["zoneNumber"] = data.alarmZone.Value,
["zoneName"] = data.Parent.Zones[data.alarmZone.Value].zoneName.Value,
["placeName"] = placeName,
["systemName"] = data.Parent.Settings.SystemName.Value or "Your security system"
}
dialing = true
local success, response = HttpService:PostAsync(url, HttpService:JSONEncode(postData), Enum.HttpContentType.ApplicationJson)
if success then
dialing = false
sent = true
else
dialing = false
fail = true
end
elseif val == 4 then -- fire
-- Prepare an HTTP POST request JSON data
local postData = {
["accountNumber"] = acct,
["event"] = "fire alarm",
["transaction"] = generateTransactionId(),
["zoneNumber"] = data.fireZone.Value,
["zoneName"] = data.Parent.Zones[data.fireZone.Value].zoneName.Value,
["placeName"] = placeName,
["systemName"] = data.Parent.Settings.SystemName.Value or "Your security system"
}
dialing = true
local success, response = HttpService:PostAsync(url, HttpService:JSONEncode(postData), Enum.HttpContentType.ApplicationJson)
if success then
dialing = false
sent = true
else
dialing = false
fail = true
end
end
end)

View file

@ -3,7 +3,7 @@ local dataStore = DataStoreService:GetDataStore('securityCodes-' .. script.Paren
function setup(parentScript) function setup(parentScript)
-- dont touch -- dont touch
version = "v1.2.0" version = "v1.2.1"
-- codes object, will be swapped for data store later -- codes object, will be swapped for data store later
codes = dataStore:GetAsync("codes") codes = dataStore:GetAsync("codes")
@ -19,7 +19,7 @@ function setup(parentScript)
end end
power = false power = false
chime = false chime = true
armState = 0 armState = 0
delay = 0 delay = 0
instant = false instant = false
@ -560,9 +560,19 @@ delay
function stateLoop() function stateLoop()
while true do while true do
script.Parent.armState.Value = armState if #alarms > 0 then
script.Parent.delay.Value = delay script.Parent.Reporting.alarmZone.Value = alarms[1]
script.Parent.curTone.Value = curTone else
script.Parent.Reporting.alarmZone.Value = -1
end
if #fires > 0 then
script.Parent.Reporting.fireZone.Value = fires[1]
else
script.Parent.Reporting.fireZone.Value = -1
end
script.Parent.Reporting.armState.Value = armState
script.Parent.Reporting.delay.Value = delay
script.Parent.Reporting.curTone.Value = curTone
wait(0) wait(0)
end end
end end