- Update system to 1.2.1
- Add dialer for SecuriNet
This commit is contained in:
parent
7b5c2c6485
commit
84d8a0ff54
BIN
Individual Components/WorkingDialerModel.rbxm
Normal file
BIN
Individual Components/WorkingDialerModel.rbxm
Normal file
Binary file not shown.
107
Scripts/Dialer.lua
Normal file
107
Scripts/Dialer.lua
Normal 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)
|
|
@ -3,7 +3,7 @@ local dataStore = DataStoreService:GetDataStore('securityCodes-' .. script.Paren
|
|||
|
||||
function setup(parentScript)
|
||||
-- dont touch
|
||||
version = "v1.2.0"
|
||||
version = "v1.2.1"
|
||||
|
||||
-- codes object, will be swapped for data store later
|
||||
codes = dataStore:GetAsync("codes")
|
||||
|
@ -19,7 +19,7 @@ function setup(parentScript)
|
|||
end
|
||||
|
||||
power = false
|
||||
chime = false
|
||||
chime = true
|
||||
armState = 0
|
||||
delay = 0
|
||||
instant = false
|
||||
|
@ -560,9 +560,19 @@ delay
|
|||
|
||||
function stateLoop()
|
||||
while true do
|
||||
script.Parent.armState.Value = armState
|
||||
script.Parent.delay.Value = delay
|
||||
script.Parent.curTone.Value = curTone
|
||||
if #alarms > 0 then
|
||||
script.Parent.Reporting.alarmZone.Value = alarms[1]
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue