Advertisement
Guest User

Untitled

a guest
Feb 25th, 2022
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.54 KB | None | 0 0
  1. esx_licenses/server.lua:
  2.  
  3. function AddLicense(target, type, cb)
  4. local xPlayer = ESX.GetPlayerFromId(target)
  5.  
  6. if xPlayer then
  7. MySQL.insert('INSERT INTO user_licenses (type, owner) VALUES (?, ?)', {type, xPlayer.identifier},
  8. function(rowsChanged)
  9. if cb then
  10. cb()
  11. end
  12. end)
  13. else
  14. if cb then
  15. cb()
  16. end
  17. end
  18. end
  19.  
  20. function RemoveLicense(target, type, cb)
  21. local xPlayer = ESX.GetPlayerFromId(target)
  22.  
  23. if xPlayer then
  24. MySQL.update('DELETE FROM user_licenses WHERE type = ? AND owner = ?', {type, xPlayer.identifier},
  25. function(rowsChanged)
  26. if cb then
  27. cb()
  28. end
  29. end)
  30. else
  31. if cb then
  32. cb()
  33. end
  34. end
  35. end
  36.  
  37. function GetLicense(type, cb)
  38. MySQL.scalar('SELECT label FROM licenses WHERE type = ?', {type},
  39. function(result)
  40. cb({type = type, label = result})
  41. end)
  42. end
  43.  
  44. function GetLicenses(target, cb)
  45. local xPlayer = ESX.GetPlayerFromId(target)
  46.  
  47. MySQL.query('SELECT user_licenses.type, licenses.label FROM user_licenses LEFT JOIN licenses ON user_licenses.type = licenses.type WHERE owner = ?', {xPlayer.identifier},
  48. function(result)
  49. cb(result)
  50. end)
  51. end
  52.  
  53. function CheckLicense(target, type, cb)
  54. local xPlayer = ESX.GetPlayerFromId(target)
  55.  
  56. if xPlayer then
  57. MySQL.scalar('SELECT type FROM user_licenses WHERE type = ? AND owner = ?', {type, xPlayer.identifier},
  58. function(result)
  59. if result then
  60. cb(true)
  61. else
  62. cb(false)
  63. end
  64. end)
  65. else
  66. cb(false)
  67. end
  68. end
  69.  
  70. function GetLicensesList(cb)
  71. MySQL.query('SELECT type, label FROM licenses',
  72. function(result)
  73. cb(result)
  74. end)
  75. end
  76.  
  77. RegisterNetEvent('esx_license:addLicense')
  78. AddEventHandler('esx_license:addLicense', function(target, type, cb)
  79. AddLicense(target, type, cb)
  80. end)
  81.  
  82. RegisterNetEvent('esx_license:removeLicense')
  83. AddEventHandler('esx_license:removeLicense', function(target, type, cb)
  84. RemoveLicense(target, type, cb)
  85. end)
  86.  
  87. AddEventHandler('esx_license:getLicense', function(type, cb)
  88. GetLicense(type, cb)
  89. end)
  90.  
  91. RegisterNetEvent('esx_license:getLicenses')
  92. AddEventHandler('esx_license:getLicenses', function(target, cb)
  93. GetLicenses(target, cb)
  94. end)
  95.  
  96. AddEventHandler('esx_license:checkLicense', function(target, type, cb)
  97. CheckLicense(target, type, cb)
  98. end)
  99.  
  100. AddEventHandler('esx_license:getLicensesList', function(cb)
  101. GetLicensesList(cb)
  102. end)
  103.  
  104. ESX.RegisterServerCallback('esx_license:getLicense', function(source, cb, type)
  105. GetLicense(type, cb)
  106. end)
  107.  
  108. ESX.RegisterServerCallback('esx_license:getLicenses', function(source, cb, target)
  109. GetLicenses(target, cb)
  110. end)
  111.  
  112. ESX.RegisterServerCallback('esx_license:checkLicense', function(source, cb, target, type)
  113. CheckLicense(target, type, cb)
  114. end)
  115.  
  116. ESX.RegisterServerCallback('esx_license:getLicensesList', function(source, cb)
  117. GetLicensesList(cb)
  118. end)
  119.  
  120. esx_dmvschool/config.lua:
  121.  
  122. Config = {}
  123. Config.DrawDistance = 100.0
  124. Config.MaxErrors = 3
  125. Config.SpeedMultiplier = 3.6
  126. Config.Locale = 'en'
  127.  
  128. Config.Prices = {
  129. dmv = 500,
  130. drive = 2500,
  131. drive_bike = 3000,
  132. drive_truck = 5000
  133. }
  134.  
  135. Config.VehicleModels = {
  136. drive = 'golf4',
  137. drive_bike = 'ninjah2',
  138. drive_truck = 'mule3'
  139. }
  140.  
  141. Config.SpeedLimits = {
  142. residence = 55,
  143. town = 88,
  144. freeway = 105
  145. }
  146.  
  147. Config.Zones = {
  148.  
  149. DMVSchool = {
  150. Pos = {x = -810.5988, y = -1352.2604, z = 5.1500-0.98},
  151. Size = {x = 1.5, y = 1.5, z = 1.0},
  152. Color = {r = 204, g = 204, b = 0},
  153. Type = 1
  154. },
  155.  
  156. VehicleSpawnPoint = {
  157. Pos = {x = -761.8342, y = -1329.8511, z = 5.0004, h = 54.3854},
  158. Size = {x = 1.5, y = 1.5, z = 1.0},
  159. Color = {r = 204, g = 204, b = 0},
  160. Type = -1
  161. }
  162.  
  163. }
  164.  
  165. Config.CheckPoints = {
  166.  
  167. {
  168. Pos = {x = -781.9925, y = -1326.0081, z = 5.0003-0.98},
  169. Action = function(playerPed, vehicle, setCurrentZoneType)
  170. DrawMissionText(_U('next_point_speed', Config.SpeedLimits['residence']), 5000)
  171. end
  172. },
  173.  
  174. {
  175. Pos = {x = -703.4666, y = -1246.3673, z = 10.3445-0.98},
  176. Action = function(playerPed, vehicle, setCurrentZoneType)
  177. setCurrentZoneType('town')
  178.  
  179. Citizen.CreateThread(function()
  180. DrawMissionText(_U('stop_for_ped'), 5000)
  181. PlaySound(-1, 'RACE_PLACED', 'HUD_AWARDS', false, 0, true)
  182. FreezeEntityPosition(vehicle, true)
  183. Citizen.Wait(4000)
  184.  
  185. FreezeEntityPosition(vehicle, false)
  186. DrawMissionText(_U('good_lets_cont'), 5000)
  187. end)
  188. end
  189. },
  190.  
  191. {
  192. Pos = {x = -646.4415, y = -1293.4617, z = 10.6685-0.98},
  193. Action = function(playerPed, vehicle, setCurrentZoneType)
  194. end
  195. },
  196.  
  197. {
  198. Pos = {x = -532.9138, y = -1107.9597, z = 22.2426-0.98},
  199. Action = function(playerPed, vehicle, setCurrentZoneType)
  200. end
  201. },
  202.  
  203. {
  204. Pos = {x = -497.3983, y = -860.0271, z = 30.3336-0.98},
  205. Action = function(playerPed, vehicle, setCurrentZoneType)
  206. end
  207. },
  208.  
  209. {
  210. Pos = {x = -545.3369, y = -680.7515, z = 33.2965-0.98},
  211. Action = function(playerPed, vehicle, setCurrentZoneType)
  212. end
  213. },
  214.  
  215. {
  216. Pos = {x = -624.1840, y = -572.0944, z = 34.9276-0.98},
  217. Action = function(playerPed, vehicle, setCurrentZoneType)
  218. end
  219. },
  220.  
  221. {
  222. Pos = {x = -465.8426, y = -572.0718, z = 34.5073-0.98},
  223. Action = function(playerPed, vehicle, setCurrentZoneType)
  224. setCurrentZoneType('freeway')
  225.  
  226. DrawMissionText(_U('hway_time', Config.SpeedLimits['freeway']), 5000)
  227. PlaySound(-1, 'RACE_PLACED', 'HUD_AWARDS', false, 0, true)
  228. end
  229. },
  230.  
  231. {
  232. Pos = {x = -424.1990, y = -715.8915, z = 37.2108-0.98},
  233. Action = function(playerPed, vehicle, setCurrentZoneType)
  234. end
  235. },
  236.  
  237. {
  238. Pos = {x = -736.0645, y = -1704.1716, z = 29.4669-0.98},
  239. Action = function(playerPed, vehicle, setCurrentZoneType)
  240. setCurrentZoneType('town')
  241. DrawMissionText(_U('in_town_speed', Config.SpeedLimits['town']), 5000)
  242. end
  243. },
  244.  
  245. {
  246. Pos = {x = -729.1650, y = -1620.9277, z = 24.5995-0.98},
  247. Action = function(playerPed, vehicle, setCurrentZoneType)
  248. DrawMissionText(_U('go_next_point'), 5000)
  249. end
  250. },
  251.  
  252. {
  253. Pos = {x = -634.6426, y = -1320.2935, z = 10.6556-0.98},
  254. Action = function(playerPed, vehicle, setCurrentZoneType)
  255. DrawMissionText(_U('go_next_point'), 5000)
  256. end
  257. },
  258.  
  259. {
  260. Pos = {x = -682.0701, y = -1228.4078, z = 10.6670-0.98},
  261. Action = function(playerPed, vehicle, setCurrentZoneType)
  262. DrawMissionText(_U('go_next_point'), 5000)
  263. end
  264. },
  265.  
  266. {
  267. Pos = {x = -798.8036, y = -1315.1281, z = 5.000-0.98},
  268. Action = function(playerPed, vehicle, setCurrentZoneType)
  269. ESX.Game.DeleteVehicle(vehicle)
  270. end
  271. }
  272.  
  273. }
  274.  
  275.  
  276. esx_dmvschool/client/main.lua:
  277.  
  278. local CurrentAction = nil
  279. local CurrentActionMsg = nil
  280. local CurrentActionData = nil
  281. local Licenses = {}
  282. local CurrentTest = nil
  283. local CurrentTestType = nil
  284. local CurrentVehicle = nil
  285. local CurrentCheckPoint, DriveErrors = 0, 0
  286. local LastCheckPoint = -1
  287. local CurrentBlip = nil
  288. local CurrentZoneType = nil
  289. local IsAboveSpeedLimit = false
  290. local LastVehicleHealth = nil
  291.  
  292. function DrawMissionText(msg, time)
  293. ClearPrints()
  294. BeginTextCommandPrint('STRING')
  295. AddTextComponentSubstringPlayerName(msg)
  296. EndTextCommandPrint(time, true)
  297. end
  298.  
  299. function StartTheoryTest()
  300. CurrentTest = 'theory'
  301.  
  302. SendNUIMessage({
  303. openQuestion = true
  304. })
  305.  
  306. ESX.SetTimeout(200, function()
  307. SetNuiFocus(true, true)
  308. end)
  309.  
  310.  
  311. end
  312.  
  313. function StopTheoryTest(success)
  314. CurrentTest = nil
  315.  
  316. SendNUIMessage({
  317. openQuestion = false
  318. })
  319.  
  320. SetNuiFocus(false)
  321.  
  322. if success then
  323. TriggerServerEvent('esx_dmvschool:addLicense', 'dmv')
  324. ESX.ShowNotification(_U('passed_test'))
  325. else
  326. ESX.ShowNotification(_U('failed_test'))
  327. end
  328. end
  329.  
  330. function StartDriveTest(type)
  331. ESX.Game.SpawnVehicle(Config.VehicleModels[type], Config.Zones.VehicleSpawnPoint.Pos, Config.Zones.VehicleSpawnPoint.Pos.h, function(vehicle)
  332. CurrentTest = 'drive'
  333. CurrentTestType = type
  334. CurrentCheckPoint = 0
  335. LastCheckPoint = -1
  336. CurrentZoneType = 'residence'
  337. DriveErrors = 0
  338. IsAboveSpeedLimit = false
  339. CurrentVehicle = vehicle
  340. LastVehicleHealth = GetEntityHealth(vehicle)
  341.  
  342. local playerPed = PlayerPedId()
  343. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  344. SetVehicleFuelLevel(vehicle, 100.0)
  345. exports["LegacyFuel"]:SetFuel(vehicle, 100)
  346. DecorSetFloat(vehicle, "_FUEL_LEVEL", GetVehicleFuelLevel(vehicle))
  347. end)
  348. end
  349.  
  350. function StopDriveTest(success)
  351. if success then
  352. TriggerServerEvent('esx_dmvschool:addLicense', CurrentTestType)
  353. ESX.ShowNotification(_U('passed_test'))
  354. else
  355. ESX.ShowNotification(_U('failed_test'))
  356. end
  357.  
  358. CurrentTest = nil
  359. CurrentTestType = nil
  360. end
  361.  
  362. function SetCurrentZoneType(type)
  363. CurrentZoneType = type
  364. end
  365.  
  366. function OpenDMVSchoolMenu()
  367. local ownedLicenses = {}
  368.  
  369. for i=1, #Licenses, 1 do
  370. ownedLicenses[Licenses[i].type] = true
  371. end
  372.  
  373. local elements = {}
  374.  
  375. if not ownedLicenses['dmv'] then
  376. table.insert(elements, {
  377. label = (('%s: <span style="color:green;">%s</span>'):format(_U('theory_test'), _U('school_item', ESX.Math.GroupDigits(Config.Prices['dmv'])))),
  378. value = 'theory_test'
  379. })
  380. end
  381.  
  382. if ownedLicenses['dmv'] then
  383. if not ownedLicenses['drive'] then
  384. table.insert(elements, {
  385. label = (('%s: <span style="color:green;">%s</span>'):format(_U('road_test_car'), _U('school_item', ESX.Math.GroupDigits(Config.Prices['drive'])))),
  386. value = 'drive_test',
  387. type = 'drive'
  388. })
  389. end
  390.  
  391. if not ownedLicenses['drive_bike'] then
  392. table.insert(elements, {
  393. label = (('%s: <span style="color:green;">%s</span>'):format(_U('road_test_bike'), _U('school_item', ESX.Math.GroupDigits(Config.Prices['drive_bike'])))),
  394. value = 'drive_test',
  395. type = 'drive_bike'
  396. })
  397. end
  398.  
  399. if not ownedLicenses['drive_truck'] then
  400. table.insert(elements, {
  401. label = (('%s: <span style="color:green;">%s</span>'):format(_U('road_test_truck'), _U('school_item', ESX.Math.GroupDigits(Config.Prices['drive_truck'])))),
  402. value = 'drive_test',
  403. type = 'drive_truck'
  404. })
  405. end
  406. end
  407.  
  408. ESX.UI.Menu.CloseAll()
  409.  
  410. ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'dmvschool_actions', {
  411. title = _U('driving_school'),
  412. elements = elements,
  413. align = 'bottom-right'
  414. }, function(data, menu)
  415. if data.current.value == 'theory_test' then
  416. menu.close()
  417. ESX.TriggerServerCallback('esx_dmvschool:canYouPay', function(haveMoney)
  418. if haveMoney then
  419. StartTheoryTest()
  420. else
  421. ESX.ShowNotification(_U('not_enough_money'))
  422. end
  423. end, 'dmv')
  424. elseif data.current.value == 'drive_test' then
  425. menu.close()
  426. ESX.TriggerServerCallback('esx_dmvschool:canYouPay', function(haveMoney)
  427. if haveMoney then
  428. StartDriveTest(data.current.type)
  429. else
  430. ESX.ShowNotification(_U('not_enough_money'))
  431. end
  432. end, data.current.type)
  433. end
  434. end, function(data, menu)
  435. menu.close()
  436.  
  437. CurrentAction = 'dmvschool_menu'
  438. CurrentActionMsg = _U('press_open_menu')
  439. CurrentActionData = {}
  440. end)
  441. end
  442.  
  443. RegisterNUICallback('question', function(data, cb)
  444. SendNUIMessage({
  445. openSection = 'question'
  446. })
  447.  
  448. cb()
  449. end)
  450.  
  451. RegisterNUICallback('close', function(data, cb)
  452. StopTheoryTest(true)
  453. cb()
  454. end)
  455.  
  456. RegisterNUICallback('kick', function(data, cb)
  457. StopTheoryTest(false)
  458. cb()
  459. end)
  460.  
  461. AddEventHandler('esx_dmvschool:hasEnteredMarker', function(zone)
  462. if zone == 'DMVSchool' then
  463. CurrentAction = 'dmvschool_menu'
  464. CurrentActionMsg = _U('press_open_menu')
  465. CurrentActionData = {}
  466. end
  467. end)
  468.  
  469. AddEventHandler('esx_dmvschool:hasExitedMarker', function(zone)
  470. CurrentAction = nil
  471. ESX.UI.Menu.CloseAll()
  472. end)
  473.  
  474. RegisterNetEvent('esx_dmvschool:loadLicenses')
  475. AddEventHandler('esx_dmvschool:loadLicenses', function(licenses)
  476. Licenses = licenses
  477. end)
  478.  
  479. -- Create Blips
  480. Citizen.CreateThread(function()
  481. local blip = AddBlipForCoord(Config.Zones.DMVSchool.Pos.x, Config.Zones.DMVSchool.Pos.y, Config.Zones.DMVSchool.Pos.z)
  482.  
  483. SetBlipSprite (blip, 408)
  484. SetBlipDisplay(blip, 4)
  485. SetBlipScale (blip, 0.5)
  486. SetBlipAsShortRange(blip, true)
  487.  
  488. BeginTextCommandSetBlipName("STRING")
  489. AddTextComponentString(_U('driving_school_blip'))
  490. EndTextCommandSetBlipName(blip)
  491. end)
  492.  
  493. -- Display markers
  494. Citizen.CreateThread(function()
  495. while true do
  496. Citizen.Wait(0)
  497.  
  498. local coords = GetEntityCoords(PlayerPedId())
  499.  
  500. for k,v in pairs(Config.Zones) do
  501. if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
  502. DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false)
  503. end
  504. end
  505. end
  506. end)
  507.  
  508. -- Enter / Exit marker events
  509. Citizen.CreateThread(function()
  510. while true do
  511.  
  512. Citizen.Wait(100)
  513.  
  514. local coords = GetEntityCoords(PlayerPedId())
  515. local isInMarker = false
  516. local currentZone = nil
  517.  
  518. for k,v in pairs(Config.Zones) do
  519. if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then
  520. isInMarker = true
  521. currentZone = k
  522. end
  523. end
  524.  
  525. if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
  526. HasAlreadyEnteredMarker = true
  527. LastZone = currentZone
  528. TriggerEvent('esx_dmvschool:hasEnteredMarker', currentZone)
  529. end
  530.  
  531. if not isInMarker and HasAlreadyEnteredMarker then
  532. HasAlreadyEnteredMarker = false
  533. TriggerEvent('esx_dmvschool:hasExitedMarker', LastZone)
  534. end
  535. end
  536. end)
  537.  
  538. -- Block UI
  539. Citizen.CreateThread(function()
  540. while true do
  541. Citizen.Wait(1)
  542.  
  543. if CurrentTest == 'theory' then
  544. local playerPed = PlayerPedId()
  545.  
  546. DisableControlAction(0, 1, true) -- LookLeftRight
  547. DisableControlAction(0, 2, true) -- LookUpDown
  548. DisablePlayerFiring(playerPed, true) -- Disable weapon firing
  549. DisableControlAction(0, 142, true) -- MeleeAttackAlternate
  550. DisableControlAction(0, 106, true) -- VehicleMouseControlOverride
  551. else
  552. Citizen.Wait(500)
  553. end
  554. end
  555. end)
  556.  
  557. -- Key Controls
  558. Citizen.CreateThread(function()
  559. while true do
  560. Citizen.Wait(0)
  561.  
  562. if CurrentAction then
  563. ESX.ShowHelpNotification(CurrentActionMsg)
  564.  
  565. if IsControlJustReleased(0, 38) then
  566. if CurrentAction == 'dmvschool_menu' then
  567. OpenDMVSchoolMenu()
  568. end
  569.  
  570. CurrentAction = nil
  571. end
  572. else
  573. Citizen.Wait(500)
  574. end
  575. end
  576. end)
  577.  
  578. -- Drive test
  579. Citizen.CreateThread(function()
  580. while true do
  581.  
  582. Citizen.Wait(0)
  583.  
  584. if CurrentTest == 'drive' then
  585. local playerPed = PlayerPedId()
  586. local coords = GetEntityCoords(playerPed)
  587. local nextCheckPoint = CurrentCheckPoint + 1
  588.  
  589. if Config.CheckPoints[nextCheckPoint] == nil then
  590. if DoesBlipExist(CurrentBlip) then
  591. RemoveBlip(CurrentBlip)
  592. end
  593.  
  594. CurrentTest = nil
  595.  
  596. ESX.ShowNotification(_U('driving_test_complete'))
  597.  
  598. if DriveErrors < Config.MaxErrors then
  599. StopDriveTest(true)
  600. else
  601. StopDriveTest(false)
  602. end
  603. else
  604.  
  605. if CurrentCheckPoint ~= LastCheckPoint then
  606. if DoesBlipExist(CurrentBlip) then
  607. RemoveBlip(CurrentBlip)
  608. end
  609.  
  610. CurrentBlip = AddBlipForCoord(Config.CheckPoints[nextCheckPoint].Pos.x, Config.CheckPoints[nextCheckPoint].Pos.y, Config.CheckPoints[nextCheckPoint].Pos.z)
  611. SetBlipRoute(CurrentBlip, 1)
  612.  
  613. LastCheckPoint = CurrentCheckPoint
  614. end
  615.  
  616. local distance = GetDistanceBetweenCoords(coords, Config.CheckPoints[nextCheckPoint].Pos.x, Config.CheckPoints[nextCheckPoint].Pos.y, Config.CheckPoints[nextCheckPoint].Pos.z, true)
  617.  
  618. if distance <= 100.0 then
  619. DrawMarker(1, Config.CheckPoints[nextCheckPoint].Pos.x, Config.CheckPoints[nextCheckPoint].Pos.y, Config.CheckPoints[nextCheckPoint].Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 1.5, 1.5, 1.5, 102, 204, 102, 100, false, true, 2, false, false, false, false)
  620. end
  621.  
  622. if distance <= 3.0 then
  623. Config.CheckPoints[nextCheckPoint].Action(playerPed, CurrentVehicle, SetCurrentZoneType)
  624. CurrentCheckPoint = CurrentCheckPoint + 1
  625. end
  626. end
  627. else
  628. -- not currently taking driver test
  629. Citizen.Wait(500)
  630. end
  631. end
  632. end)
  633.  
  634. -- Speed / Damage control
  635. Citizen.CreateThread(function()
  636. while true do
  637. Citizen.Wait(10)
  638.  
  639. if CurrentTest == 'drive' then
  640.  
  641. local playerPed = PlayerPedId()
  642.  
  643. if IsPedInAnyVehicle(playerPed, false) then
  644.  
  645. local vehicle = GetVehiclePedIsIn(playerPed, false)
  646. local speed = GetEntitySpeed(vehicle) * Config.SpeedMultiplier
  647. local tooMuchSpeed = false
  648.  
  649. for k,v in pairs(Config.SpeedLimits) do
  650. if CurrentZoneType == k and speed > v then
  651. tooMuchSpeed = true
  652.  
  653. if not IsAboveSpeedLimit then
  654. DriveErrors = DriveErrors + 1
  655. IsAboveSpeedLimit = true
  656.  
  657. ESX.ShowNotification(_U('driving_too_fast', v))
  658. ESX.ShowNotification(_U('errors', DriveErrors, Config.MaxErrors))
  659. end
  660. end
  661. end
  662.  
  663. if not tooMuchSpeed then
  664. IsAboveSpeedLimit = false
  665. end
  666.  
  667. local health = GetEntityHealth(vehicle)
  668. if health < LastVehicleHealth then
  669.  
  670. DriveErrors = DriveErrors + 1
  671.  
  672. ESX.ShowNotification(_U('you_damaged_veh'))
  673. ESX.ShowNotification(_U('errors', DriveErrors, Config.MaxErrors))
  674.  
  675. -- avoid stacking faults
  676. LastVehicleHealth = health
  677. Citizen.Wait(1500)
  678. end
  679. end
  680. else
  681. -- not currently taking driver test
  682. Citizen.Wait(500)
  683. end
  684. end
  685. end)
  686.  
  687. esx_dmvschool/server/main.lua:
  688.  
  689. ESX.RegisterServerCallback('esx_dmvschool:canYouPay', function(source, cb, type)
  690. local xPlayer = ESX.GetPlayerFromId(source)
  691.  
  692. if xPlayer.getMoney() >= Config.Prices[type] then
  693. xPlayer.removeMoney(Config.Prices[type])
  694. TriggerClientEvent('esx:showNotification', source, _U('you_paid', Config.Prices[type]))
  695. cb(true)
  696. else
  697. cb(false)
  698. end
  699. end)
  700.  
  701.  
  702. AddEventHandler('esx:playerLoaded', function(source)
  703. TriggerEvent('esx_license:getLicenses', source, function(licenses)
  704. TriggerClientEvent('esx_dmvschool:loadLicenses', source, licenses)
  705. end)
  706. end)
  707.  
  708. RegisterNetEvent('esx_dmvschool:addLicense')
  709. AddEventHandler('esx_dmvschool:addLicense', function(type)
  710. local _source = source
  711.  
  712. TriggerEvent('esx_license:addLicense', _source, type, function()
  713. TriggerEvent('esx_license:getLicenses', _source, function(licenses)
  714. TriggerClientEvent('esx_dmvschool:loadLicenses', _source, licenses)
  715. end)
  716. end)
  717. end)
  718.  
  719.  
  720. SQL:
  721.  
  722. -- phpMyAdmin SQL Dump
  723. -- version 5.1.3
  724. -- https://www.phpmyadmin.net/
  725. --
  726. -- Host: localhost
  727. -- Erstellungszeit: 25. Feb 2022 um 12:24
  728. -- Server-Version: 10.3.31-MariaDB-0+deb10u1
  729. -- PHP-Version: 7.4.27
  730.  
  731. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  732. START TRANSACTION;
  733. SET time_zone = "+00:00";
  734.  
  735.  
  736. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  737. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  738. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  739. /*!40101 SET NAMES utf8mb4 */;
  740.  
  741. --
  742. -- Datenbank: `es_extended`
  743. --
  744.  
  745. -- --------------------------------------------------------
  746.  
  747. --
  748. -- Tabellenstruktur für Tabelle `licenses`
  749. --
  750.  
  751. CREATE TABLE `licenses` (
  752. `type` varchar(60) NOT NULL,
  753. `label` varchar(60) NOT NULL
  754. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  755.  
  756. --
  757. -- Daten für Tabelle `licenses`
  758. --
  759.  
  760. INSERT INTO `licenses` (`type`, `label`) VALUES
  761. ('dmv', 'Theoretische Fahrprüfung'),
  762. ('drive', 'Praktische Fahrprüfung'),
  763. ('drive_bike', 'Motorrad Fahrprüfung'),
  764. ('drive_truck', 'LKW Fahrprüfung'),
  765. ('weapon', 'Waffenschein');
  766.  
  767. -- --------------------------------------------------------
  768.  
  769. --
  770. -- Tabellenstruktur für Tabelle `user_licenses`
  771. --
  772.  
  773. CREATE TABLE `user_licenses` (
  774. `id` int(11) NOT NULL,
  775. `type` varchar(60) NOT NULL,
  776. `owner` varchar(60) DEFAULT NULL
  777. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  778.  
  779. --
  780. -- Daten für Tabelle `user_licenses`
  781. --
  782.  
  783. INSERT INTO `user_licenses` (`id`, `type`, `owner`) VALUES
  784. (7, 'drive', 'char2:74399739c7f1c4cfb50a13346b06a284401ca9fd'),
  785. (14, 'weapon', 'c2c3ec5e10269e2d4911b9737b4784416c7b4981'),
  786. (17, 'drive', '32e4fc6afa759afb7076f06117d10373d0687407'),
  787. (18, 'dmv', '32e4fc6afa759afb7076f06117d10373d0687407'),
  788. (24, 'dmv', '1a9ed63fbc6deb2696e26d0d25c7b4aab6d91379'),
  789. (28, 'dmv', '1a9ed63fbc6deb2696e26d0d25c7b4aab6d91379'),
  790. (29, 'drive', '1a9ed63fbc6deb2696e26d0d25c7b4aab6d91379'),
  791. (37, 'weapon', 'a2518ea92c68f9e72ec024252769fcc3beec3aef'),
  792. (38, 'weapon', '4d4f98b905d5a991535abd0ec95f3a8e000debd0'),
  793. (39, 'weapon', 'cb085c20a2fd4105b72dd99d1afbdd8cabb2aaab'),
  794. (42, 'weapon', 'd82758be17f5628be3205411d13c0a02707e2ab0'),
  795. (45, 'dmv', '5322dfb116cead5f5aee2f02b5659c93891fe8a4'),
  796. (47, 'drive_bike', '5322dfb116cead5f5aee2f02b5659c93891fe8a4'),
  797. (48, 'drive_truck', '5322dfb116cead5f5aee2f02b5659c93891fe8a4'),
  798. (57, 'weapon', 'afaae8b00bb0eb198ae861c90d31ccfc139abe58'),
  799. (58, 'drive', 'afaae8b00bb0eb198ae861c90d31ccfc139abe58'),
  800. (59, 'dmv', 'afaae8b00bb0eb198ae861c90d31ccfc139abe58'),
  801. (60, 'drive_bike', 'afaae8b00bb0eb198ae861c90d31ccfc139abe58'),
  802. (61, 'drive_truck', 'afaae8b00bb0eb198ae861c90d31ccfc139abe58'),
  803. (65, 'drive_bike', '37b747c146c338823e8e764fe82ff656ac219c8d'),
  804. (66, 'drive_truck', '37b747c146c338823e8e764fe82ff656ac219c8d'),
  805. (69, 'dmv', '382c2f1aed25d20b283b621387de1400ccf81c4e'),
  806. (70, 'drive', ' f5c8d63dc423a821c5935c23add8cd3c31cf350c'),
  807. (71, 'dmv', 'f5c8d63dc423a821c5935c23add8cd3c31cf350c'),
  808. (72, 'drive_truck', 'f5c8d63dc423a821c5935c23add8cd3c31cf350c'),
  809. (74, 'drive', '5a28589147cf17d0475c5ddd74788fe1062cddc9'),
  810. (75, 'dmv', '5a28589147cf17d0475c5ddd74788fe1062cddc9'),
  811. (77, 'drive_truck', '5a28589147cf17d0475c5ddd74788fe1062cddc9'),
  812. (79, 'dmv', '9af5fe77fd9923caa600035af97cde9305cf21b9'),
  813. (81, 'dmv', '8f4f4e74609a166b011827d91a34394eb3930eab'),
  814. (82, 'drive', '8f4f4e74609a166b011827d91a34394eb3930eab'),
  815. (85, 'drive', '9af5fe77fd9923caa600035af97cde9305cf21b9'),
  816. (86, 'drive_bike', '9af5fe77fd9923caa600035af97cde9305cf21b9'),
  817. (87, 'drive_truck', '9af5fe77fd9923caa600035af97cde9305cf21b9'),
  818. (88, 'drive', 'a53b5bf49a48ae456e2cc8bd35609a591d675878'),
  819. (89, 'dmv', 'a53b5bf49a48ae456e2cc8bd35609a591d675878'),
  820. (91, 'drive', '5322dfb116cead5f5aee2f02b5659c93891fe8a4'),
  821. (95, 'weapon', '1a9ed63fbc6deb2696e26d0d25c7b4aab6d91379'),
  822. (99, 'weapon', '5322dfb116cead5f5aee2f02b5659c93891fe8a4'),
  823. (100, 'weapon', '587804cef1f353d822b79768ea763d180d585c87'),
  824. (102, 'weapon', 'ca0966caeed0b49e05743ca2c20c55b008918854'),
  825. (103, 'weapon', '22b077e11e5ee5e932c7d6803ee7e4747f6f569d'),
  826. (104, 'weapon', '9af5fe77fd9923caa600035af97cde9305cf21b9'),
  827. (105, 'weapon', 'cc0a2b5f09fefa8cdf790b94e765a68657437a4f'),
  828. (106, 'dmv', '2e4a1b434f6e3821796147950ac22bc1b18ec36b'),
  829. (107, 'weapon', '32e4fc6afa759afb7076f06117d10373d0687407'),
  830. (110, 'dmv', '286fc126ce4c4022684432e3d7034b1ad1991692'),
  831. (111, 'drive', '286fc126ce4c4022684432e3d7034b1ad1991692'),
  832. (113, 'dmv', '587804cef1f353d822b79768ea763d180d585c87'),
  833. (115, 'weapon', 'bb900646e80c550e870304b54a35291e96061210'),
  834. (118, 'weapon', 'a53b5bf49a48ae456e2cc8bd35609a591d675878'),
  835. (119, 'dmv', 'f84504bfa0c9a9da92c4cdf77bbeced585eb73ad'),
  836. (120, 'dmv', 'fe9d304e1661aaa97fa36c0f89632b094605c8b6'),
  837. (121, 'dmv', 'c3f437fbb565aba19660d9d16374452493d72f0a'),
  838. (123, 'drive_bike', 'fe9d304e1661aaa97fa36c0f89632b094605c8b6'),
  839. (124, 'drive', 'c3f437fbb565aba19660d9d16374452493d72f0a'),
  840. (125, 'drive_bike', 'c3f437fbb565aba19660d9d16374452493d72f0a'),
  841. (128, 'drive_bike', '587804cef1f353d822b79768ea763d180d585c87'),
  842. (129, 'drive', '587804cef1f353d822b79768ea763d180d585c87'),
  843. (130, 'dmv', '494fbaa710c11afead7643305001e5ce2f0e13e7'),
  844. (131, 'drive_truck', 'fe9d304e1661aaa97fa36c0f89632b094605c8b6'),
  845. (132, 'drive', '494fbaa710c11afead7643305001e5ce2f0e13e7'),
  846. (134, 'weapon', 'fe9d304e1661aaa97fa36c0f89632b094605c8b6'),
  847. (135, 'weapon', '292f813ea1b7ff611d1e0a4198feae4e1ff25fe8'),
  848. (136, 'weapon', '494fbaa710c11afead7643305001e5ce2f0e13e7'),
  849. (140, 'dmv', '37b747c146c338823e8e764fe82ff656ac219c8d'),
  850. (141, 'drive', '37b747c146c338823e8e764fe82ff656ac219c8d'),
  851. (149, 'weapon', '5a28589147cf17d0475c5ddd74788fe1062cddc9'),
  852. (155, 'weapon', 'f5c8d63dc423a821c5935c23add8cd3c31cf350c'),
  853. (156, 'dmv', '4d4f98b905d5a991535abd0ec95f3a8e000debd0'),
  854. (157, 'drive', '4d4f98b905d5a991535abd0ec95f3a8e000debd0'),
  855. (158, 'dmv', '074c07516e81642c4e2eeef4b9598d13e9f5a0d6'),
  856. (159, 'drive', '074c07516e81642c4e2eeef4b9598d13e9f5a0d6'),
  857. (160, 'dmv', '7c76d8579fa4ed0236b0d91ae47e019ffa4fa118'),
  858. (161, 'drive', '7c76d8579fa4ed0236b0d91ae47e019ffa4fa118'),
  859. (162, 'drive', '74399739c7f1c4cfb50a13346b06a284401ca9fd'),
  860. (163, 'dmv', '74399739c7f1c4cfb50a13346b06a284401ca9fd'),
  861. (164, 'dmv', '8961510d9d7692d091304580b03a0f4395780038'),
  862. (165, 'drive', '8961510d9d7692d091304580b03a0f4395780038'),
  863. (166, 'weapon', '74399739c7f1c4cfb50a13346b06a284401ca9fd'),
  864. (169, 'weapon', 'ec489403752096e3b5d9a1802e5464845a752f94'),
  865. (170, 'dmv', 'ec489403752096e3b5d9a1802e5464845a752f94'),
  866. (173, 'weapon', 'b4823ba58324e29740d50fb5265e8bef2652b1f9'),
  867. (175, 'drive', '292f813ea1b7ff611d1e0a4198feae4e1ff25fe8'),
  868. (176, 'dmv', 'c328263a6af4394f8a35f5101e5f122e94812edb'),
  869. (177, 'dmv', 'a54a3af4504d2b7dbe16760ee653efde0168520a'),
  870. (178, 'drive', 'a54a3af4504d2b7dbe16760ee653efde0168520a'),
  871. (179, 'weapon', 'a54a3af4504d2b7dbe16760ee653efde0168520a'),
  872. (180, 'weapon', '3fa4098058b8bfcbbdcde5bd66eaa591f3e5ef65'),
  873. (181, 'weapon', '7459902c1acde57d69a1ad31a9c11efda1fb2966'),
  874. (184, 'dmv', '9b6a6234ed1dd5c5379d4d9758fa3640d52c9d25'),
  875. (186, 'weapon', '7c76d8579fa4ed0236b0d91ae47e019ffa4fa118'),
  876. (188, 'dmv', 'b2e39063051d8e36620d343207fcffbc1bc1c4e6'),
  877. (189, 'drive', 'b2e39063051d8e36620d343207fcffbc1bc1c4e6'),
  878. (190, 'dmv', '292f813ea1b7ff611d1e0a4198feae4e1ff25fe8'),
  879. (191, 'weapon', '9b6a6234ed1dd5c5379d4d9758fa3640d52c9d25'),
  880. (192, 'drive', '9b6a6234ed1dd5c5379d4d9758fa3640d52c9d25'),
  881. (193, 'dmv', '5fdf3e8533f605133da751cb36617d4ea02c35ee'),
  882. (194, 'dmv', '16ac6a07dbb480a5d380354e5854d0442d045bea'),
  883. (195, 'drive', '16ac6a07dbb480a5d380354e5854d0442d045bea'),
  884. (196, 'drive', '5fdf3e8533f605133da751cb36617d4ea02c35ee'),
  885. (197, 'weapon', '16ac6a07dbb480a5d380354e5854d0442d045bea'),
  886. (198, 'weapon', '5fdf3e8533f605133da751cb36617d4ea02c35ee'),
  887. (199, 'dmv', '8495003c06b35570ecd425b437029685e07a9e16'),
  888. (200, 'drive', '8495003c06b35570ecd425b437029685e07a9e16'),
  889. (201, 'dmv', '4edb82d05116ee8a3b3127de9f0eb94967b5cdc3'),
  890. (202, 'drive', '4edb82d05116ee8a3b3127de9f0eb94967b5cdc3'),
  891. (207, 'weapon', '2be5c3b3c1e3f2868ee4f3012b002a76b0744ec9'),
  892. (208, 'weapon', 'b2e39063051d8e36620d343207fcffbc1bc1c4e6'),
  893. (209, 'drive_bike', 'b2e39063051d8e36620d343207fcffbc1bc1c4e6'),
  894. (210, 'dmv', 'cb085c20a2fd4105b72dd99d1afbdd8cabb2aaab'),
  895. (211, 'drive', 'cb085c20a2fd4105b72dd99d1afbdd8cabb2aaab'),
  896. (212, 'dmv', 'bc5b0453c6a237d24e9edb6e9819365671acb98b'),
  897. (213, 'drive', 'bc5b0453c6a237d24e9edb6e9819365671acb98b'),
  898. (214, 'weapon', '37b747c146c338823e8e764fe82ff656ac219c8d'),
  899. (215, 'weapon', 'bc5b0453c6a237d24e9edb6e9819365671acb98b'),
  900. (216, 'drive_bike', 'bc5b0453c6a237d24e9edb6e9819365671acb98b'),
  901. (217, 'drive_truck', 'bc5b0453c6a237d24e9edb6e9819365671acb98b'),
  902. (220, 'dmv', '781aaa5be26ec8979cf683044b3b9bec88c606ad'),
  903. (221, 'dmv', '781aaa5be26ec8979cf683044b3b9bec88c606ad'),
  904. (222, 'weapon', '781aaa5be26ec8979cf683044b3b9bec88c606ad'),
  905. (223, 'drive', '781aaa5be26ec8979cf683044b3b9bec88c606ad');
  906.  
  907. --
  908. -- Indizes der exportierten Tabellen
  909. --
  910.  
  911. --
  912. -- Indizes für die Tabelle `licenses`
  913. --
  914. ALTER TABLE `licenses`
  915. ADD PRIMARY KEY (`type`);
  916.  
  917. --
  918. -- Indizes für die Tabelle `user_licenses`
  919. --
  920. ALTER TABLE `user_licenses`
  921. ADD PRIMARY KEY (`id`);
  922.  
  923. --
  924. -- AUTO_INCREMENT für exportierte Tabellen
  925. --
  926.  
  927. --
  928. -- AUTO_INCREMENT für Tabelle `user_licenses`
  929. --
  930. ALTER TABLE `user_licenses`
  931. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=224;
  932. COMMIT;
  933.  
  934. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  935. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  936. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  937.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement