SHARE
    TWEET
    supinus

    dzdzzd

    Apr 3rd, 2025
    597
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Lua 42.85 KB | Gaming | 0 0
    1. ac.log("Police script")
    2. local sim = ac.getSim()
    3. local car = ac.getCar(0)
    4. local valideCar = {"audi_rs3_2022_LMC", "bmw_m340i_Police_HighSpeed", "police_r34_tiresarpi"}
    5. local carID = ac.getCarID(0)
    6. local windowWidth = sim.windowWidth
    7. local windowHeight = sim.windowHeight
    8. local settingsOpen = false
    9. local arrestLogsOpen = false
    10. local camerasOpen = false
    11. local cspVersion = ac.getPatchVersionCode()
    12. local cspMinVersion = 2144
    13. local fontMultiplier = windowHeight/1440
    14. local firstload = true
    15. local cspAboveP218 = cspVersion >= 2363
    16. ac.log("Police script")
    17. if not(carID == valideCar[1] or carID == valideCar[2] or carID == valideCar[3]) or cspVersion < cspMinVersion then return end
    18. local msgArrest = {
    19. msg = {"`NAME` has been arrested for Speeding. The individual was driving a `CAR`.",
    20. "We have apprehended `NAME` for Speeding. The suspect was behind the wheel of a `CAR`.",
    21. "The driver of a `CAR`, identified as `NAME`, has been arrested for Speeding.",
    22. "`NAME` has been taken into custody for Illegal Racing. The suspect was driving a `CAR`.",
    23. "We have successfully apprehended `NAME` for Illegal Racing. The individual was operating a `CAR`.",
    24. "The driver of a `CAR`, identified as `NAME`, has been arrested for Illegal Racing.",
    25. "`NAME` has been apprehended for Speeding. The suspect was operating a `CAR` at the time of the arrest.",
    26. "We have successfully detained `NAME` for Illegal Racing. The individual was driving a `CAR`.",
    27. "`NAME` driving a `CAR` has been arrested for Speeding",
    28. "`NAME` driving a `CAR` has been arrested for Illegal Racing."}
    29. }
    30. local msgLost = {
    31. msg = {"We've lost sight of the suspect. The vehicle involved is described as a `CAR` driven by `NAME`.",
    32. "Attention all units, we have lost visual contact with the suspect. The vehicle involved is a `CAR` driven by `NAME`.",
    33. "We have temporarily lost track of the suspect. The vehicle description is a `CAR` with `NAME` as the driver.",
    34. "Visual contact with the suspect has been lost. The suspect is driving a `CAR` and identified as `NAME`.",
    35. "We have lost the suspect's visual trail. The vehicle in question is described as a `CAR` driven by `NAME`.",
    36. "Suspect have been lost, Vehicle Description:`CAR` driven by `NAME`",
    37. "Visual contact with the suspect has been lost. The suspect is driving a `CAR` and identified as `NAME`.",
    38. "We have lost the suspect's visual trail. The vehicle in question is described as a `CAR` driven by `NAME`.",}
    39. }
    40. local msgEngage = {
    41. msg = {"Control! I am engaging on a `CAR` traveling at `SPEED`","Pursuit in progress! I am chasing a `CAR` exceeding `SPEED`","Control, be advised! Pursuit is active on a `CAR` driving over `SPEED`","Attention! Pursuit initiated! Im following a `CAR` going above `SPEED`","Pursuit engaged! `CAR` driving at a high rate of speed over `SPEED`","Attention all units, we have a pursuit in progress! Suspect driving a `CAR` exceeding `SPEED`","Attention units! We have a suspect fleeing in a `CAR` at high speed, pursuing now at `SPEED`","Engaging on a high-speed chase! Suspect driving a `CAR` exceeding `SPEED`!","Attention all units! we have a pursuit in progress! Suspect driving a `CAR` exceeding `SPEED`","High-speed chase underway, suspect driving `CAR` over `SPEED`","Control, `CAR` exceeding `SPEED`, pursuit active.","Engaging on a `CAR` exceeding `SPEED`, pursuit initiated."}
    42. }
    43. ------------------------------------------------------------------------- JSON Utils -------------------------------------------------------------------------
    44. local json = {}
    45. -- Internal functions.
    46. local function kind_of(obj)
    47. if type(obj) ~= 'table' then return type(obj) end
    48. local i = 1
    49. for _ in pairs(obj) do
    50. if obj[i] ~= nil then i = i + 1 else return 'table' end
    51. end
    52. if i == 1 then return 'table' else return 'array' end
    53. end
    54. local function escape_str(s)
    55. local in_char = {'\\', '"', '/', '\b', '\f', '\n', '\r', '\t'}
    56. local out_char = {'\\', '"', '/', 'b', 'f', 'n', 'r', 't'}
    57. for i, c in ipairs(in_char) do
    58. s = s:gsub(c, '\\' .. out_char[i])
    59. end
    60. return s
    61. end
    62. -- Returns pos, did_find; there are two cases:
    63. -- 1. Delimiter found: pos = pos after leading space + delim; did_find = true.
    64. -- 2. Delimiter not found: pos = pos after leading space; did_find = false.
    65. -- This throws an error if err_if_missing is true and the delim is not found.
    66. local function skip_delim(str, pos, delim, err_if_missing)
    67. pos = pos + #str:match('^%s*', pos)
    68. if str:sub(pos, pos) ~= delim then
    69. if err_if_missing then
    70. error('Expected ' .. delim .. ' near position ' .. pos)
    71. end
    72. return pos, false
    73. end
    74. return pos + 1, true
    75. end
    76. -- Expects the given pos to be the first character after the opening quote.
    77. -- Returns val, pos; the returned pos is after the closing quote character.
    78. local function parse_str_val(str, pos, val)
    79. val = val or ''
    80. local early_end_error = 'End of input found while parsing string.'
    81. if pos > #str then error(early_end_error) end
    82. local c = str:sub(pos, pos)
    83. if c == '"' then return val, pos + 1 end
    84. if c ~= '\\' then return parse_str_val(str, pos + 1, val .. c) end
    85. -- We must have a \ character.
    86. local esc_map = {b = '\b', f = '\f', n = '\n', r = '\r', t = '\t'}
    87. local nextc = str:sub(pos + 1, pos + 1)
    88. if not nextc then error(early_end_error) end
    89. return parse_str_val(str, pos + 2, val .. (esc_map[nextc] or nextc))
    90. end
    91. -- Returns val, pos; the returned pos is after the number's final character.
    92. local function parse_num_val(str, pos)
    93. local num_str = str:match('^-?%d+%.?%d*[eE]?[+-]?%d*', pos)
    94. local val = tonumber(num_str)
    95. if not val then error('Error parsing number at position ' .. pos .. '.') end
    96. return val, pos + #num_str
    97. end
    98. -- Public values and functions.
    99. function json.stringify(obj, as_key)
    100. local s = {} -- We'll build the string as an array of strings to be concatenated.
    101. local kind = kind_of(obj) -- This is 'array' if it's an array or type(obj) otherwise.
    102. if kind == 'array' then
    103. if as_key then error('Can\'t encode array as key.') end
    104. s[#s + 1] = '['
    105. for i, val in ipairs(obj) do
    106. if i > 1 then s[#s + 1] = ', ' end
    107. s[#s + 1] = json.stringify(val)
    108. end
    109. s[#s + 1] = ']'
    110. elseif kind == 'table' then
    111. if as_key then error('Can\'t encode table as key.') end
    112. s[#s + 1] = '{'
    113. for k, v in pairs(obj) do
    114. if #s > 1 then s[#s + 1] = ', ' end
    115. s[#s + 1] = json.stringify(k, true)
    116. s[#s + 1] = ':'
    117. s[#s + 1] = json.stringify(v)
    118. end
    119. s[#s + 1] = '}'
    120. elseif kind == 'string' then
    121. return '"' .. escape_str(obj) .. '"'
    122. elseif kind == 'number' then
    123. if as_key then return '"' .. tostring(obj) .. '"' end
    124. return tostring(obj)
    125. elseif kind == 'boolean' then
    126. return tostring(obj)
    127. elseif kind == 'nil' then
    128. return 'null'
    129. else
    130. error('Unjsonifiable type: ' .. kind .. '.')
    131. end
    132. return table.concat(s)
    133. end
    134. json.null = {} -- This is a one-off table to represent the null value.
    135. function json.parse(str, pos, end_delim)
    136. pos = pos or 1
    137. if pos > #str then error('Reached unexpected end of input.') end
    138. local pos = pos + #str:match('^%s*', pos) -- Skip whitespace.
    139. local first = str:sub(pos, pos)
    140. if first == '{' then -- Parse an object.
    141. local obj, key, delim_found = {}, true, true
    142. pos = pos + 1
    143. while true do
    144. key, pos = json.parse(str, pos, '}')
    145. if key == nil then return obj, pos end
    146. if not delim_found then error('Comma missing between object items.') end
    147. pos = skip_delim(str, pos, ':', true) -- true -> error if missing.
    148. obj[key], pos = json.parse(str, pos)
    149. pos, delim_found = skip_delim(str, pos, ',')
    150. end
    151. elseif first == '[' then -- Parse an array.
    152. local arr, val, delim_found = {}, true, true
    153. pos = pos + 1
    154. while true do
    155. val, pos = json.parse(str, pos, ']')
    156. if val == nil then return arr, pos end
    157. if not delim_found then error('Comma missing between array items.') end
    158. arr[#arr + 1] = val
    159. pos, delim_found = skip_delim(str, pos, ',')
    160. end
    161. elseif first == '"' then -- Parse a string.
    162. return parse_str_val(str, pos + 1)
    163. elseif first == '-' or first:match('%d') then -- Parse a number.
    164. return parse_num_val(str, pos)
    165. elseif first == end_delim then -- End of an object or array.
    166. return nil, pos + 1
    167. else -- Parse true, false, or null.
    168. local literals = {['true'] = true, ['false'] = false, ['null'] = json.null}
    169. for lit_str, lit_val in pairs(literals) do
    170. local lit_end = pos + #lit_str - 1
    171. if str:sub(pos, lit_end) == lit_str then return lit_val, lit_end + 1 end
    172. end
    173. local pos_info_str = 'position ' .. pos .. ': ' .. str:sub(pos, pos + 10)
    174. error('Invalid json syntax starting at ' .. pos_info_str)
    175. end
    176. end
    177. --return json of playerData with only the data needed for the leaderboard
    178. -- data are keys of the playerData table
    179. local function dataStringify(data)
    180. local str = '{"' .. ac.getUserSteamID() .. '": '
    181. local name = ac.getDriverName(0)
    182. data['Name'] = name
    183. str = str .. json.stringify(data) .. '}'
    184. return str
    185. end
    186. ------------------------------------------------------------------------- Web Utils -------------------------------------------------------------------------
    187. local settings = {
    188. essentialSize = 20,
    189. policeSize = 20,
    190. hudOffsetX = 0,
    191. hudOffsetY = 0,
    192. fontSize = 20,
    193. current = 1,
    194. colorHud = rgbm(1,0,0,1),
    195. timeMsg = 10,
    196. msgOffsetY = 10,
    197. msgOffsetX = windowWidth/2,
    198. fontSizeMSG = 30,
    199. menuPos = vec2(0, 0),
    200. unit = "km/h",
    201. unitMult = 1,
    202. starsSize = 20,
    203. starsPos = vec2(windowWidth, 0),
    204. }
    205. local settingsJSON = {
    206. essentialSize = 20,
    207. policeSize = 20,
    208. hudOffsetX = 0,
    209. hudOffsetY = 0,
    210. fontSize = 20,
    211. current = 1,
    212. colorHud = "1,0,0,1",
    213. timeMsg = 10,
    214. msgOffsetY = 10,
    215. msgOffsetX = "1280",
    216. fontSizeMSG = 30,
    217. menuPos = vec2(0, 0),
    218. unit = "km/h",
    219. unitMult = 1,
    220. starsSize = 20,
    221. starsPos = vec2(windowWidth, 0),
    222. }
    223. local function stringToVec2(str)
    224. if str == nil then return vec2(0, 0) end
    225. local x = string.match(str, "([^,]+)")
    226. local y = string.match(str, "[^,]+,(.+)")
    227. return vec2(tonumber(x), tonumber(y))
    228. end
    229. local function vec2ToString(vec)
    230. return tostring(vec.x) .. ',' .. tostring(vec.y)
    231. end
    232. local function stringToRGBM(str)
    233. local r = string.match(str, "([^,]+)")
    234. local g = string.match(str, "[^,]+,([^,]+)")
    235. local b = string.match(str, "[^,]+,[^,]+,([^,]+)")
    236. local m = string.match(str, "[^,]+,[^,]+,[^,]+,(.+)")
    237. return rgbm(tonumber(r), tonumber(g), tonumber(b), tonumber(m))
    238. end
    239. local function rgbmToString(rgbm)
    240. return tostring(rgbm.r) .. ',' .. tostring(rgbm.g) .. ',' .. tostring(rgbm.b) .. ',' .. tostring(rgbm.mult)
    241. end
    242. local function parsesettings(table)
    243. settings.essentialSize = table.essentialSize
    244. settings.policeSize = table.policeSize
    245. settings.hudOffsetX = table.hudOffsetX
    246. settings.hudOffsetY = table.hudOffsetY
    247. settings.fontSize = table.fontSize
    248. settings.current = table.current
    249. settings.colorHud = stringToRGBM(table.colorHud)
    250. settings.timeMsg = table.timeMsg
    251. settings.msgOffsetY = table.msgOffsetY
    252. settings.msgOffsetX = table.msgOffsetX
    253. settings.fontSizeMSG = table.fontSizeMSG
    254. settings.menuPos = stringToVec2(table.menuPos)
    255. settings.unit = table.unit
    256. settings.unitMult = table.unitMult
    257. settings.starsSize = table.starsSize or 20
    258. if table.starsPos == nil then
    259. settings.starsPos = vec2(windowWidth, 0)
    260. else
    261. settings.starsPos = stringToVec2(table.starsPos)
    262. end
    263. end
    264. ui.setAsynchronousImagesLoading(true)
    265. local imageSize = vec2(0,0)
    266. local hudImg = {
    267. base = "https://i.ibb.co/8N4mNj6/zhud.png",
    268. arrest = "https://i.postimg.cc/DwJv2YgM/icon-Arrest.png",
    269. cams = "https://i.postimg.cc/15zRdzNP/iconCams.png",
    270. logs = "https://i.postimg.cc/VNXztr29/iconLogs.png",
    271. lost = "https://i.postimg.cc/DyYf3KqG/iconLost.png",
    272. menu = "https://i.postimg.cc/SxByj71N/iconMenu.png",
    273. radar = "https://i.postimg.cc/4dZsQ4TD/icon-Radar.png",
    274. }
    275. local cameras = {
    276. {
    277. name = "BOBs SCRAPYARD",
    278. pos = vec3(-3564, 31.5, -103),
    279. dir = -8,
    280. fov = 60,
    281. },
    282. {
    283. name = "ARENA",
    284. pos = vec3(-2283, 115.5, 3284),
    285. dir = 128,
    286. fov = 70,
    287. },
    288. {
    289. name = "BANK",
    290. pos = vec3(-716, 151, 3556.4),
    291. dir = 12,
    292. fov = 95,
    293. },
    294. {
    295. name = "STREET RUNNERS",
    296. pos = vec3(-57.3, 103.5, 2935.5),
    297. dir = 16,
    298. fov = 67,
    299. },
    300. {
    301. name = "ROAD CRIMINALS",
    302. pos = vec3(-2332, 101.1, 3119.2),
    303. dir = 121,
    304. fov = 60,
    305. },
    306. {
    307. name = "RECKLESS RENEGADES",
    308. pos = vec3(-2993.7, -24.4, -601.7),
    309. dir = -64,
    310. fov = 60,
    311. },
    312. {
    313. name = "MOTION MASTERS",
    314. pos = vec3(-2120.4, -11.8, -1911.5),
    315. dir = 102,
    316. fov = 60,
    317. },
    318. }
    319. local pursuit = {
    320. suspect = nil,
    321. enable = false,
    322. maxDistance = 250000,
    323. minDistance = 40000,
    324. nextMessage = 30,
    325. level = 1,
    326. id = -1,
    327. timerArrest = 0,
    328. hasArrested = false,
    329. startedTime = 0,
    330. timeLostSight = 0,
    331. lostSight = false,
    332. engage = false,
    333. }
    334. local arrestations = {}
    335. local textSize = {}
    336. local textPos = {}
    337. local iconPos = {}
    338. local playerData = {}
    339. ---------------------------------------------------------------------------------------------- Firebase ----------------------------------------------------------------------------------------------
    340. local urlAppScript = 'https://script.google.com/macros/s/AKfycbwenxjCAbfJA-S90VlV0y7mEH75qt3TuqAmVvlGkx-Y1TX8z5gHtvf5Vb8bOVNOA_9j/exec'
    341. local firebaseUrl = 'https://acp-server-97674-default-rtdb.firebaseio.com/'
    342. local firebaseUrlData = 'https://acp-server-97674-default-rtdb.firebaseio.com/PlayersData/'
    343. local firebaseUrlsettings = 'https://acp-server-97674-default-rtdb.firebaseio.com/Settings'
    344. local function updateSheets()
    345. local str = '{"category" : "Arrestations"}'
    346. web.post(urlAppScript, str, function(err, response)
    347. if err then
    348. print(err)
    349. return
    350. else
    351. print(response.body)
    352. end
    353. end)
    354. end
    355. local function addPlayerToDataBase()
    356. local steamID = ac.getUserSteamID()
    357. local name = ac.getDriverName(0)
    358. local str = '{"' .. steamID .. '": {"Name":"' .. name .. '","Getaway": 0,"Drift": 0,"Overtake": 0,"Wins": 0,"Losses": 0,"Busted": 0,"Arrests": 0,"Theft": 0}}'
    359. web.request('PATCH', firebaseUrl .. "Players.json", str, function(err, response)
    360. if err then
    361. print(err)
    362. return
    363. end
    364. end)
    365. end
    366. local function getFirebase()
    367. local url = firebaseUrl .. "Players/" .. ac.getUserSteamID() .. '.json'
    368. web.get(url, function(err, response)
    369. if err then
    370. print(err)
    371. return
    372. else
    373. if response.body == 'null' then
    374. addPlayerToDataBase(ac.getUserSteamID())
    375. else
    376. local jString = response.body
    377. playerData = json.parse(jString)
    378. if playerData.Name ~= ac.getDriverName(0) then
    379. playerData.Name = ac.getDriverName(0)
    380. end
    381. end
    382. ac.log('Player data loaded')
    383. end
    384. end)
    385. end
    386. local function updatefirebase()
    387. local str = '{"' .. ac.getUserSteamID() .. '": ' .. json.stringify(playerData) .. '}'
    388. web.request('PATCH', firebaseUrl .. "Players.json", str, function(err, response)
    389. if err then
    390. print(err)
    391. return
    392. else
    393. print(response.body)
    394. end
    395. end)
    396. end
    397. local function updatefirebaseData(node, data)
    398. local str = dataStringify(data)
    399. web.request('PATCH', firebaseUrlData .. node .. ".json", str, function(err, response)
    400. if err then
    401. print(err)
    402. return
    403. else
    404. print(response.body)
    405. updateSheets()
    406. end
    407. end)
    408. end
    409. local function addPlayersettingsToDataBase(steamID)
    410. local str = '{"' .. steamID .. '": {"essentialSize":20,"policeSize":20,"hudOffsetX":0,"hudOffsetY":0,"fontSize":20,"current":1,"colorHud":"1,0,0,1","timeMsg":10,"msgOffsetY":10,"msgOffsetX":' .. windowWidth/2 .. ',"fontSizeMSG":30,"menuPos":"0,0","unit":"km/h","unitMult":1}}'
    411. web.request('PATCH', firebaseUrlsettings .. ".json", str, function(err, response)
    412. if err then
    413. print(err)
    414. return
    415. end
    416. end)
    417. end
    418. local function loadsettings()
    419. local url = firebaseUrlsettings .. "/" .. ac.getUserSteamID() .. '.json'
    420. web.get(url, function(err, response)
    421. if err then
    422. print(err)
    423. return
    424. else
    425. if response.body == 'null' then
    426. addPlayersettingsToDataBase(ac.getUserSteamID())
    427. else
    428. ac.log("settings loaded")
    429. local jString = response.body
    430. local table = json.parse(jString)
    431. parsesettings(table)
    432. end
    433. end
    434. end)
    435. end
    436. local function updatesettings()
    437. local str = '{"' .. ac.getUserSteamID() .. '": ' .. json.stringify(settingsJSON) .. '}'
    438. web.request('PATCH', firebaseUrlsettings .. ".json", str, function(err, response)
    439. if err then
    440. print(err)
    441. return
    442. end
    443. end)
    444. end
    445. local function onsettingsChange()
    446. settingsJSON.colorHud = rgbmToString(settings.colorHud)
    447. settingsJSON.menuPos = vec2ToString(settings.menuPos)
    448. settingsJSON.essentialSize = settings.essentialSize
    449. settingsJSON.policeSize = settings.policeSize
    450. settingsJSON.hudOffsetX = settings.hudOffsetX
    451. settingsJSON.hudOffsetY = settings.hudOffsetY
    452. settingsJSON.fontSize = settings.fontSize
    453. settingsJSON.current = settings.current
    454. settingsJSON.timeMsg = settings.timeMsg
    455. settingsJSON.msgOffsetY = settings.msgOffsetY
    456. settingsJSON.msgOffsetX = settings.msgOffsetX
    457. settingsJSON.fontSizeMSG = settings.fontSizeMSG
    458. settingsJSON.unit = settings.unit
    459. settingsJSON.unitMult = settings.unitMult
    460. settingsJSON.starsSize = settings.starsSize
    461. settingsJSON.starsPos = vec2ToString(settings.starsPos)
    462. updatesettings()
    463. end
    464. ---------------------------------------------------------------------------------------------- settings ----------------------------------------------------------------------------------------------
    465. local acpPolice = ac.OnlineEvent({
    466. message = ac.StructItem.string(110),
    467. messageType = ac.StructItem.int16(),
    468. yourIndex = ac.StructItem.int16(),
    469. }, function (sender, data)
    470. if data.yourIndex == car.sessionID and data.messageType == 0 and pursuit.suspect ~= nil and sender == pursuit.suspect then
    471. pursuit.hasArrested = true
    472. ac.log("ZHD Police: Police received")
    473. end
    474. end)
    475. local starsUI = {
    476. starsPos = vec2(windowWidth - (settings.starsSize or 20)/2, settings.starsSize or 20)/2,
    477. starsSize = vec2(windowWidth - (settings.starsSize or 20)*2, (settings.starsSize or 20)*2),
    478. startSpace = (settings.starsSize or 20)/4,
    479. }
    480. local function resetStarsUI()
    481. if settings.starsPos == nil then
    482. settings.starsPos = vec2(windowWidth, 0)
    483. end
    484. if settings.starsSize == nil then
    485. settings.starsSize = 20
    486. end
    487. starsUI.starsPos = vec2(settings.starsPos.x - settings.starsSize/2, settings.starsPos.y + settings.starsSize/2)
    488. starsUI.starsSize = vec2(settings.starsPos.x - settings.starsSize*2, settings.starsPos.y + settings.starsSize*2)
    489. starsUI.startSpace = settings.starsSize/1.5
    490. end
    491. local function updatePos()
    492. imageSize = vec2(windowHeight/80 * settings.policeSize, windowHeight/80 * settings.policeSize)
    493. iconPos.arrest1 = vec2(imageSize.x - imageSize.x/12, imageSize.y/3.2)
    494. iconPos.arrest2 = vec2(imageSize.x/1.215, imageSize.y/5)
    495. iconPos.lost1 = vec2(imageSize.x - imageSize.x/12, imageSize.y/2.35)
    496. iconPos.lost2 = vec2(imageSize.x/1.215, imageSize.y/3.2)
    497. iconPos.logs1 = vec2(imageSize.x/1.215, imageSize.y/1.88)
    498. iconPos.logs2 = vec2(imageSize.x/1.39, imageSize.y/2.35)
    499. iconPos.menu1 = vec2(imageSize.x - imageSize.x/12, imageSize.y/1.88)
    500. iconPos.menu2 = vec2(imageSize.x/1.215, imageSize.y/2.35)
    501. iconPos.cams1 = vec2(imageSize.x/1.215, imageSize.y/2.35)
    502. iconPos.cams2 = vec2(imageSize.x/1.39, imageSize.y/3.2)
    503. textSize.size = vec2(imageSize.x*3/5, settings.fontSize/2)
    504. textSize.box = vec2(imageSize.x*3/5, settings.fontSize/1.3)
    505. textSize.window1 = vec2(settings.hudOffsetX+imageSize.x/9.5, settings.hudOffsetY+imageSize.y/5.3)
    506. textSize.window2 = vec2(imageSize.x*3/5, imageSize.y/2.8)
    507. textPos.box1 = vec2(0, 0)
    508. textPos.box2 = vec2(textSize.size.x, textSize.size.y*1.8)
    509. textPos.addBox = vec2(0, textSize.size.y*1.8)
    510. settings.fontSize = settings.policeSize * fontMultiplier
    511. resetStarsUI()
    512. end
    513. local function showStarsPursuit()
    514. local starsColor = rgbm(1, 1, 1, os.clock()%2 + 0.3)
    515. resetStarsUI()
    516. for i = 1, 5 do
    517. if i > pursuit.level/2 then
    518. ui.drawIcon(ui.Icons.StarEmpty, starsUI.starsPos, starsUI.starsSize, rgbm(1, 1, 1, 0.2))
    519. else
    520. ui.drawIcon(ui.Icons.StarFull, starsUI.starsPos, starsUI.starsSize, starsColor)
    521. end
    522. starsUI.starsPos.x = starsUI.starsPos.x - settings.starsSize - starsUI.startSpace
    523. starsUI.starsSize.x = starsUI.starsSize.x - settings.starsSize - starsUI.startSpace
    524. end
    525. end
    526. local showPreviewMsg = false
    527. local showPreviewStars = false
    528. COLORSMSGBG = rgbm(0.5,0.5,0.5,0.5)
    529. local function initsettings()
    530. if settings.unit then
    531. settings.fontSize = settings.policeSize * fontMultiplier
    532. if settings.unit ~= "km/h" then settings.unitMult = 0.621371 end
    533. settings.policeSize = settings.policeSize * windowHeight/1440
    534. settings.fontSize = settings.policeSize * windowHeight/1440
    535. imageSize = vec2(windowHeight/80 * settings.policeSize, windowHeight/80 * settings.policeSize)
    536. updatePos()
    537. end
    538. end
    539. local function previewMSG()
    540. ui.beginTransparentWindow("previewMSG", vec2(0, 0), vec2(windowWidth, windowHeight))
    541. ui.pushDWriteFont("Orbitron;Weight=800")
    542. local tSize = ui.measureDWriteText("Messages from Police when being chased", settings.fontSizeMSG)
    543. local uiOffsetX = settings.msgOffsetX - tSize.x/2
    544. local uiOffsetY = settings.msgOffsetY
    545. ui.drawRectFilled(vec2(uiOffsetX - 5, uiOffsetY-5), vec2(uiOffsetX + tSize.x + 5, uiOffsetY + tSize.y + 5), COLORSMSGBG)
    546. ui.dwriteDrawText("Messages from Police when being chased", settings.fontSizeMSG, vec2(uiOffsetX, uiOffsetY), rgbm.colors.cyan)
    547. ui.popDWriteFont()
    548. ui.endTransparentWindow()
    549. end
    550. local function previewStars()
    551. ui.beginTransparentWindow("previewStars", vec2(0, 0), vec2(windowWidth, windowHeight))
    552. showStarsPursuit()
    553. ui.endTransparentWindow()
    554. end
    555. local function uiTab()
    556. ui.text('On Screen Message : ')
    557. settings.timeMsg = ui.slider('##' .. 'Time Msg On Screen', settings.timeMsg, 1, 15, 'Time Msg On Screen' .. ': %.0fs')
    558. settings.fontSizeMSG = ui.slider('##' .. 'Font Size MSG', settings.fontSizeMSG, 10, 50, 'Font Size' .. ': %.0f')
    559. ui.text('Stars : ')
    560. settings.starsPos.x = ui.slider('##' .. 'Stars Offset X', settings.starsPos.x, 0, windowWidth, 'Stars Offset X' .. ': %.0f')
    561. settings.starsPos.y = ui.slider('##' .. 'Stars Offset Y', settings.starsPos.y, 0, windowHeight, 'Stars Offset Y' .. ': %.0f')
    562. settings.starsSize = ui.slider('##' .. 'Stars Size', settings.starsSize, 10, 50, 'Stars Size' .. ': %.0f')
    563. ui.newLine()
    564. ui.text('Offset : ')
    565. settings.msgOffsetY = ui.slider('##' .. 'Msg On Screen Offset Y', settings.msgOffsetY, 0, windowHeight, 'Msg On Screen Offset Y' .. ': %.0f')
    566. settings.msgOffsetX = ui.slider('##' .. 'Msg On Screen Offset X', settings.msgOffsetX, 0, windowWidth, 'Msg On Screen Offset X' .. ': %.0f')
    567. ui.newLine()
    568. ui.text('Preview : ')
    569. ui.sameLine()
    570. if ui.button('Message') then
    571. showPreviewMsg = not showPreviewMsg
    572. showPreviewStars = false
    573. end
    574. ui.sameLine()
    575. if ui.button('Stars') then
    576. showPreviewStars = not showPreviewStars
    577. showPreviewMsg = false
    578. end
    579. if showPreviewMsg then previewMSG()
    580. elseif showPreviewStars then previewStars() end
    581. if ui.button('Offset X to center') then settings.msgOffsetX = windowWidth/2 end
    582. ui.newLine()
    583. end
    584. local function settingsWindow()
    585. imageSize = vec2(windowHeight/80 * settings.policeSize, windowHeight/80 * settings.policeSize)
    586. ui.dwriteTextAligned("settings", 40, ui.Alignment.Center, ui.Alignment.Center, vec2(windowWidth/6.5,60), false, rgbm.colors.white)
    587. ui.drawLine(vec2(0,60), vec2(windowWidth/6.5,60), rgbm.colors.white, 1)
    588. ui.newLine(20)
    589. ui.sameLine(10)
    590. ui.beginGroup()
    591. ui.text('Unit : ')
    592. ui.sameLine(160)
    593. if ui.selectable('mph', settings.unit == 'mph',_, ui.measureText('km/h')) then
    594. settings.unit = 'mph'
    595. settings.unitMult = 0.621371
    596. end
    597. ui.sameLine(200)
    598. if ui.selectable('km/h', settings.unit == 'km/h',_, ui.measureText('km/h')) then
    599. settings.unit = 'km/h'
    600. settings.unitMult = 1
    601. end
    602. ui.sameLine(windowWidth/6.5 - 120)
    603. if ui.button('Close', vec2(100, windowHeight/50)) then
    604. settingsOpen = false
    605. onsettingsChange()
    606. end
    607. ui.text('HUD : ')
    608. settings.hudOffsetX = ui.slider('##' .. 'HUD Offset X', settings.hudOffsetX, 0, windowWidth, 'HUD Offset X' .. ': %.0f')
    609. settings.hudOffsetY = ui.slider('##' .. 'HUD Offset Y', settings.hudOffsetY, 0, windowHeight, 'HUD Offset Y' .. ': %.0f')
    610. settings.policeSize = ui.slider('##' .. 'HUD Size', settings.policeSize, 10, 50, 'HUD Size' .. ': %.0f')
    611. settings.fontSize = settings.policeSize * fontMultiplier
    612. ui.setNextItemWidth(300)
    613. ui.newLine()
    614. uiTab()
    615. updatePos()
    616. ui.endGroup()
    617. end
    618. ---------------------------------------------------------------------------------------------- Utils ----------------------------------------------------------------------------------------------
    619. local function formatMessage(message)
    620. local msgToSend = message
    621. if pursuit.suspect == nil then
    622. msgToSend = string.gsub(msgToSend,"`CAR`", "No Car")
    623. msgToSend = string.gsub(msgToSend,"`NAME`", "No Name")
    624. msgToSend = string.gsub(msgToSend,"`SPEED`", "No Speed")
    625. return msgToSend
    626. end
    627. msgToSend = string.gsub(msgToSend,"`CAR`", string.gsub(string.gsub(ac.getCarName(pursuit.suspect.index), "%W", " "), " ", ""))
    628. msgToSend = string.gsub(msgToSend,"`NAME`", "@" .. ac.getDriverName(pursuit.suspect.index))
    629. msgToSend = string.gsub(msgToSend,"`SPEED`", string.format("%d ", ac.getCarSpeedKmh(pursuit.suspect.index) * settings.unitMult) .. settings.unit)
    630. return msgToSend
    631. end
    632. ---------------------------------------------------------------------------------------------- HUD ----------------------------------------------------------------------------------------------
    633. local policeLightsPos = {
    634. vec2(0,0),
    635. vec2(windowWidth/10,windowHeight),
    636. vec2(windowWidth-windowWidth/10,0),
    637. vec2(windowWidth,windowHeight)
    638. }
    639. local function showPoliceLights()
    640. local timing = math.floor(os.clock()*2 % 2)
    641. if timing == 0 then
    642. ui.drawRectFilledMultiColor(policeLightsPos[1], policeLightsPos[2], rgbm(1,0,0,0.5), rgbm(0,0,0,0), rgbm(0,0,0,0), rgbm(1,0,0,0.5))
    643. ui.drawRectFilledMultiColor(policeLightsPos[3], policeLightsPos[4], rgbm(0,0,0,0), rgbm(0,0,1,0.5), rgbm(0,0,1,0.5), rgbm(0,0,0,0))
    644. else
    645. ui.drawRectFilledMultiColor(policeLightsPos[1], policeLightsPos[2], rgbm(0,0,1,0.5), rgbm(0,0,0,0), rgbm(0,0,0,0), rgbm(0,0,1,0.5))
    646. ui.drawRectFilledMultiColor(policeLightsPos[3], policeLightsPos[4], rgbm(0,0,0,0), rgbm(1,0,0,0.5), rgbm(1,0,0,0.5), rgbm(0,0,0,0))
    647. end
    648. end
    649. local chaseLVL = {
    650. message = "",
    651. messageTimer = 0,
    652. color = rgbm(1,1,1,1),
    653. }
    654. local function resetChase()
    655. pursuit.enable = false
    656. pursuit.nextMessage = 30
    657. pursuit.lostSight = false
    658. pursuit.timeLostSight = 2
    659. end
    660. local function lostSuspect()
    661. resetChase()
    662. pursuit.lostSight = false
    663. pursuit.timeLostSight = 0
    664. pursuit.level = 1
    665. ac.sendChatMessage(formatMessage(msgLost.msg[math.random(#msgLost.msg)]))
    666. pursuit.suspect = nil
    667. if cspAboveP218 then
    668. ac.setExtraSwitch(0, false)
    669. end
    670. end
    671. local iconsColorOn = {
    672. [1] = rgbm(1,0,0,1),
    673. [2] = rgbm(1,1,1,1),
    674. [3] = rgbm(1,1,1,1),
    675. [4] = rgbm(1,1,1,1),
    676. [5] = rgbm(1,1,1,1),
    677. [6] = rgbm(1,1,1,1),
    678. }
    679. local playersInRange = {}
    680. local function drawImage()
    681. iconsColorOn[2] = rgbm(0.99,0.99,0.99,1)
    682. iconsColorOn[3] = rgbm(0.99,0.99,0.99,1)
    683. iconsColorOn[4] = rgbm(0.99,0.99,0.99,1)
    684. iconsColorOn[5] = rgbm(0.99,0.99,0.99,1)
    685. iconsColorOn[6] = rgbm(0.99,0.99,0.99,1)
    686. local uiStats = ac.getUI()
    687. if ui.rectHovered(iconPos.arrest2, iconPos.arrest1) then
    688. iconsColorOn[2] = rgbm(1,0,0,1)
    689. if pursuit.suspect and pursuit.suspect.speedKmh < 50 and car.speedKmh < 20 and uiStats.isMouseLeftKeyClicked then
    690. pursuit.hasArrested = true
    691. end
    692. elseif ui.rectHovered(iconPos.cams2, iconPos.cams1) then
    693. iconsColorOn[3] = rgbm(1,0,0,1)
    694. if uiStats.isMouseLeftKeyClicked then
    695. if camerasOpen then camerasOpen = false
    696. else
    697. camerasOpen = true
    698. arrestLogsOpen = false
    699. if settingsOpen then
    700. onsettingsChange()
    701. settingsOpen = false
    702. end
    703. end
    704. end
    705. elseif ui.rectHovered(iconPos.lost2, iconPos.lost1) then
    706. iconsColorOn[4] = rgbm(1,0,0,1)
    707. if pursuit.suspect and uiStats.isMouseLeftKeyClicked then
    708. lostSuspect()
    709. end
    710. elseif ui.rectHovered(iconPos.logs2, iconPos.logs1) then
    711. iconsColorOn[5] = rgbm(1,0,0,1)
    712. if uiStats.isMouseLeftKeyClicked then
    713. if arrestLogsOpen then arrestLogsOpen = false
    714. else
    715. arrestLogsOpen = true
    716. camerasOpen = false
    717. if settingsOpen then
    718. onsettingsChange()
    719. settingsOpen = false
    720. end
    721. end
    722. end
    723. elseif ui.rectHovered(iconPos.menu2, iconPos.menu1) then
    724. iconsColorOn[6] = rgbm(1,0,0,1)
    725. if uiStats.isMouseLeftKeyClicked then
    726. if settingsOpen then
    727. onsettingsChange()
    728. settingsOpen = false
    729. else
    730. settingsOpen = true
    731. arrestLogsOpen = false
    732. camerasOpen = false
    733. end
    734. end
    735. end
    736. ui.image(hudImg.base, imageSize, rgbm.colors.white)
    737. ui.drawImage(hudImg.radar, vec2(0,0), imageSize, iconsColorOn[1])
    738. ui.drawImage(hudImg.arrest, vec2(0,0), imageSize, iconsColorOn[2])
    739. ui.drawImage(hudImg.cams, vec2(0,0), imageSize, iconsColorOn[3])
    740. ui.drawImage(hudImg.lost, vec2(0,0), imageSize, iconsColorOn[4])
    741. ui.drawImage(hudImg.logs, vec2(0,0), imageSize, iconsColorOn[5])
    742. ui.drawImage(hudImg.menu, vec2(0,0), imageSize, iconsColorOn[6])
    743. end
    744. local function playerSelected(player)
    745. if player.speedKmh > 50 then
    746. pursuit.suspect = player
    747. pursuit.nextMessage = 30
    748. pursuit.level = 1
    749. local msgToSend = "Officer " .. ac.getDriverName(0) .. " is chasing you. Run! "
    750. pursuit.startedTime = settings.timeMsg
    751. pursuit.engage = true
    752. acpPolice{message = msgToSend, messageType = 0, yourIndex = ac.getCar(pursuit.suspect.index).sessionID}
    753. if cspAboveP218 then
    754. ac.setExtraSwitch(0, true)
    755. end
    756. end
    757. end
    758. local function hudInChase()
    759. ui.pushDWriteFont("Orbitron;Weight=Black")
    760. ui.sameLine(20)
    761. ui.beginGroup()
    762. ui.newLine(1)
    763. local textPursuit = "LVL : " .. math.floor(pursuit.level/2)
    764. ui.dwriteTextWrapped(ac.getDriverName(pursuit.suspect.index) .. '\n'
    765. .. string.gsub(string.gsub(ac.getCarName(pursuit.suspect.index), "%W", " "), " ", "")
    766. .. '\n' .. string.format("Speed: %d ", pursuit.suspect.speedKmh * settings.unitMult) .. settings.unit
    767. .. '\n' .. textPursuit, settings.fontSize/2, rgbm.colors.white)
    768. ui.dummy(vec2(imageSize.x/5,imageSize.y/20))
    769. ui.newLine(30)
    770. ui.sameLine()
    771. if ui.button('Cancel Chase', vec2(imageSize.x/5, imageSize.y/20)) then
    772. lostSuspect()
    773. end
    774. ui.endGroup()
    775. ui.popDWriteFont()
    776. end
    777. local function drawText()
    778. local uiStats = ac.getUI()
    779. ui.pushDWriteFont("Orbitron;Weight=Bold")
    780. ui.dwriteDrawText("RADAR ACTIVE", settings.fontSize/2, vec2((textPos.box2.x - ui.measureDWriteText("RADAR ACTIVE", settings.fontSize/2).x)/2, 0), rgbm(1,0,0,1))
    781. ui.popDWriteFont()
    782. ui.pushDWriteFont("Orbitron;Weight=Regular")
    783. ui.dwriteDrawText("NEARBY VEHICULE SPEED SCANNING", settings.fontSize/3, vec2((textPos.box2.x - ui.measureDWriteText("NEARBY VEHICULE SPEED SCANNING", settings.fontSize/3).x)/2, settings.fontSize/1.5), rgbm(1,0,0,1))
    784. local colorText = rgbm(1,1,1,1)
    785. textPos.box1 = vec2(0, textSize.size.y*2.5)
    786. ui.dummy(vec2(textPos.box2.x,settings.fontSize))
    787. for i = 1, #playersInRange do
    788. colorText = rgbm(1,1,1,1)
    789. ui.drawRect(vec2(textPos.box2.x/9,textPos.box1.y), vec2(textPos.box2.x*8/9, textPos.box1.y + textPos.box2.y), rgbm(1,1,1,0.1), 1)
    790. if ui.rectHovered(textPos.box1, textPos.box1 + textPos.box2) then
    791. colorText = rgbm(1,0,0,1)
    792. if uiStats.isMouseLeftKeyClicked then
    793. playerSelected(playersInRange[i].player)
    794. end
    795. end
    796. ui.dwriteDrawText(playersInRange[i].text, settings.fontSize/2, vec2((textPos.box2.x - ui.measureDWriteText(ac.getDriverName(playersInRange[i].player.index) .. " - 000 " .. settings.unit, settings.fontSize/2).x)/2, textPos.box1.y + textSize.size.y/5), colorText)
    797. textPos.box1 = textPos.box1 + textPos.addBox
    798. ui.dummy(vec2(textPos.box2.x, i * settings.fontSize/5))
    799. end
    800. ui.popDWriteFont()
    801. end
    802. local function radarUI()
    803. ui.toolWindow('radarText', textSize.window1, textSize.window2, true, function ()
    804. ui.childWindow('childradar', textSize.window2, true , function ()
    805. if pursuit.suspect then hudInChase()
    806. else drawText() end
    807. end)
    808. end)
    809. ui.transparentWindow('radar', vec2(settings.hudOffsetX, settings.hudOffsetY), imageSize, true, function ()
    810. drawImage()
    811. end)
    812. end
    813. local function hidePlayers()
    814. local hideRange = 500
    815. for i = ac.getSim().carsCount - 1, 0, -1 do
    816. local player = ac.getCar(i)
    817. local playerCarID = ac.getCarID(i)
    818. if player.isConnected and ac.getCarBrand(i) ~= "traffic" then
    819. if playerCarID ~= valideCar[1] and playerCarID ~= valideCar[2] and playerCarID ~= valideCar[3] then
    820. if player.position.x > car.position.x - hideRange and player.position.z > car.position.z - hideRange and player.position.x < car.position.x + hideRange and player.position.z < car.position.z + hideRange then
    821. ac.hideCarLabels(i, false)
    822. else
    823. ac.hideCarLabels(i, true)
    824. end
    825. end
    826. end
    827. end
    828. end
    829. local function radarUpdate()
    830. if firstload and not pursuit.suspect then return end
    831. local radarRange = 250
    832. local previousSize = #playersInRange
    833. local j = 1
    834. for i = ac.getSim().carsCount - 1, 0, -1 do
    835. local player = ac.getCar(i)
    836. local playerCarID = ac.getCarID(i)
    837. if player.isConnected and ac.getCarBrand(i) ~= "traffic" then
    838. if playerCarID ~= valideCar[1] and playerCarID ~= valideCar[2] and playerCarID ~= valideCar[3] then
    839. if player.position.x > car.position.x - radarRange and player.position.z > car.position.z - radarRange and player.position.x < car.position.x + radarRange and player.position.z < car.position.z + radarRange then
    840. playersInRange[j] = {}
    841. playersInRange[j].player = player
    842. playersInRange[j].text = ac.getDriverName(player.index) .. string.format(" - %d ", player.speedKmh * settings.unitMult) .. settings.unit
    843. j = j + 1
    844. if j == 9 then break end
    845. end
    846. end
    847. end
    848. end
    849. for i = j, previousSize do playersInRange[i] = nil end
    850. end
    851. ---------------------------------------------------------------------------------------------- Chase ----------------------------------------------------------------------------------------------
    852. local function inRange()
    853. local distance_x = pursuit.suspect.position.x - car.position.x
    854. local distance_z = pursuit.suspect.position.z - car.position.z
    855. local distanceSquared = distance_x * distance_x + distance_z * distance_z
    856. if(distanceSquared < pursuit.minDistance) then
    857. pursuit.enable = true
    858. pursuit.lostSight = false
    859. pursuit.timeLostSight = 2
    860. elseif (distanceSquared < pursuit.maxDistance) then resetChase()
    861. else
    862. if not pursuit.lostSight then
    863. pursuit.lostSight = true
    864. pursuit.timeLostSight = 2
    865. else
    866. pursuit.timeLostSight = pursuit.timeLostSight - ui.deltaTime()
    867. if pursuit.timeLostSight < 0 then lostSuspect() end
    868. end
    869. end
    870. end
    871. local function sendChatToSuspect()
    872. if pursuit.enable then
    873. if 0 < pursuit.nextMessage then
    874. pursuit.nextMessage = pursuit.nextMessage - ui.deltaTime()
    875. elseif pursuit.nextMessage < 0 then
    876. local nb = tostring(pursuit.level)
    877. acpPolice{message = nb, messageType = 1, yourIndex = ac.getCar(pursuit.suspect.index).sessionID}
    878. if pursuit.level < 10 then
    879. pursuit.level = pursuit.level + 1
    880. chaseLVL.messageTimer = settings.timeMsg
    881. chaseLVL.message = "CHASE LEVEL " .. math.floor(pursuit.level/2)
    882. if pursuit.level > 8 then
    883. chaseLVL.color = rgbm.colors.red
    884. elseif pursuit.level > 6 then
    885. chaseLVL.color = rgbm.colors.orange
    886. elseif pursuit.level > 4 then
    887. chaseLVL.color = rgbm.colors.yellow
    888. else
    889. chaseLVL.color = rgbm.colors.white
    890. end
    891. end
    892. pursuit.nextMessage = 30
    893. end
    894. end
    895. end
    896. local function showPursuitMsg()
    897. local text = ""
    898. if chaseLVL.messageTimer > 0 then
    899. chaseLVL.messageTimer = chaseLVL.messageTimer - ui.deltaTime()
    900. text = chaseLVL.message
    901. end
    902. if pursuit.startedTime > 0 then
    903. if pursuit.suspect then
    904. text = "You are chasing " .. ac.getDriverName(pursuit.suspect.index) .. " driving a " .. string.gsub(string.gsub(ac.getCarName(pursuit.suspect.index), "%W", " "), " ", "") .. " ! Get him! "
    905. end
    906. if pursuit.startedTime > 6 then showPoliceLights() end
    907. if pursuit.engage and pursuit.startedTime < 8 then
    908. ac.sendChatMessage(formatMessage(msgEngage.msg[math.random(#msgEngage.msg)]))
    909. pursuit.engage = false
    910. end
    911. end
    912. if text ~= "" then
    913. local textLenght = ui.measureDWriteText(text, settings.fontSizeMSG)
    914. local rectPos1 = vec2(settings.msgOffsetX - textLenght.x/2, settings.msgOffsetY)
    915. local rectPos2 = vec2(settings.msgOffsetX + textLenght.x/2, settings.msgOffsetY + settings.fontSizeMSG)
    916. local rectOffset = vec2(10, 10)
    917. if ui.time() % 1 < 0.5 then
    918. ui.drawRectFilled(rectPos1 - vec2(10,0), rectPos2 + rectOffset, COLORSMSGBG, 10)
    919. else
    920. ui.drawRectFilled(rectPos1 - vec2(10,0), rectPos2 + rectOffset, rgbm(0,0,0,0.5), 10)
    921. end
    922. ui.dwriteDrawText(text, settings.fontSizeMSG, rectPos1, chaseLVL.color)
    923. end
    924. end
    925. local function arrestSuspect()
    926. if pursuit.hasArrested and pursuit.suspect then
    927. local msgToSend = formatMessage(msgArrest.msg[math.random(#msgArrest.msg)])
    928. table.insert(arrestations, msgToSend .. os.date("\nDate of the Arrestation: %c"))
    929. ac.sendChatMessage(msgToSend .. "\nPlease Get Back Pit, GG!")
    930. pursuit.id = pursuit.suspect.sessionID
    931. if playerData.Arrests == nil then playerData.Arrests = 0 end
    932. playerData.Arrests = playerData.Arrests + 1
    933. pursuit.startedTime = 0
    934. pursuit.suspect = nil
    935. pursuit.timerArrest = 1
    936. elseif pursuit.hasArrested then
    937. if pursuit.timerArrest > 0 then
    938. pursuit.timerArrest = pursuit.timerArrest - ui.deltaTime()
    939. else
    940. acpPolice{message = "BUSTED!", messageType = 2, yourIndex = pursuit.id}
    941. pursuit.timerArrest = 0
    942. pursuit.suspect = nil
    943. pursuit.id = -1
    944. pursuit.hasArrested = false
    945. pursuit.startedTime = 0
    946. pursuit.enable = false
    947. pursuit.level = 1
    948. pursuit.nextMessage = 20
    949. pursuit.lostSight = false
    950. pursuit.timeLostSight = 0
    951. local data = {
    952. ["Arrests"] = playerData.Arrests,
    953. }
    954. updatefirebase()
    955. updatefirebaseData("Arrests", data)
    956. end
    957. end
    958. end
    959. local function chaseUpdate()
    960. if pursuit.startedTime > 0 then pursuit.startedTime = pursuit.startedTime - ui.deltaTime()
    961. else pursuit.startedTime = 0 end
    962. if pursuit.suspect then
    963. sendChatToSuspect()
    964. inRange()
    965. end
    966. arrestSuspect()
    967. end
    968. ---------------------------------------------------------------------------------------------- Menu ----------------------------------------------------------------------------------------------
    969. local function arrestLogsUI()
    970. ui.dwriteTextAligned("Arrestation Logs", 40, ui.Alignment.Center, ui.Alignment.Center, vec2(windowWidth/4,60), false, rgbm.colors.white)
    971. ui.drawLine(vec2(0,60), vec2(windowWidth/4,60), rgbm.colors.white, 1)
    972. ui.newLine(15)
    973. ui.sameLine(10)
    974. ui.beginGroup()
    975. local allMsg = ""
    976. ui.dwriteText("Click on the button next to the message you want to copy.", 15, rgbm.colors.white)
    977. ui.sameLine(windowWidth/4 - 120)
    978. if ui.button('Close', vec2(100, windowHeight/50)) then arrestLogsOpen = false end
    979. for i = 1, #arrestations do
    980. if ui.smallButton("#" .. i .. ": ", vec2(0,10)) then
    981. ui.setClipboardText(arrestations[i])
    982. end
    983. ui.sameLine()
    984. ui.dwriteTextWrapped(arrestations[i], 15, rgbm.colors.white)
    985. end
    986. if #arrestations == 0 then
    987. ui.dwriteText("No arrestation logs yet.", 15, rgbm.colors.white)
    988. end
    989. ui.newLine()
    990. if ui.button("Set all messages to ClipBoard") then
    991. for i = 1, #arrestations do
    992. allMsg = allMsg .. arrestations[i] .. "\n\n"
    993. end
    994. ui.setClipboardText(allMsg)
    995. end
    996. ui.endGroup()
    997. end
    998. local buttonPos = windowWidth/65
    999. local function camerasUI()
    1000. ui.dwriteTextAligned("Surveillance Cameras", 40, ui.Alignment.Center, ui.Alignment.Center, vec2(windowWidth/6.5,60), false, rgbm.colors.white)
    1001. ui.drawLine(vec2(0,60), vec2(windowWidth/6.5,60), rgbm.colors.white, 1)
    1002. ui.newLine(20)
    1003. ui.beginGroup()
    1004. ui.sameLine(buttonPos)
    1005. if ui.button('Close', vec2(windowWidth/6.5 - buttonPos*2,30)) then camerasOpen = false end
    1006. ui.newLine()
    1007. for i = 1, #cameras do
    1008. local h = math.rad(cameras[i].dir + ac.getCompassAngle(vec3(0, 0, 1)))
    1009. ui.newLine()
    1010. ui.sameLine(buttonPos)
    1011. if ui.button(cameras[i].name, vec2(windowWidth/6.5 - buttonPos*2,30)) then
    1012. ac.setCurrentCamera(ac.CameraMode.Free)
    1013. ac.setCameraPosition(cameras[i].pos)
    1014. ac.setCameraDirection(vec3(math.sin(h), 0, math.cos(h)))
    1015. ac.setCameraFOV(cameras[i].fov)
    1016. end
    1017. end
    1018. if ac.getSim().cameraMode == ac.CameraMode.Free then
    1019. ui.newLine()
    1020. ui.newLine()
    1021. ui.sameLine(buttonPos)
    1022. if ui.button('Police car camera', vec2(windowWidth/6.5 - buttonPos*2,30)) then ac.setCurrentCamera(ac.CameraMode.Cockpit) end
    1023. end
    1024. end
    1025. local initialized = false
    1026. local menuSize = {vec2(windowWidth/4, windowHeight/3), vec2(windowWidth/6.4, windowHeight/2.2)}
    1027. local buttonPressed = false
    1028. local function moveMenu()
    1029. if ui.windowHovered() and ui.mouseDown() then buttonPressed = true end
    1030. if ui.mouseReleased() then buttonPressed = false end
    1031. if buttonPressed then settings.menuPos = settings.menuPos + ui.mouseDelta() end
    1032. end
    1033. ---------------------------------------------------------------------------------------------- updates ----------------------------------------------------------------------------------------------
    1034. function script.drawUI()
    1035. if carID ~= valideCar[1] and carID ~= valideCar[2] and carID ~= valideCar[3] or cspVersion < cspMinVersion then return end
    1036. if initialized and settings.policeSize then
    1037. if firstload then
    1038. firstload = false
    1039. initsettings()
    1040. end
    1041. radarUI()
    1042. if pursuit.suspect then showStarsPursuit() end
    1043. showPursuitMsg()
    1044. if settingsOpen then
    1045. ui.toolWindow('settings', settings.menuPos, menuSize[2], true, function ()
    1046. ui.childWindow('childsettings', menuSize[2], true, function () settingsWindow() moveMenu() end)
    1047. end)
    1048. elseif arrestLogsOpen then
    1049. ui.toolWindow('ArrestLogs', settings.menuPos, menuSize[1], true, function ()
    1050. ui.childWindow('childArrestLogs', menuSize[1], true, function () arrestLogsUI() moveMenu() end)
    1051. end)
    1052. elseif camerasOpen then
    1053. ui.toolWindow('Cameras', settings.menuPos, menuSize[2], true, function ()
    1054. ui.childWindow('childCameras', menuSize[2], true, function () camerasUI() moveMenu() end)
    1055. end)
    1056. end
    1057. end
    1058. end
    1059. ac.onCarJumped(0, function (carid)
    1060. if carID == valideCar[1] or carID == valideCar[2] or carID == valideCar[3]then
    1061. if pursuit.suspect then lostSuspect() end
    1062. end
    1063. end)
    1064. function script.update(dt)
    1065. if carID ~= valideCar[1] and carID ~= valideCar[2] and carID ~= valideCar[3] or cspVersion < cspMinVersion then return end
    1066. if not initialized then
    1067. loadsettings()
    1068. getFirebase()
    1069. initialized = true
    1070. else
    1071. radarUpdate()
    1072. chaseUpdate()
    1073. --hidePlayers()
    1074. end
    1075. end
    1076. if carID == valideCar[1] or carID == valideCar[2] or carID == valideCar[3] and cspVersion >= cspMinVersion then
    1077. ui.registerOnlineExtra(ui.Icons.Settings, "Settings", nil, settingsWindow, nil, ui.OnlineExtraFlags.Tool, 'ui.WindowFlags.AlwaysAutoResize')
    1078. end
    Tags: dz
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /