Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update esx_dmvschool + ox_lib #619

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions server-data/resources/[esx_addons]/esx_dmvschool/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function OpenDMVSchoolMenu()
end
end

ESX.OpenContext("right", elements, function(_, element)
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "theory_test" then
ESX.TriggerServerCallback('esx_dmvschool:canYouPay', function(haveMoney)
if haveMoney then
Expand All @@ -151,26 +151,27 @@ function OpenDMVSchoolMenu()
end
end, element.type)
end
end, function()
end, function(menu)
CurrentAction = 'dmvschool_menu'
CurrentActionMsg = _U('press_open_menu')
CurrentActionData = {}
end)
end

RegisterNUICallback('question', function(_, cb)
RegisterNUICallback('question', function(data, cb)
SendNUIMessage({
openSection = 'question'
})

cb()
end)

RegisterNUICallback('close', function(_, cb)
RegisterNUICallback('close', function(data, cb)
StopTheoryTest(true)
cb()
end)

RegisterNUICallback('kick', function(_, cb)
RegisterNUICallback('kick', function(data, cb)
StopTheoryTest(false)
cb()
end)
Expand All @@ -183,7 +184,7 @@ AddEventHandler('esx_dmvschool:hasEnteredMarker', function(zone)
end
end)

AddEventHandler('esx_dmvschool:hasExitedMarker', function()
AddEventHandler('esx_dmvschool:hasExitedMarker', function(zone)
CurrentAction = nil
ESX.CloseContext()
end)
Expand All @@ -198,6 +199,7 @@ CreateThread(function()
local blip = AddBlipForCoord(Config.Zones.DMVSchool.Pos.x, Config.Zones.DMVSchool.Pos.y, Config.Zones.DMVSchool.Pos.z)

SetBlipSprite (blip, 408)
SetBlipColour (blip, 0)
SetBlipDisplay(blip, 4)
SetBlipScale (blip, 1.2)
SetBlipAsShortRange(blip, true)
Expand All @@ -214,7 +216,7 @@ CreateThread(function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)

for _, v in pairs(Config.Zones) do
for k,v in pairs(Config.Zones) do
local Pos = vector3(v.Pos.x, v.Pos.y, v.Pos.z)
if(v.Type ~= -1 and #(coords - Pos) < Config.DrawDistance) then
sleep = 0
Expand Down Expand Up @@ -332,7 +334,7 @@ CreateThread(function()
tooMuchSpeed = true

if not IsAboveSpeedLimit then
DriveErrors = DriveErrors + 1
DriveErrors += 1
IsAboveSpeedLimit = true

ESX.ShowNotification(_U('driving_too_fast', v))
Expand All @@ -348,17 +350,17 @@ CreateThread(function()
local health = GetEntityHealth(vehicle)
if health < LastVehicleHealth then

DriveErrors = DriveErrors + 1
DriveErrors += 1

ESX.ShowNotification(_U('you_damaged_veh'))
ESX.ShowNotification(_U('errors', DriveErrors, Config.MaxErrors))

-- avoid stacking faults
LastVehicleHealth = health
Wait(1500)
sleep = 1500
end
end
end
Wait(sleep)
end
end)
end)
34 changes: 17 additions & 17 deletions server-data/resources/[esx_addons]/esx_dmvschool/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ Config.CheckPoints = {

{
Pos = {x = 255.139, y = -1400.731, z = 29.537},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('next_point_speed', Config.SpeedLimits['residence']), 5000)
end
},

{
Pos = {x = 271.874, y = -1370.574, z = 30.932},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('go_next_point'), 5000)
end
},

{
Pos = {x = 234.907, y = -1345.385, z = 29.542},
Action = function(_, vehicle)
Action = function(playerPed, vehicle, setCurrentZoneType)
CreateThread(function()
DrawMissionText(_U('stop_for_ped'), 5000)
PlaySound(-1, 'RACE_PLACED', 'HUD_AWARDS', false, 0, true)
Expand All @@ -74,7 +74,7 @@ Config.CheckPoints = {

{
Pos = {x = 217.821, y = -1410.520, z = 28.292},
Action = function(_, vehicle, setCurrentZoneType)
Action = function(playerPed, vehicle, setCurrentZoneType)
setCurrentZoneType('town')

CreateThread(function()
Expand All @@ -91,21 +91,21 @@ Config.CheckPoints = {

{
Pos = {x = 178.550, y = -1401.755, z = 27.725},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('watch_traffic_lightson'), 5000)
end
},

{
Pos = {x = 113.160, y = -1365.276, z = 27.725},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('go_next_point'), 5000)
end
},

{
Pos = {x = -73.542, y = -1364.335, z = 27.789},
Action = function(_, vehicle)
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('stop_for_passing'), 5000)
PlaySound(-1, 'RACE_PLACED', 'HUD_AWARDS', false, 0, true)
FreezeEntityPosition(vehicle, true)
Expand All @@ -116,21 +116,21 @@ Config.CheckPoints = {

{
Pos = {x = -355.143, y = -1420.282, z = 27.868},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('go_next_point'), 5000)
end
},

{
Pos = {x = -439.148, y = -1417.100, z = 27.704},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('go_next_point'), 5000)
end
},

{
Pos = {x = -453.790, y = -1444.726, z = 27.665},
Action = function(_, _, setCurrentZoneType)
Action = function(playerPed, vehicle, setCurrentZoneType)
setCurrentZoneType('freeway')

DrawMissionText(_U('hway_time', Config.SpeedLimits['freeway']), 5000)
Expand All @@ -140,46 +140,46 @@ Config.CheckPoints = {

{
Pos = {x = -463.237, y = -1592.178, z = 37.519},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('go_next_point'), 5000)
end
},

{
Pos = {x = -900.647, y = -1986.28, z = 26.109},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('go_next_point'), 5000)
end
},

{
Pos = {x = 1225.759, y = -1948.792, z = 38.718},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('go_next_point'), 5000)
end
},

{
Pos = {x = 1225.759, y = -1948.792, z = 38.718},
Action = function(_, _, setCurrentZoneType)
Action = function(playerPed, vehicle, setCurrentZoneType)
setCurrentZoneType('town')
DrawMissionText(_U('in_town_speed', Config.SpeedLimits['town']), 5000)
end
},

{
Pos = {x = 1163.603, y = -1841.771, z = 35.679},
Action = function()
Action = function(playerPed, vehicle, setCurrentZoneType)
DrawMissionText(_U('gratz_stay_alert'), 5000)
PlaySound(-1, 'RACE_PLACED', 'HUD_AWARDS', false, 0, true)
end
},

{
Pos = {x = 235.283, y = -1398.329, z = 28.921},
Action = function(_, vehicle)
Action = function(playerPed, vehicle, setCurrentZoneType)
ESX.Game.DeleteVehicle(vehicle)
end
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ files {
dependencies {
'es_extended',
'esx_license'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
var tableauQuestion = [
{
question: "Om du ligger i 80 km/h, och kommer in i ett bostadsområde måste du:",
propositionA: "Du accelererar",
propositionB: "Du behåller din hastighet, om du inte passerar andra fordon",
propositionC: "Du saktar ner",
propositionD: "Du behåller hastigheten",
reponse: "C"
},

{
question: "Om du svänger höger vid ett trafikljus, men ser en fotgängare gå över vägen. Vad gör du?:",
propositionA: "Du passerar fotgängaren",
propositionB: "Du ser omkring dig att det inte finns några andra fordon i närheten",
propositionC: "Du väntar tills fotgängaren passerat",
propositionD: "Du skjuter fotgängaren och kör över han",
reponse: "C"
},

{
question: "Utan någon förhandsindikation, hastigheten i ett bostadsområde är: __ km/h",
propositionA: "30 km/h",
propositionB: "50 km/h",
propositionC: "40 km/h",
propositionD: "60 km/h",
reponse: "B"
},

{
question: "Innan varje filbyte måste du:",
propositionA: "Kolla dina speglar",
propositionB: "Kontrollera dina döda vinklar",
propositionC: "Signalera dina avsikter",
propositionD: "Alla uppskrivna",
reponse: "D"
},

{
question: "Vilken alkoholhalt i blodet klassas som rattfylleri?",
propositionA: "0.05%",
propositionB: "0.18%",
propositionC: "0.08%",
propositionD: "0.06%",
reponse: "C"
},

{
question: "När kan du fortsätta att köra vid ett trafikljus?",
propositionA: "När det är grönt",
propositionB: "När det inte finns någon i korsningen",
propositionC: "Du befinner dig i en skolzon",
propositionD: "När det är grönt och / eller rött och du svänger höger",
reponse: "D"
},

{
question: "En fotgängare har inte en grön gubbe lysandes, men går ändå. Vad gör du?",
propositionA: "Du låter de passera",
propositionB: "Du observerar innan du fortsätter",
propositionC: "Du vinkar för att säga åt dem att gå över",
propositionD: "Du fortsätter eftersom ditt trafikljus är grönt",
reponse: "D"
},

{
question: "Vad är tillåtet när man passerar ett annat fordon?",
propositionA: "Du följer den noga för att passera den snabbare",
propositionB: "Du passerar den utan att lämna vägbanan",
propositionC: "Du kör på motsatt sida av vägen för att passera",
propositionD: "Du överskrider hastighetsgränsen för att passera dem",
reponse: "C"
},

{
question: "Du kör på en motorväg som anger en maxhastighet på 120 km/h. Men de flesta trafikanter kör i 125 km/h, så du ska inte köra fortare än:",
propositionA: "120 km/h",
propositionB: "125 km/h",
propositionC: "130 km/h",
propositionD: "110 km/h",
reponse: "A"
},

{
question: "När du blir omkörd av ett annat fordon är det viktigt att INTE göra det:",
propositionA: "Sakta ned",
propositionB: "Kolla dina backspeglar",
propositionC: "Titta på andra förare",
propositionD: "Öka din hastighet",
reponse: "D"
},
]
Loading
Loading