mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
+8
-2
@@ -1,12 +1,18 @@
|
||||
description 'ESX Mecano Job'
|
||||
description 'ESX Shops'
|
||||
|
||||
client_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
}
|
||||
|
||||
+21
-21
@@ -4,7 +4,7 @@ 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)
|
||||
@@ -13,7 +13,7 @@ Citizen.CreateThread(function()
|
||||
end)
|
||||
|
||||
AddEventHandler('onClientMapStart', function()
|
||||
|
||||
|
||||
ESX.TriggerServerCallback('esx_shop:requestDBItems', function(ShopItems)
|
||||
for k,v in pairs(ShopItems) do
|
||||
Config.Zones[k].Items = v
|
||||
@@ -45,27 +45,27 @@ function OpenShopMenu(zone)
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'shop',
|
||||
{
|
||||
title = 'Magasin',
|
||||
title = _U('shop'),
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
function(data, menu)
|
||||
TriggerServerEvent('esx_shop:buyItem', data.current.value, data.current.price)
|
||||
end,
|
||||
function(data, menu)
|
||||
|
||||
|
||||
menu.close()
|
||||
|
||||
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.'
|
||||
CurrentActionMsg = _U('press_menu')
|
||||
CurrentActionData = {zone = zone}
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
AddEventHandler('esx_shop:hasEnteredMarker', function(zone)
|
||||
|
||||
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.'
|
||||
CurrentActionMsg = _U('press_menu')
|
||||
CurrentActionData = {zone = zone}
|
||||
|
||||
end)
|
||||
@@ -88,7 +88,7 @@ Citizen.CreateThread(function()
|
||||
SetBlipColour (blip, 2)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentString("Magasins")
|
||||
AddTextComponentString(_U('shops'))
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
end
|
||||
@@ -96,15 +96,15 @@ end)
|
||||
|
||||
-- Display markers
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
while true do
|
||||
Wait(0)
|
||||
local coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
local coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
for k,v in pairs(Config.Zones) do
|
||||
for i = 1, #v.Pos, 1 do
|
||||
if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then
|
||||
DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -143,21 +143,21 @@ Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
if CurrentAction ~= nil then
|
||||
|
||||
|
||||
SetTextComponentFormat('STRING')
|
||||
AddTextComponentString(CurrentActionMsg)
|
||||
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
||||
|
||||
if IsControlJustReleased(0, 38) then
|
||||
|
||||
|
||||
if IsControlJustReleased(0, 38) then
|
||||
|
||||
if CurrentAction == 'shop_menu' then
|
||||
OpenShopMenu(CurrentActionData.zone)
|
||||
end
|
||||
|
||||
CurrentAction = nil
|
||||
|
||||
|
||||
CurrentAction = nil
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@ Config.DrawDistance = 100
|
||||
Config.Size = {x = 1.5, y = 1.5, z = 1.5}
|
||||
Config.Color = {r = 0, g = 128, b = 255}
|
||||
Config.Type = 1
|
||||
Config.Locale = 'fr'
|
||||
|
||||
Config.Zones = {
|
||||
|
||||
@@ -35,7 +36,7 @@ Config.Zones = {
|
||||
{x = -559.906, y = 287.093, z = 82.176} --Bahamamas
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
LTDgasoline = {
|
||||
Items = {},
|
||||
Pos = {
|
||||
@@ -46,4 +47,4 @@ Config.Zones = {
|
||||
{x = 1698.388, y = 4924.404, z = 41.063}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Locales['en'] = {
|
||||
|
||||
['shop'] = 'shop',
|
||||
['shops'] = 'shops',
|
||||
['press_menu'] = 'press ~INPUT_CONTEXT~ to access the store.',
|
||||
['bought'] = 'you bought ~b~1x ',
|
||||
['not_enough'] = 'you do not ~r~have enough~s~ money.'
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
Locales['fr'] = {
|
||||
|
||||
['shop'] = 'magasin',
|
||||
['shops'] = 'magasins',
|
||||
['press_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.',
|
||||
['bought'] = 'vous avez acheté ~b~1x ',
|
||||
['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent.',
|
||||
|
||||
}
|
||||
+6
-6
@@ -9,10 +9,10 @@ AddEventHandler('onMySQLReady', function()
|
||||
'SELECT * FROM items',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
|
||||
for i=1, #result, 1 do
|
||||
ItemsLabels[result[i].name] = result[i].label
|
||||
end--
|
||||
end--
|
||||
|
||||
end
|
||||
)
|
||||
@@ -25,7 +25,7 @@ ESX.RegisterServerCallback('esx_shop:requestDBItems', function(source, cb)
|
||||
'SELECT * FROM shops',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
|
||||
local shopItems = {}
|
||||
|
||||
for i=1, #result, 1 do
|
||||
@@ -51,7 +51,7 @@ end)
|
||||
|
||||
RegisterServerEvent('esx_shop:buyItem')
|
||||
AddEventHandler('esx_shop:buyItem', function(itemName, price)
|
||||
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
@@ -60,10 +60,10 @@ AddEventHandler('esx_shop:buyItem', function(itemName, price)
|
||||
xPlayer.removeMoney(price)
|
||||
xPlayer.addInventoryItem(itemName, 1)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', _source, 'Vous avez acheté ~b~1x ' .. ItemsLabels[itemName])
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('bought') .. ItemsLabels[itemName])
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, 'Vous n\'avez ~r~pas assez~s~ d\'argent.')
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('not_enough'))
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user