mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
Add files
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'ESX BarberShop'
|
||||
|
||||
server_scripts {
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
local Keys = {
|
||||
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
|
||||
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
|
||||
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
|
||||
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
|
||||
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
|
||||
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
|
||||
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
|
||||
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
|
||||
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
||||
}
|
||||
|
||||
ESX = nil
|
||||
local GUI = {}
|
||||
GUI.Time = 0
|
||||
local HasAlreadyEnteredMarker = false
|
||||
local LastZone = nil
|
||||
local CurrentAction = nil
|
||||
local CurrentActionMsg = ''
|
||||
local CurrentActionData = {}
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
while ESX == nil do
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
function OpenShopMenu()
|
||||
|
||||
TriggerEvent('esx_skin:openRestrictedMenu', function(data, menu)
|
||||
|
||||
menu.close()
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'shop_confirm',
|
||||
{
|
||||
title = 'Valider cet achat ?',
|
||||
align = 'top-left',
|
||||
elements = {
|
||||
{label = 'Oui', value = 'yes'},
|
||||
{label = 'Non', value = 'no'},
|
||||
}
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
menu.close()
|
||||
|
||||
if data.current.value == 'yes' then
|
||||
|
||||
ESX.TriggerServerCallback('esx_barbershop:checkMoney', function(hasEnoughMoney)
|
||||
|
||||
if hasEnoughMoney then
|
||||
|
||||
TriggerEvent('skinchanger:getSkin', function(skin)
|
||||
TriggerServerEvent('esx_skin:save', skin)
|
||||
end)
|
||||
|
||||
TriggerServerEvent('esx_barbershop:pay')
|
||||
else
|
||||
|
||||
TriggerEvent('esx_skin:getLastSkin', function(skin)
|
||||
TriggerEvent('skinchanger:loadSkin', skin)
|
||||
end)
|
||||
|
||||
ESX.ShowNotification('Vous n\'avez pas assez d\'argent')
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
if data.current.value == 'no' then
|
||||
|
||||
TriggerEvent('esx_skin:getLastSkin', function(skin)
|
||||
TriggerEvent('skinchanger:loadSkin', skin)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu'
|
||||
CurrentActionData = {}
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
|
||||
menu.close()
|
||||
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu'
|
||||
CurrentActionData = {}
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end, function(data, menu)
|
||||
|
||||
menu.close()
|
||||
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu'
|
||||
CurrentActionData = {}
|
||||
|
||||
end, {
|
||||
'beard_1',
|
||||
'beard_2',
|
||||
'beard_3',
|
||||
'beard_4',
|
||||
'hair_1',
|
||||
'hair_2',
|
||||
'hair_color_1',
|
||||
'hair_color_2',
|
||||
'eyebrows_1',
|
||||
'eyebrows_2',
|
||||
'eyebrows_3',
|
||||
'eyebrows_4',
|
||||
'makeup_1',
|
||||
'makeup_2',
|
||||
'makeup_3',
|
||||
'makeup_4',
|
||||
'lipstick_1',
|
||||
'lipstick_2',
|
||||
'lipstick_3',
|
||||
'lipstick_4',
|
||||
'ears_1',
|
||||
'ears_2',
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
AddEventHandler('esx_barbershop:hasEnteredMarker', function(zone)
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu'
|
||||
CurrentActionData = {}
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_barbershop:hasExitedMarker', function(zone)
|
||||
CurrentAction = nil
|
||||
end)
|
||||
|
||||
-- Create Blips
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
for i=1, #Config.Shops, 1 do
|
||||
|
||||
local blip = AddBlipForCoord(Config.Shops[i].x, Config.Shops[i].y, Config.Shops[i].z)
|
||||
|
||||
SetBlipSprite (blip, 71)
|
||||
SetBlipDisplay(blip, 4)
|
||||
SetBlipScale (blip, 1.0)
|
||||
SetBlipColour (blip, 51)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentString("Coiffeur / Barbier")
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
-- Display markers
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
Wait(0)
|
||||
|
||||
local coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
|
||||
for k,v in pairs(Config.Zones) do
|
||||
if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
-- Enter / Exit marker events
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
Wait(0)
|
||||
|
||||
local coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
local isInMarker = false
|
||||
local currentZone = nil
|
||||
|
||||
for k,v in pairs(Config.Zones) do
|
||||
if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then
|
||||
isInMarker = true
|
||||
currentZone = k
|
||||
end
|
||||
end
|
||||
|
||||
if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
|
||||
HasAlreadyEnteredMarker = true
|
||||
LastZone = currentZone
|
||||
TriggerEvent('esx_barbershop:hasEnteredMarker', currentZone)
|
||||
end
|
||||
|
||||
if not isInMarker and HasAlreadyEnteredMarker then
|
||||
HasAlreadyEnteredMarker = false
|
||||
TriggerEvent('esx_barbershop:hasExitedMarker', LastZone)
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
-- Key controls
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
Citizen.Wait(0)
|
||||
|
||||
if CurrentAction ~= nil then
|
||||
|
||||
SetTextComponentFormat('STRING')
|
||||
AddTextComponentString(CurrentActionMsg)
|
||||
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
||||
|
||||
if IsControlPressed(0, Keys['E']) and (GetGameTimer() - GUI.Time) > 300 then
|
||||
|
||||
if CurrentAction == 'shop_menu' then
|
||||
OpenShopMenu()
|
||||
end
|
||||
|
||||
CurrentAction = nil
|
||||
GUI.Time = GetGameTimer()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
Config = {}
|
||||
|
||||
Config.Price = 100
|
||||
|
||||
Config.DrawDistance = 100.0
|
||||
Config.MarkerSize = {x = 1.5, y = 1.5, z = 1.0}
|
||||
Config.MarkerColor = {r = 102, g = 102, b = 204}
|
||||
Config.MarkerType = 1
|
||||
|
||||
Config.Zones = {}
|
||||
|
||||
Config.Shops = {
|
||||
{x = -814.308, y = -183.823, z = 36.568},
|
||||
{x = 136.826, y = -1708.373, z = 28.291},
|
||||
{x = -1282.604, y = -1116.757, z = 5.990},
|
||||
{x = 1931.513, y = 3729.671, z = 31.844},
|
||||
{x = 1212.840, y = -472.921, z = 62.208},
|
||||
{x = -32.885, y = -152.319, z = 56.076},
|
||||
{x = -278.077, y = 6228.463, z = 30.695},
|
||||
}
|
||||
|
||||
for i=1, #Config.Shops, 1 do
|
||||
|
||||
Config.Zones['Shop_' .. i] = {
|
||||
Pos = Config.Shops[i],
|
||||
Size = Config.MarkerSize,
|
||||
Color = Config.MarkerColor,
|
||||
Type = Config.MarkerType
|
||||
}
|
||||
|
||||
end
|
||||
@@ -0,0 +1,26 @@
|
||||
ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
RegisterServerEvent('esx_barbershop:pay')
|
||||
AddEventHandler('esx_barbershop:pay', function()
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.removeMoney(Config.Price)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', source, 'Vous avez payé $' .. Config.Price)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_barbershop:checkMoney', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if xPlayer.get('money') >= Config.Price then
|
||||
cb(true)
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
|
||||
end)
|
||||
Reference in New Issue
Block a user