Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local poleemploi = {
- opened = false,
- title = "Pôle emploi",
- currentmenu = "main2",
- lastmenu = nil,
- currentpos = nil,
- selectedbutton = 0,
- marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
- menu = {
- x = 0.9,
- y = 0.20,
- width = 0.2,
- height = 0.04,
- buttons = 10,
- from = 1,
- to = 10,
- scale = 0.4,
- font = 0,
- ["main2"] = {
- title = "CATEGORIES",
- name = "main2",
- buttons = {
- {name = "Sans études", description = ""},
- {name = "Avec Diplômes(SOON)", description = ""},
- }
- },
- ["sansetude"] = {
- title = "Sans etudes",
- name = "sansetude",
- buttons = {
- }
- },
- ["avecetude"] = {
- title = "Avec Diplomes",
- name = "avecetude",
- buttons = {
- {name = "Vigneron (SOON)", costs = 0, description = {}, model = "Vigneron"},
- {name = "Joaillier (SOON)", costs = 0, description = {}, model = "Joaillier"},
- {name = "Pompiste (SOON)", costs = 0, description = {}, model = "Pompiste"},
- }
- },
- }
- }
- RegisterNetEvent('PoleEmploiAddButton')
- AddEventHandler('PoleEmploiAddButton', function(tablejob)
- local a = tablejob
- poleemploi.menu["sansetude"].buttons = {}
- local i = 1
- while a[i] do
- namejobclient = a[i]['name_job']
- jobidjobclient = a[i]['job_id']
- posxclient = a[i]['x']
- posyclient = a[i]['y']
- poszclient = a[i]['z']
- table.insert(poleemploi.menu["sansetude"].buttons, {name = namejobclient, description = "", jobid = jobidjobclient, posx = posxclient, posy = posyclient, posz = poszclient})
- i = i + 1
- end
- end)
- RegisterNetEvent('PoleEmploiAddButton2')
- AddEventHandler('PoleEmploiAddButton2', function()
- poleemploi.currentmenu = "sansetude"
- poleemploi.opened = true
- poleemploi.selectedbutton = 0
- end)
- local fakecar = {model = '', car = nil}
- local poleemploi_locations = {
- {insidejob = {-266.5083,-960.6709,30.22313}},
- }
- local poleemploi_blips ={}
- local inrangeofpoleemploi = false
- local currentlocation = nil
- local boughtcloth = false
- local function LocalPed()
- return GetPlayerPed(-1)
- end
- function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
- SetTextFont(font)
- SetTextProportional(0)
- SetTextScale(scale, scale)
- SetTextColour(r, g, b, a)
- SetTextDropShadow(0, 0, 0, 0,255)
- SetTextEdge(1, 0, 0, 0, 255)
- SetTextDropShadow()
- SetTextOutline()
- SetTextCentre(centre)
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x , y)
- end
- function IsPlayerInRangeOfpoleemploi()
- return inrangeofpoleemploi
- end
- function ShowpoleemploiBlips(bool)
- if bool and #poleemploi_blips == 0 then
- for station,pos in pairs(poleemploi_locations) do
- local loc = pos
- pos = pos.insidejob
- local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
- -- 60 58 137
- SetBlipSprite(blip,407)
- SetBlipColour(blip, 15)
- BeginTextCommandSetBlipName("STRING")
- AddTextComponentString('Pôle Emploi')
- EndTextCommandSetBlipName(blip)
- SetBlipAsShortRange(blip,true)
- SetBlipAsMissionCreatorBlip(blip,true)
- table.insert(poleemploi_blips, {blip = blip, pos = loc})
- end
- Citizen.CreateThread(function()
- while #poleemploi_blips > 0 do
- Citizen.Wait(0)
- local inrange = false
- for i,b in ipairs(poleemploi_blips) do
- if poleemploi.opened == false and GetDistanceBetweenCoords(b.pos.insidejob[1],b.pos.insidejob[2],b.pos.insidejob[3],GetEntityCoords(LocalPed()),true) > 0 then
- -- DrawMarker(1,b.pos.insidejob[1],b.pos.insidejob[2],b.pos.insidejob[3],0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
- currentlocation = b
- if GetDistanceBetweenCoords(b.pos.insidejob[1],b.pos.insidejob[2],b.pos.insidejob[3],GetEntityCoords(LocalPed()),true) < 5 then
- Show("Appuyez sur ~INPUT_CONTEXT~ pour choisir un ~b~métier.")
- -- drawTxt('Appuyez sur ~g~ENTRER~s~ pour choisir un ~b~Job',0,1,0.5,0.8,0.6,255,255,255,255)
- inrange = true
- end
- end
- if GetDistanceBetweenCoords(b.pos.insidejob[1],b.pos.insidejob[2],b.pos.insidejob[3],GetEntityCoords(LocalPed()),true) > 5 then
- poleemploi.opened = false
- inrange = false
- end
- end
- inrangeofpoleemploi = inrange
- end
- end)
- elseif bool == false and #poleemploi_blips > 0 then
- for i,b in ipairs(poleemploi_blips) do
- if DoesBlipExist(b.blip) then
- SetBlipAsMissionCreatorBlip(b.blip,false)
- Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(b.blip))
- end
- end
- poleemploi_blips = {}
- end
- end
- function fi(n)
- return n + 0.0001
- end
- function LocalPed()
- return GetPlayerPed(-1)
- end
- function trycloth(fi, catch_f)
- local status, exception = pcall(fi)
- if not status then
- catch_f(exception)
- end
- end
- function firstToUpperCloth(str)
- return (str:gsub("^%l", string.upper))
- end
- --local veh = nil
- function OpenCreatorPoleEmploi()
- boughtcloth = false
- local ped = LocalPed()
- local pos = currentlocation.pos.insidejob
- local g = Citizen.InvokeNative(0xC906A7DAB05C8D2B,pos[1],pos[2],pos[3],Citizen.PointerValueFloat(),0)
- poleemploi.currentmenu = "main2"
- poleemploi.opened = true
- poleemploi.selectedbutton = 0
- end
- local cloth_price = 0
- function CloseCreatorPoleEmploi()
- Citizen.CreateThread(function()
- local ped = LocalPed()
- if not boughtcloth then
- local pos = currentlocation.pos.insidejob
- FreezeEntityPosition(ped,false)
- SetEntityVisible(ped,true)
- else
- local model = GetEntityModel(cloth)
- Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(cloth))
- local pos = currentlocation.pos.insidejob
- FreezeEntityPosition(ped,false)
- RequestModel(model)
- while not HasModelLoaded(model) do
- Citizen.Wait(0)
- end
- SetModelAsNoLongerNeeded(model)
- SetClothHasBeenOwnedByPlayer(skin,true)
- local id = NetworkGetNetworkIdFromEntity(skin)
- SetNetworkIdCanMigrate(id, true)
- Citizen.InvokeNative(0x629BFA74418D6239,Citizen.PointerValueIntInitialized(skin))
- SetEntityVisible(ped,true)
- FreezeEntityPosition(ped,false)
- TriggerEvent('BoughtPv',skin)
- end
- poleemploi.opened = false
- poleemploi.menu.from = 1
- poleemploi.menu.to = 10
- end)
- end
- function drawMenuButton(button,x,y,selected)
- local menu = poleemploi.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(menu.scale, menu.scale)
- if selected then
- SetTextColour(0, 0, 0, 255)
- else
- SetTextColour(255, 255, 255, 255)
- end
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(button.name)
- if selected then
- DrawRect(x,y,menu.width,menu.height,255,255,255,255)
- else
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- end
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function drawMenuInfo(text)
- local menu = poleemploi.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(0.45, 0.45)
- SetTextColour(255, 255, 255, 255)
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawRect(0.675, 0.95,0.65,0.050,0,0,0,150)
- DrawText(0.365, 0.934)
- end
- function drawMenuRight(txt,x,y,selected)
- local menu = poleemploi.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(menu.scale, menu.scale)
- SetTextRightJustify(1)
- if selected then
- SetTextColour(0, 0, 0, 255)
- else
- SetTextColour(255, 255, 255, 255)
- end
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(txt)
- DrawText(x + menu.width/2 - 0.03, y - menu.height/2 + 0.0028)
- end
- function drawMenuTitlePole(txt,x,y)
- local menu = poleemploi.menu
- SetTextFont(2)
- SetTextProportional(0)
- SetTextScale(0.5, 0.5)
- SetTextColour(255, 255, 255, 255)
- SetTextEntry("STRING")
- AddTextComponentString(txt)
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function NotifyPoleEmploi(text)
- SetNotificationTextEntry('STRING')
- AddTextComponentString(text)
- DrawNotification(false, false)
- end
- function DoesPlayerHaveJob(model,button,y,selected)
- local t = false
- --TODO:check if player own car
- if t then
- drawMenuRight("OWNED",poleemploi.menu.x,y,selected)
- else
- drawMenuRight(button.costs.."$",poleemploi.menu.x,y,selected)
- end
- end
- local backlock = false
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if IsControlJustPressed(1,38) and IsPlayerInRangeOfpoleemploi() then
- if poleemploi.opened then
- CloseCreatorPoleEmploi()
- else
- OpenCreatorPoleEmploi()
- clearPed()
- end
- end
- if poleemploi.opened then
- local ped = LocalPed()
- local menu = poleemploi.menu[poleemploi.currentmenu]
- drawTxt(poleemploi.title,1,1,poleemploi.menu.x,poleemploi.menu.y,1.0, 255,255,255,255)
- drawMenuTitlePole(menu.title, poleemploi.menu.x,poleemploi.menu.y + 0.08)
- drawTxt(poleemploi.selectedbutton.."/"..tablelength(menu.buttons),0,0,poleemploi.menu.x + poleemploi.menu.width/2 - 0.0385,poleemploi.menu.y + 0.067,0.4, 255,255,255,255)
- local y = poleemploi.menu.y + 0.12
- buttoncount = tablelength(menu.buttons)
- local selected = false
- for i,button in pairs(menu.buttons) do
- if i >= poleemploi.menu.from and i <= poleemploi.menu.to then
- if i == poleemploi.selectedbutton then
- selected = true
- else
- selected = false
- end
- drawMenuButton(button,poleemploi.menu.x,y,selected)
- y = y + 0.04
- if selected and IsControlJustPressed(1,201) then
- ButtonSelectedPoleEmploi(button)
- end
- end
- end
- end
- if poleemploi.opened then
- if IsControlJustPressed(1,202) then
- BackJob()
- end
- if IsControlJustReleased(1,202) then
- backlock = false
- end
- if IsControlJustPressed(1,188) then
- if poleemploi.selectedbutton > 1 then
- poleemploi.selectedbutton = poleemploi.selectedbutton -1
- if buttoncount > 10 and poleemploi.selectedbutton < poleemploi.menu.from then
- poleemploi.menu.from = poleemploi.menu.from -1
- poleemploi.menu.to = poleemploi.menu.to - 1
- end
- end
- end
- if IsControlJustPressed(1,187)then
- if poleemploi.selectedbutton < buttoncount then
- poleemploi.selectedbutton = poleemploi.selectedbutton +1
- if buttoncount > 10 and poleemploi.selectedbutton > poleemploi.menu.to then
- poleemploi.menu.to = poleemploi.menu.to + 1
- poleemploi.menu.from = poleemploi.menu.from + 1
- end
- end
- end
- end
- end
- end)
- function roundPoleEmploi(num1, idp2)
- if idp2 and idp2>0 then
- local mult = 10^idp2
- return math.floor(num1 * mult + 0.5) / mult
- end
- return math.floor(num1 + 0.5)
- end
- function ButtonSelectedPoleEmploi(button)
- local ped = GetPlayerPed(-1)
- local this = poleemploi.currentmenu
- local btn = button.name
- if this == "main2" then
- if btn == "Sans études" then
- TriggerServerEvent('PoleEmploi')
- elseif btn == "Avec Diplômes" then
- OpenMenuJob('avecetude')
- end
- elseif this == "sansetude" or this == "avecetude" then
- TriggerServerEvent('CheckJobForPlayer',button.name,button.jobid,button.posx,button.posy,button.posz)
- poleemploi.opened = false
- poleemploi.menu.from = 1
- poleemploi.menu.to = 10
- end
- end
- local polegoto = 0
- RegisterNetEvent('GiveCoord')
- AddEventHandler('GiveCoord', function(posx, posy, posz)
- polegoto = 1
- coordpolex = tonumber(posx)
- coordpoley = tonumber(posy)
- coordpolez = tonumber(posz)
- ShowNotificationMenuCivil2("~h~Coordonnées de votre nouvelle ~b~Entreprise~w~ envoyées sur votre GPS.")
- end)
- Citizen.CreateThread(function()
- while true do
- Wait(0)
- if (polegoto == 1) then
- blipentreprise = AddBlipForCoord(coordpolex, coordpoley, coordpolez)
- N_0x80ead8e2e1d5d52e(blipentreprise)
- SetBlipRoute(blipentreprise, 1)
- polegoto = 2
- end
- if polegoto == 2 then
- if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), coordpolex, coordpoley, coordpolez, true) > 4.0001 then
- DrawMarker(1, coordpolex, coordpoley, coordpolez-1.0001, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 2.0, 11, 80, 169, 255, 0, 0, 1, 0, 0, 0, 0)
- else
- if blipentreprise ~= nil and DoesBlipExist(blipentreprise) then
- Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(blipentreprise))
- blipentreprise = nil
- polegoto = 0
- end
- end
- end
- end
- end)
- RegisterNetEvent('FinishCheckJobForPlayer')
- AddEventHandler('FinishCheckJobForPlayer', function(button)
- boughtcloth = true
- CloseCreatorPoleEmploi()
- poleemploi.opened = false
- poleemploi.menu.from = 1
- poleemploi.menu.to = 10
- end)
- function OpenMenuJob(menu)
- poleemploi.lastmenu = poleemploi.currentmenu
- if menu == "sansetude" then
- poleemploi.lastmenu = "main2"
- elseif menu == "avecetude" then
- poleemploi.lastmenu = "main2"
- elseif menu == 'race_create_objects' then
- poleemploi.lastmenu = "main2"
- elseif menu == "race_create_objects_spawn" then
- poleemploi.lastmenu = "race_create_objects"
- end
- poleemploi.menu.from = 1
- poleemploi.menu.to = 10
- poleemploi.selectedbutton = 0
- poleemploi.currentmenu = menu
- end
- function BackJob()
- if backlock then
- return
- end
- backlock = true
- if poleemploi.currentmenu == "main2" then
- CloseCreatorPoleEmploi()
- poleemploi.opened = false
- poleemploi.menu.from = 1
- poleemploi.menu.to = 10
- elseif poleemploi.currentmenu == "sansetude" or poleemploi.currentmenu == "avecetude" then
- OpenMenuJob('main2')
- else
- OpenMenuJob(poleemploi.lastmenu)
- end
- end
- function stringstartsJob(String1,Start2)
- return string.sub(String1,1,string.len(Start2))==Start2
- end
- local firstspawn = 0
- AddEventHandler('playerSpawned', function(spawn)
- if firstspawn == 0 then
- ShowpoleemploiBlips(true)
- firstspawn = 1
- end
- end)
- onJob = 0
- jobs = {peds = {}, flag = {}, blip = {}, cars = {}, coords = {cx={}, cy={}, cz={}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement