Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.64 KB | None | 0 0
  1. local Keys = {
  2. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  3. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  4. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  5. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  6. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  7. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  8. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  9. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  10. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  11. }
  12.  
  13. ESX = nil
  14.  
  15. local cardOpen = false
  16. local playerData = {}
  17. local windowavg = false
  18. local windowavd = false
  19. local windowarg = false
  20. local windoward = false
  21. local window = false
  22. local engineOn = true
  23. local speedkm = 0
  24.  
  25.  
  26. -- Servern callback
  27. RegisterNetEvent('jsfour-legitimation:open')
  28. AddEventHandler('jsfour-legitimation:open', function(playerData)
  29. cardOpen = true
  30. SendNUIMessage({
  31. action = "open",
  32. array = playerData
  33. })
  34. end)
  35.  
  36. Citizen.CreateThread(function()
  37. while ESX == nil do
  38. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  39. Citizen.Wait(0)
  40. end
  41. end)
  42.  
  43. RegisterNetEvent('esx:playerLoaded')
  44. AddEventHandler('esx:playerLoaded', function(xPlayer)
  45. PlayerData = xPlayer
  46. end)
  47.  
  48. -- Giving ID Animation
  49. function OpenGivingID()
  50. local pP = GetPlayerPed(-1)
  51.  
  52. Citizen.CreateThread(function()
  53.  
  54. local pP = GetPlayerPed(-1)
  55. TaskPlayAnim(pP, "mp_common", "givetake1_a", 3.5, -8, -1, 2, 0, 0, 0, 0, 0)
  56. Citizen.CreateThread(function()
  57. Citizen.Wait(10000)
  58. TriggerServerEvent('esx_personmeny:give_id')
  59. ClearPedTasksImmediately(pP)
  60. end)
  61. end)
  62. end
  63.  
  64. -- No one Near Animation
  65. function OpenNoOneNear()
  66. local pP = GetPlayerPed(-1)
  67.  
  68. Citizen.CreateThread(function()
  69.  
  70. local pP = GetPlayerPed(-1)
  71. TaskPlayAnim(pP, "anim@mp_player_intcelebrationmale@face_palm", "face_palm", 3.5, -8, -1, 2, 0, 0, 0, 0, 0)
  72. Citizen.CreateThread(function()
  73. Citizen.Wait(1000)
  74. TriggerServerEvent('esx_personmeny:idnoonenear')
  75. ClearPedTasksImmediately(pP)
  76. end)
  77. end)
  78. end
  79.  
  80. function OpenTrashCan()
  81. local pP = GetPlayerPed(-1)
  82.  
  83. Citizen.CreateThread(function()
  84.  
  85. local pP = GetPlayerPed(-1)
  86. TaskPlayAnim(pP, "mp_common", "givetake2_a", 3.5, -8, -1, 2, 0, 0, 0, 0, 0)
  87. TaskStartScenarioInPlace(pP, "mp_common", 0, true)
  88. Citizen.CreateThread(function()
  89. Citizen.Wait(2000)
  90. ClearPedTasksImmediately(pP)
  91. end)
  92. end)
  93. end
  94.  
  95. function OpenAttansCan()
  96. local pP = GetPlayerPed(-1)
  97.  
  98. Citizen.CreateThread(function()
  99.  
  100. local pP = GetPlayerPed(-1)
  101. TaskPlayAnim(pP, "gestures@m@standing@casual", "gesture_damn", 3.5, -8, -1, 2, 0, 0, 0, 0, 0)
  102. TaskStartScenarioInPlace(pP, "gestures@m@standing@casual", 0, true)
  103. FreezeEntityPosition(playerPed, true)
  104. Citizen.CreateThread(function()
  105. Citizen.Wait(2000)
  106. FreezeEntityPosition(playerPed, false)
  107. ClearPedTasksImmediately(pP)
  108. end)
  109. end)
  110. end
  111.  
  112. function OpenShowGiveID()
  113.  
  114. ESX.UI.Menu.Open(
  115. 'default', GetCurrentResourceName(), 'id_card_menu',
  116. {
  117. title = 'ID menu',
  118. elements = {
  119. {label = 'Check your ID', value = 'checkID'},
  120. {label = 'Show your ID', value = 'showID'},
  121. {label = 'Check your driver license', value = 'checkDriver'},
  122. {label = 'Show your driver license', value = 'showDriver'},
  123. {label = 'Check your firearms license', value = 'checkFirearms'},
  124. {label = 'Show your firearms license', value = 'showFirearms'},
  125. }
  126. },
  127.  
  128. function(data2, menu2)
  129. local player, distance = ESX.Game.GetClosestPlayer()
  130.  
  131. if data2.current.value == 'checkID' then
  132. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
  133. elseif data2.current.value == 'checkDriver' then
  134. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')
  135. elseif data2.current.value == 'checkFirearms' then
  136. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'weapon')
  137. end
  138.  
  139. if distance ~= -1 and distance <= 3.0 then
  140. if data2.current.value == 'showID' then
  141. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
  142. elseif data2.current.value == 'showDriver' then
  143. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
  144. elseif data2.current.value == 'showFirearms' then
  145. TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'weapon')
  146. end
  147. OpenTrashCan()
  148. else
  149. OpenAttansCan()
  150. ESX.ShowNotification(_U('nobody_near'))
  151. end
  152. end,
  153. function(data2, menu2)
  154. menu2.close()
  155. end
  156. )
  157.  
  158. end
  159.  
  160. function OpenCivilianActionsMenu()
  161.  
  162. ESX.UI.Menu.CloseAll()
  163.  
  164. ESX.UI.Menu.Open(
  165. 'default', GetCurrentResourceName(), 'civilian_actions',
  166. {
  167. title = _U('citizen_interactions'),
  168. align = 'top-left',
  169. elements = {
  170. {label = _U('vehicle_menu'), value = 'vehiclemenu'},
  171. {label = _U('id_card'), value = 'id_kort'},
  172. {label = _U('blindfold'), value = 'blindfold'},
  173. }
  174. },
  175.  
  176. function(data, menu)
  177.  
  178. if data.current.value == 'id_kort' then
  179. OpenShowGiveID()
  180. end
  181.  
  182. if data.current.value == 'blindfold' then
  183. local player, distance = ESX.Game.GetClosestPlayer()
  184.  
  185. if distance ~= -1 and distance <= 3.0 then
  186. ESX.TriggerServerCallback('jsfour-blindfold:itemCheck', function( hasItem )
  187. TriggerServerEvent('jsfour-blindfold', GetPlayerServerId(player), hasItem)
  188. end)
  189. else
  190. ESX.ShowAdvancedNotification('Individåtgärder', '~b~Ögonbindel', _U('nobody_near'), 'CHAR_DEFAULT', 8)
  191. end
  192. end
  193.  
  194. if data.current.value == 'vehiclemenu' then
  195. local playerPed = GetPlayerPed(-1)
  196. if IsPedSittingInAnyVehicle(playerPed) then
  197. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  198. local drivingPed = GetPedInVehicleSeat(playerVeh, -1)
  199. if drivingPed == playerPed then
  200. OpenVehicleMenu()
  201. end
  202. end
  203. end
  204.  
  205. if data.current.value == 'check' then
  206. TriggerServerEvent('jsfour-legitimation:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
  207. elseif data.current.value == 'show' then
  208. local player, distance = ESX.Game.GetClosestPlayer()
  209.  
  210. if distance ~= -1 and distance <= 3.0 then
  211. TriggerServerEvent('jsfour-legitimation:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
  212. else
  213. ESX.ShowAdvancedNotification('Individåtgärder', '', _U('nobody_near'), 'CHAR_DEFAULT', 8)
  214. end
  215. end
  216. end,
  217. function(data, menu)
  218. menu.close()
  219. end
  220. )
  221. end
  222.  
  223. function OpenVehicleMenu()
  224.  
  225. ESX.UI.Menu.CloseAll()
  226.  
  227. ESX.UI.Menu.Open(
  228. 'default', GetCurrentResourceName(), 'vehicle_actions',
  229. {
  230. title = _U('vehicle_menu'),
  231. align = 'top-left',
  232. elements = {
  233. {label = _U('engine'), value = 'engine'},
  234. {label = _U('doors'), value = 'door'},
  235. {label = _U('window'), value = 'window'},
  236. }
  237. },
  238. function(data, menu)
  239. if data.current.value == 'engine' then
  240. local playerPed = GetPlayerPed(-1)
  241. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  242. if engineOn == true then
  243. SetVehicleUndriveable(playerVeh, true)
  244. SetVehicleEngineOn(playerVeh, false, false, false)
  245. engineOn = false
  246. TriggerEvent("pNotify:SendNotification", {text = _U('turned_off_engine'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  247. else
  248. SetVehicleUndriveable(playerVeh, false)
  249. SetVehicleEngineOn(playerVeh, true, false, false)
  250. engineOn = true
  251. TriggerEvent("pNotify:SendNotification", {text = _U('turned_on_engine'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  252. end
  253. end
  254.  
  255. if data.current.value == 'changeseat' then
  256. TriggerEvent("SeatShuffle")
  257. end
  258.  
  259. if data.current.value == 'door' then
  260. ESX.UI.Menu.CloseAll()
  261.  
  262. ESX.UI.Menu.Open(
  263. 'default', GetCurrentResourceName(), 'door_actions',
  264. {
  265. title = _U('doors'),
  266. align = 'top-left',
  267. elements = {
  268. {label = _U('hood'), value = 'hood'},
  269. {label = _U('trunk'), value = 'trunk'},
  270. {label = _U('front_left_door'), value = 'dooravg'},
  271. {label = _U('front_right_door'), value = 'dooravd'},
  272. {label = _U('back_left_door'), value = 'doorarg'},
  273. {label = _U('back_right_door'), value = 'doorard'}
  274. }
  275. },
  276. function(data, menu)
  277. if data.current.value == 'hood' then
  278. local playerPed = GetPlayerPed(-1)
  279. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  280. if (IsPedSittingInAnyVehicle(playerPed)) then
  281. if GetVehicleDoorAngleRatio(playerVeh, 4) > 0.0 then
  282. SetVehicleDoorShut(playerVeh, 4, false)
  283. TriggerEvent("pNotify:SendNotification", {text = "Du stängde motorhuv!", type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  284. else
  285. SetVehicleDoorOpen(playerVeh, 4, false)
  286. frontleft = true
  287. TriggerEvent("pNotify:SendNotification", {text = "Du öppnade motorhuv!", type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  288. end
  289. end
  290. end
  291. if data.current.value == 'trunk' then
  292. local playerPed = GetPlayerPed(-1)
  293. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  294. if ( IsPedSittingInAnyVehicle( playerPed ) ) then
  295. if GetVehicleDoorAngleRatio(playerVeh, 5) > 0.0 then
  296. SetVehicleDoorShut(playerVeh, 5, false)
  297. TriggerEvent("pNotify:SendNotification", {text = _U('closed_hood'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  298. else
  299. SetVehicleDoorOpen(playerVeh, 5, false)
  300. frontleft = true
  301. TriggerEvent("pNotify:SendNotification", {text = _U('opened_hood'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  302. end
  303. end
  304. end
  305. if data.current.value == 'dooravg' then
  306. local playerPed = GetPlayerPed(-1)
  307. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  308. if ( IsPedSittingInAnyVehicle( playerPed ) ) then
  309. if GetVehicleDoorAngleRatio(playerVeh, 0) > 0.0 then
  310. SetVehicleDoorShut(playerVeh, 0, false)
  311. TriggerEvent("pNotify:SendNotification", {text = _U('closed_door'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  312. else
  313. SetVehicleDoorOpen(playerVeh, 0, false)
  314. frontleft = true
  315. TriggerEvent("pNotify:SendNotification", {text = _U('opened_door'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  316. end
  317. end
  318. end
  319. if data.current.value == 'dooravd' then
  320. local playerPed = GetPlayerPed(-1)
  321. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  322. if ( IsPedSittingInAnyVehicle( playerPed ) ) then
  323. if GetVehicleDoorAngleRatio(playerVeh, 1) > 0.0 then
  324. SetVehicleDoorShut(playerVeh, 1, false)
  325. TriggerEvent("pNotify:SendNotification", {text = _U('closed_door'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  326. else
  327. SetVehicleDoorOpen(playerVeh, 1, false)
  328. frontleft = true
  329. TriggerEvent("pNotify:SendNotification", {text = _U('opened_door'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  330. end
  331. end
  332. end
  333. if data.current.value == 'doorarg' then
  334. local playerPed = GetPlayerPed(-1)
  335. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  336. if ( IsPedSittingInAnyVehicle( playerPed ) ) then
  337. if GetVehicleDoorAngleRatio(playerVeh, 2) > 0.0 then
  338. SetVehicleDoorShut(playerVeh, 2, false)
  339. TriggerEvent("pNotify:SendNotification", {text = _U('closed_door'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  340. else
  341. SetVehicleDoorOpen(playerVeh, 2, false)
  342. frontleft = true
  343. TriggerEvent("pNotify:SendNotification", {text = _U('opened_door'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  344. end
  345. end
  346. end
  347. if data.current.value == 'doorard' then
  348. local playerPed = GetPlayerPed(-1)
  349. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  350. if ( IsPedSittingInAnyVehicle( playerPed ) ) then
  351. if GetVehicleDoorAngleRatio(playerVeh, 3) > 0.0 then
  352. SetVehicleDoorShut(playerVeh, 3, false)
  353. TriggerEvent("pNotify:SendNotification", {text = _U('closed_door'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  354. else
  355. SetVehicleDoorOpen(playerVeh, 3, false)
  356. frontleft = true
  357. TriggerEvent("pNotify:SendNotification", {text = _U('opened_door'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  358. end
  359. end
  360. end
  361. end,
  362. function(data, menu)
  363. menu.close()
  364. OpenVehicleMenu()
  365. end
  366. )
  367. end
  368. if data.current.value == 'window' then
  369. ESX.UI.Menu.CloseAll()
  370.  
  371. ESX.UI.Menu.Open(
  372. 'default', GetCurrentResourceName(), 'window_actions',
  373. {
  374. title = _U('window_menu'),
  375. align = 'top-left',
  376. elements = {
  377. {label = _U('front_left_window'), value = 'windowavga'},
  378. {label = _U('front_right_window'), value = 'windowavdr'},
  379. {label = _U('back_left_window'), value = 'windowarga'},
  380. {label = _U('back_right_window'), value = 'windowardr'}
  381. }
  382. },
  383. function(data, menu)
  384. if data.current.value == 'windowavga' then
  385. local playerPed = GetPlayerPed(-1)
  386. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  387. if windowavg == false then
  388. RollDownWindow(playerVeh, 0)
  389. windowavg = true
  390. TriggerEvent("pNotify:SendNotification", {text = _U('opened_window'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  391. else
  392. RollUpWindow(playerVeh, 0)
  393. windowavg = false
  394. TriggerEvent("pNotify:SendNotification", {text = _U('closed_wondow'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  395. end
  396. end
  397. if data.current.value == 'windowavdr' then
  398. local playerPed = GetPlayerPed(-1)
  399. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  400. if windowavd == false then
  401. RollDownWindow(playerVeh, 1)
  402. windowavd = true
  403. TriggerEvent("pNotify:SendNotification", {text = _U('opened_window'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  404. else
  405. RollUpWindow(playerVeh, 1)
  406. windowavd = false
  407. TriggerEvent("pNotify:SendNotification", {text = _U('closed_wondow'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  408. end
  409. end
  410. if data.current.value == 'windowarga' then
  411. local playerPed = GetPlayerPed(-1)
  412. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  413. if windowarg == false then
  414. RollDownWindow(playerVeh, 2)
  415. windowarg = true
  416. TriggerEvent("pNotify:SendNotification", {text = _U('opened_window'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  417. else
  418. RollUpWindow(playerVeh, 2)
  419. windowarg = false
  420. TriggerEvent("pNotify:SendNotification", {text = _U('closed_wondow'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  421. end
  422. end
  423. if data.current.value == 'windowardr' then
  424. local playerPed = GetPlayerPed(-1)
  425. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  426. if windoward == false then
  427. RollDownWindow(playerVeh, 3)
  428. windoward = true
  429. TriggerEvent("pNotify:SendNotification", {text = _U('opened_window'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  430. else
  431. RollUpWindow(playerVeh, 3)
  432. windoward = false
  433. TriggerEvent("pNotify:SendNotification", {text = _U('closed_wondow'), type = "success", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  434. end
  435. end
  436. end,
  437. function(data, menu)
  438. menu.close()
  439. OpenVehicleMenu()
  440. end
  441. )
  442. end
  443. if data.current.value == 'cruise_control' then
  444. ESX.UI.Menu.CloseAll()
  445.  
  446. ESX.UI.Menu.Open(
  447. 'default', GetCurrentResourceName(), 'cruise_control_actions',
  448. {
  449. title = _U('cruise_control'),
  450. align = 'top-left',
  451. elements = {
  452. {label = _U('disabled'), value = 'none'},
  453. {label = '30Km/h', value = '30'},
  454. {label = '55Km/h', value = '55'},
  455. {label = '110Km/h', value = '110'},
  456. }
  457. },
  458. function(data, menu)
  459. if data.current.value == 'none' then
  460. local playerPed = GetPlayerPed(-1)
  461. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  462. local modelVeh = GetEntityModel(playerVeh)
  463. local maxSpeed = GetVehicleMaxSpeed(modelVeh)
  464. SetEntityMaxSpeed(playerVeh, maxSpeed)
  465. TriggerEvent("pNotify:SendNotification", {text = _U('disabled_cruise_control'), type = "error", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  466. end
  467. if data.current.value == '30' then
  468. local speedkm = 30
  469. local speed = speedkm/3.6
  470. local playerPed = GetPlayerPed(-1)
  471. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  472. SetEntityMaxSpeed(playerVeh, speed)
  473. TriggerEvent("pNotify:SendNotification", {text = "Du satte farthållaren på 30Km/h", type = "info", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  474. end
  475. if data.current.value == '55' then
  476. local speedkm = 55
  477. local speed = speedkm/3.6
  478. local playerPed = GetPlayerPed(-1)
  479. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  480. SetEntityMaxSpeed(playerVeh, speed)
  481. TriggerEvent("pNotify:SendNotification", {text = "Du satte farthållaren på 50Km/h", type = "info", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  482. end
  483. if data.current.value == '110' then
  484. local speedkm = 110
  485. local speed = speedkm/3.6
  486. local playerPed = GetPlayerPed(-1)
  487. local playerVeh = GetVehiclePedIsIn(playerPed, false)
  488. SetEntityMaxSpeed(playerVeh, speed)
  489. TriggerEvent("pNotify:SendNotification", {text = "Du satte farthållaren på 100Km/h", type = "info", queue = "vehiclemenu", timeout = 1000, layout = "bottomLeft"})
  490. end
  491. end,
  492. function(data, menu)
  493. menu.close()
  494. OpenVehicleMenu()
  495. end
  496. )
  497. end
  498. end,
  499. function(data, menu)
  500. menu.close()
  501. OpenCivilianActionsMenu()
  502. end
  503. )
  504. end
  505.  
  506. -- Close the ID card
  507. -- Key events
  508. Citizen.CreateThread(function()
  509. while true do
  510. Wait(0)
  511. if IsControlPressed(0, 322) or IsControlPressed(0, 177) and cardOpen then
  512. SendNUIMessage({
  513. action = "close"
  514. })
  515. cardOpen = false
  516. end
  517. end
  518. end)
  519.  
  520. Citizen.CreateThread(function()
  521. while true do
  522. Wait(0)
  523. if IsControlPressed(0, Keys["F5"]) then
  524. OpenCivilianActionsMenu()
  525. end
  526. end
  527. end)
  528.  
  529. -- Bälte
  530.  
  531.  
  532. local speedBuffer = {}
  533. local velBuffer = {}
  534. local beltOn = false
  535. local wasInCar = false
  536.  
  537. IsCar = function(veh)
  538. local vc = GetVehicleClass(veh)
  539. return (vc >= 0 and vc <= 7) or (vc >= 9 and vc <= 12) or (vc >= 17 and vc <= 20)
  540. end
  541.  
  542. Fwv = function (entity)
  543. local hr = GetEntityHeading(entity) + 90.0
  544. if hr < 0.0 then hr = 360.0 + hr end
  545. hr = hr * 0.0174533
  546. return { x = math.cos(hr) * 2.0, y = math.sin(hr) * 2.0 }
  547. end
  548.  
  549. Citizen.CreateThread(function()
  550. Citizen.Wait(500)
  551. while true do
  552.  
  553. local ped = GetPlayerPed(-1)
  554. local car = GetVehiclePedIsIn(ped)
  555.  
  556. if car ~= 0 and (wasInCar or IsCar(car)) then
  557.  
  558. wasInCar = true
  559.  
  560. if beltOn then DisableControlAction(0, 75) end
  561.  
  562. -- if beltOn and IsControlJustReleased(29)
  563. -- TriggerEvent("pNotify:SendNotification", {text = "Du har bälte på dig!", type = "error", queue = "belt", timeout = 1000, layout = "bottomLeft"})
  564. -- end
  565.  
  566. speedBuffer[2] = speedBuffer[1]
  567. speedBuffer[1] = GetEntitySpeed(car)
  568.  
  569. if speedBuffer[2] ~= nil
  570. and not beltOn
  571. and GetEntitySpeedVector(car, true).y > 1.0
  572. and speedBuffer[1] > 19.25
  573. and (speedBuffer[2] - speedBuffer[1]) > (speedBuffer[1] * 0.255) then
  574.  
  575. local co = GetEntityCoords(ped)
  576. local fw = Fwv(ped)
  577. SetEntityCoords(ped, co.x + fw.x, co.y + fw.y, co.z - 0.47, true, true, true)
  578. SetEntityVelocity(ped, velBuffer[2].x, velBuffer[2].y, velBuffer[2].z)
  579. Citizen.Wait(1)
  580. SetPedToRagdoll(ped, 1000, 1000, 0, 0, 0, 0)
  581. end
  582.  
  583. velBuffer[2] = velBuffer[1]
  584. velBuffer[1] = GetEntityVelocity(car)
  585.  
  586. if IsControlJustReleased(0, 29) then
  587. beltOn = not beltOn
  588. if beltOn then TriggerEvent("pNotify:SendNotification", {text = _U('seatbelt_on'), type = "success", queue = "belt", timeout = 1000, layout = "bottomLeft"})
  589. else TriggerEvent("pNotify:SendNotification", {text = _U('seatbelt_off'), type = "error", queue = "belt", timeout = 1000, layout = "bottomLeft"}) end
  590. end
  591.  
  592. elseif wasInCar then
  593. wasInCar = false
  594. beltOn = false
  595. speedBuffer[1], speedBuffer[2] = 0.0, 0.0
  596. end
  597. Citizen.Wait(0)
  598. end
  599. end)
  600.  
  601. local disableShuffle = true
  602. function disableSeatShuffle(flag)
  603. disableShuffle = flag
  604. end
  605.  
  606. Citizen.CreateThread(function()
  607. while true do
  608. Citizen.Wait(0)
  609. if IsPedInAnyVehicle(GetPlayerPed(-1), false) and disableShuffle then
  610. if GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0) == GetPlayerPed(-1) then
  611. if GetIsTaskActive(GetPlayerPed(-1), 165) then
  612. SetPedIntoVehicle(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 0)
  613. end
  614. end
  615. end
  616. end
  617. end)
  618.  
  619. RegisterNetEvent("SeatShuffle")
  620. AddEventHandler("SeatShuffle", function()
  621. if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
  622. disableSeatShuffle(false)
  623. Citizen.Wait(5000)
  624. disableSeatShuffle(true)
  625. else
  626. CancelEvent()
  627. end
  628. end)
  629.  
  630. RegisterCommand("shuff", function(source, args, raw) --change command here
  631. TriggerEvent("SeatShuffle")
  632. end, false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement