Add files

This commit is contained in:
renaiku
2017-08-09 00:42:51 +02:00
parent de192f9601
commit b52e9a48d2
5 changed files with 161 additions and 1 deletions
+2 -1
View File
@@ -1 +1,2 @@
# fxserver-esx_joblisting
# fxserver-esx_joblisting
FR - Pôle Emploi
+9
View File
@@ -0,0 +1,9 @@
server_scripts {
'@mysql-async/lib/MySQL.lua',
'server/esx_joblisting_sv.lua'
}
client_scripts {
'config.lua',
'client/esx_joblisting_cl.lua'
}
+115
View File
@@ -0,0 +1,115 @@
local Keys = {
["ESC"] = 322, ["BACKSPACE"] = 177, ["E"] = 38, ["ENTER"] = 18, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173
}
local menuIsShowed = false
local hasAlreadyEnteredMarker = false
local lastZone = nil
local isInJoblistingMarker = false
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
function ShowJobListingMenu(data)
ESX.TriggerServerCallback('esx_joblisting:getJobsList', function(data)
local elements = {}
for i = 1, #data, 1 do
table.insert(
elements,
{label = data[i].label, value = data[i].value}
)
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'joblisting',
{
title = 'POLE EMPLOI',
elements = elements
},
function(data, menu)
TriggerServerEvent('esx_joblisting:setJob', data.current.value)
ESX.ShowNotification('Vous avez un nouveau job !')
menu.close()
end,
function(data, menu)
menu.close()
end
)
end)
end
AddEventHandler('esx_joblisting:hasExitedMarker', function(zone)
ESX.UI.Menu.CloseAll()
end)
-- Display markers
Citizen.CreateThread(function()
while true do
Wait(0)
local coords = GetEntityCoords(GetPlayerPed(-1))
for i=1, #Config.Zones, 1 do
if(GetDistanceBetweenCoords(coords, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, true) < Config.DrawDistance) then
DrawMarker(Config.MarkerType, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.ZoneSize.x, Config.ZoneSize.y, Config.ZoneSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
end
end
end
end)
-- Activate menu when player is inside marker
Citizen.CreateThread(function()
while true do
Wait(0)
local coords = GetEntityCoords(GetPlayerPed(-1))
isInJoblistingMarker = false
local currentZone = nil
for i=1, #Config.Zones, 1 do
if(GetDistanceBetweenCoords(coords, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, true) < Config.ZoneSize.x / 2) then
isInJoblistingMarker = true
SetTextComponentFormat('STRING')
AddTextComponentString('Appuyez sur ~INPUT_PICKUP~ pour \naccéder au ~b~Pôle Emploi~s~.')
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
end
if isInJoblistingMarker and not hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = true
end
if not isInJoblistingMarker and hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = false
TriggerEvent('esx_joblisting:hasExitedMarker')
end
end
end)
-- Create blips
Citizen.CreateThread(function()
for i=1, #Config.Zones, 1 do
local blip = AddBlipForCoord(Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z)
SetBlipSprite (blip, 407)
SetBlipDisplay(blip, 4)
SetBlipScale (blip, 1.2)
SetBlipColour (blip, 27)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Pôle-Emploi")
EndTextCommandSetBlipName(blip)
end
end)
-- Menu Controls
Citizen.CreateThread(function()
while true do
Wait(0)
if IsControlJustReleased(0, Keys['E']) and isInJoblistingMarker and not menuIsShowed then
ShowJobListingMenu()
end
end
end)
+9
View File
@@ -0,0 +1,9 @@
Config = {}
Config.DrawDistance = 100.0
Config.ZoneSize = {x = 3.0, y = 3.0, z = 2.0}
Config.MarkerColor = {r = 100, g = 100, b = 204}
Config.MarkerType = 1
Config.Zones = {
{x = -265.036, y = -963.630, z = 30.223}
}
+26
View File
@@ -0,0 +1,26 @@
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
ESX.RegisterServerCallback('esx_joblisting:getJobsList', function(source, cb)
MySQL.Async.fetchAll(
'SELECT * FROM jobs',
{},
function(result)
local data = {}
for i=1, #result, 1 do
table.insert(data, {
value = result[i].name,
label = result[i].label
})
end
cb(data)
end
)
end)
RegisterServerEvent('esx_joblisting:setJob')
AddEventHandler('esx_joblisting:setJob', function(job)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.setJob(job, 0)
end)