diff --git a/Individual Components/WorkingDialerModel.rbxm b/Individual Components/WorkingDialerModel.rbxm new file mode 100644 index 0000000..8303cf0 Binary files /dev/null and b/Individual Components/WorkingDialerModel.rbxm differ diff --git a/Scripts/Dialer.lua b/Scripts/Dialer.lua new file mode 100644 index 0000000..a9a485a --- /dev/null +++ b/Scripts/Dialer.lua @@ -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) \ No newline at end of file diff --git a/Scripts/SecuritySystem.lua b/Scripts/SecuritySystem.lua index 0f1f8cf..45f5732 100644 --- a/Scripts/SecuritySystem.lua +++ b/Scripts/SecuritySystem.lua @@ -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