mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 21:01:31 +00:00
Upload files
This commit is contained in:
@@ -1 +1,22 @@
|
||||
# esx_accessories
|
||||
# fxserver-esx_accessories
|
||||
FXServer ESX Accessories
|
||||
|
||||
[REQUIREMENTS]
|
||||
|
||||
- esx_skin => https://github.com/FXServer-ESX/fxserver-esx_skin
|
||||
- esx_datastore => https://github.com/FXServer-ESX/fxserver-esx_datastore
|
||||
|
||||
[INSTALLATION]
|
||||
|
||||
1) CD in your resources/[esx] folder
|
||||
2) Clone the repository
|
||||
```
|
||||
git clone https://github.com/FXServer-ESX/fxserver-esx_accessories esx_accessories
|
||||
```
|
||||
3) Import esx_accessories.sql in your database
|
||||
4) Add this in your server.cfg :
|
||||
|
||||
```
|
||||
start baseevents
|
||||
start esx_accessories
|
||||
```
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'ESX Accessories'
|
||||
|
||||
version '1.0.0'
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/en.lua',
|
||||
'locales/fr.lua',
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
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 HasAlreadyEnteredMarker = false
|
||||
local LastZone = nil
|
||||
local CurrentAction = nil
|
||||
local CurrentActionMsg = ''
|
||||
local CurrentActionData = {}
|
||||
local IsDead = false
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
|
||||
function OpenAccessoryMenu()
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'set_unset_accessory',
|
||||
{
|
||||
title = _U('set_unset'),
|
||||
align = 'top-left',
|
||||
elements = {
|
||||
{label = _U('helmet'), value = 'Helmet'},
|
||||
{label = _U('ears'), value = 'Ears'},
|
||||
{label = _U('mask'), value = 'Mask'},
|
||||
{label = _U('glasses'), value = 'Glasses'},
|
||||
}
|
||||
},
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
SetUnsetAccessory(data.current.value)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function SetUnsetAccessory(accessory)
|
||||
|
||||
ESX.TriggerServerCallback('esx_accessories:get', function(hasAccessory, accessorySkin)
|
||||
local _accessory = string.lower(accessory)
|
||||
|
||||
if hasAccessory then
|
||||
TriggerEvent('skinchanger:getSkin', function(skin)
|
||||
local mAccessory = -1
|
||||
local mColor = 0
|
||||
if _accessory == "mask" then
|
||||
mAccessory = 0
|
||||
end
|
||||
if skin[_accessory .. '_1'] == mAccessory then
|
||||
mAccessory = accessorySkin[_accessory .. '_1']
|
||||
mColor = accessorySkin[_accessory .. '_2']
|
||||
end
|
||||
local accessorySkin = {}
|
||||
accessorySkin[_accessory .. '_1'] = mAccessory
|
||||
accessorySkin[_accessory .. '_2'] = mColor
|
||||
TriggerEvent('skinchanger:loadClothes', skin, accessorySkin)
|
||||
end)
|
||||
else
|
||||
ESX.ShowNotification(_U('no_' .. _accessory))
|
||||
end
|
||||
|
||||
end, accessory)
|
||||
|
||||
end
|
||||
|
||||
function OpenShopMenu(accessory)
|
||||
|
||||
local restrict = {}
|
||||
|
||||
restrict = { string.lower(accessory) .. '_1', string.lower(accessory) .. '_2' }
|
||||
|
||||
TriggerEvent('esx_skin:openRestrictedMenu', function(data, menu)
|
||||
|
||||
menu.close()
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'shop_confirm',
|
||||
{
|
||||
title = _U('valid_purchase'),
|
||||
align = 'top-left',
|
||||
elements = {
|
||||
{label = _U('yes'), value = 'yes'},
|
||||
{label = _U('no'), value = 'no'},
|
||||
}
|
||||
},
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
if data.current.value == 'yes' then
|
||||
ESX.TriggerServerCallback('esx_accessories:checkMoney', function(hasEnoughMoney)
|
||||
if hasEnoughMoney then
|
||||
TriggerServerEvent('esx_accessories:pay')
|
||||
TriggerEvent('skinchanger:getSkin', function(skin)
|
||||
TriggerServerEvent('esx_accessories:save', skin, accessory)
|
||||
end)
|
||||
else
|
||||
TriggerEvent('esx_skin:getLastSkin', function(skin)
|
||||
TriggerEvent('skinchanger:loadSkin', skin)
|
||||
end)
|
||||
ESX.ShowNotification(_U('not_enough_money'))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if data.current.value == 'no' then
|
||||
local player = GetPlayerPed(-1)
|
||||
TriggerEvent('esx_skin:getLastSkin', function(skin)
|
||||
TriggerEvent('skinchanger:loadSkin', skin)
|
||||
end)
|
||||
if accessory == "Ears" then
|
||||
ClearPedProp(Player, 2)
|
||||
elseif accessory == "Mask" then
|
||||
SetPedComponentVariation(player, 1, 0 ,0 ,2)
|
||||
elseif accessory == "Helmet" then
|
||||
ClearPedProp(Player, 0)
|
||||
elseif accessory == "Glasses" then
|
||||
SetPedPropIndex(player, 1, -1, 0, 0)
|
||||
end
|
||||
end
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = _U('press_access')
|
||||
CurrentActionData = {}
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = _U('press_access')
|
||||
CurrentActionData = {}
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = _U('press_access')
|
||||
CurrentActionData = {}
|
||||
end, restrict)
|
||||
|
||||
end
|
||||
|
||||
AddEventHandler('playerSpawned', function()
|
||||
IsDead = false
|
||||
end)
|
||||
|
||||
AddEventHandler('baseevents:onPlayerDied', function(killerType, coords)
|
||||
TriggerEvent('esx_ambulancejob:onPlayerDeath')
|
||||
end)
|
||||
|
||||
AddEventHandler('baseevents:onPlayerKilled', function(killerId, data)
|
||||
TriggerEvent('esx_ambulancejob:onPlayerDeath')
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_ambulancejob:onPlayerDeath', function()
|
||||
IsDead = true
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_accessories:hasEnteredMarker', function(zone)
|
||||
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = _U('press_access')
|
||||
CurrentActionData = { accessory = zone }
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_accessories:hasExitedMarker', function(zone)
|
||||
ESX.UI.Menu.CloseAll()
|
||||
CurrentAction = nil
|
||||
end)
|
||||
|
||||
-- Create Blips --
|
||||
Citizen.CreateThread(function()
|
||||
for k,v in pairs(Config.ShopsBlips) do
|
||||
if v.Pos ~= nil then
|
||||
for i=1, #v.Pos, 1 do
|
||||
local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)
|
||||
|
||||
SetBlipSprite (blip, v.Blip.sprite)
|
||||
SetBlipDisplay(blip, 4)
|
||||
SetBlipScale (blip, 1.0)
|
||||
SetBlipColour (blip, v.Blip.color)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentString(_U('store') .. ' ' .. _U(string.lower(k)))
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
end
|
||||
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
|
||||
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)
|
||||
|
||||
|
||||
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
|
||||
for i = 1, #v.Pos, 1 do
|
||||
if(GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.Size.x) then
|
||||
isInMarker = true
|
||||
currentZone = k
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
|
||||
HasAlreadyEnteredMarker = true
|
||||
LastZone = currentZone
|
||||
TriggerEvent('esx_accessories:hasEnteredMarker', currentZone)
|
||||
end
|
||||
|
||||
if not isInMarker and HasAlreadyEnteredMarker then
|
||||
HasAlreadyEnteredMarker = false
|
||||
TriggerEvent('esx_accessories: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 IsControlJustReleased(0, 38) then
|
||||
OpenShopMenu(CurrentActionData.accessory)
|
||||
CurrentAction = nil
|
||||
end
|
||||
end
|
||||
|
||||
if Config.EnableControls then
|
||||
if IsControlJustReleased(0, Keys['K']) and not IsDead then
|
||||
OpenAccessoryMenu()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
Config = {}
|
||||
|
||||
Config.Locale = 'fr'
|
||||
|
||||
Config.Price = 100
|
||||
|
||||
Config.EnableControls = true
|
||||
|
||||
|
||||
Config.DrawDistance = 100.0
|
||||
Config.Size = {x = 1.5, y = 1.5, z = 1.0}
|
||||
Config.Color = {r = 102, g = 102, b = 204}
|
||||
Config.Type = 1
|
||||
|
||||
|
||||
-- Fill this if you want to see the blips,
|
||||
-- If you have esx_clothesshop you should not fill this
|
||||
-- more than it's already filled.
|
||||
Config.ShopsBlips = {
|
||||
Ears = {
|
||||
Pos = nil,
|
||||
Blip = nil
|
||||
},
|
||||
Mask = {
|
||||
Pos = {
|
||||
{ x = -1338.129, y = -1278.200, z = 3.872 },
|
||||
},
|
||||
Blip = { sprite = 362, color = 2 }
|
||||
},
|
||||
Helmet = {
|
||||
Pos = nil,
|
||||
Blip = nil
|
||||
},
|
||||
Glasses = {
|
||||
Pos = nil,
|
||||
Blip = nil
|
||||
}
|
||||
}
|
||||
|
||||
Config.Zones = {
|
||||
Ears = {
|
||||
Pos = {
|
||||
{x= 80.374, y= -1389.493, z= 28.406},
|
||||
{x= -709.426, y= -153.829, z= 36.535},
|
||||
{x= -163.093, y= -302.038, z= 38.853},
|
||||
{x= 420.787, y= -809.654, z= 28.611},
|
||||
{x= -817.070, y= -1075.965, z= 10.448},
|
||||
{x= -1451.300, y= -238.254, z= 48.929},
|
||||
{x= -0.756, y= 6513.685, z= 30.997},
|
||||
{x= 123.431, y= -208.060, z= 53.677},
|
||||
{x= 1687.318, y= 4827.685, z= 41.183},
|
||||
{x= 622.806, y= 2749.221, z= 41.208},
|
||||
{x= 1200.085, y= 2705.428, z= 37.342},
|
||||
{x= -1199.959, y= -782.534, z= 16.452},
|
||||
{x= -3171.867, y= 1059.632, z= 19.983},
|
||||
{x= -1095.670, y= 2709.245, z= 18.227},
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Mask = {
|
||||
Pos = {
|
||||
{x = -1338.129, y = -1278.200, z = 3.872},
|
||||
}
|
||||
},
|
||||
|
||||
Helmet = {
|
||||
Pos = {
|
||||
{x= 81.576, y= -1400.602, z= 28.406},
|
||||
{x= -705.845, y= -159.015, z= 36.535},
|
||||
{x= -161.349, y= -295.774, z= 38.853},
|
||||
{x= 419.319, y= -800.647, z= 28.611},
|
||||
{x= -824.362, y= -1081.741, z= 10.448},
|
||||
{x= -1454.888, y= -242.911, z= 48.931},
|
||||
{x= 4.770, y= 6520.935, z= 30.997},
|
||||
{x= 121.071, y= -223.266, z= 53.377},
|
||||
{x= 1689.648, y= 4818.805, z= 41.183},
|
||||
{x= 613.971, y= 2749.978, z= 41.208},
|
||||
{x= 1189.513, y= 2703.947, z= 37.342},
|
||||
{x= -1204.025, y= -774.439, z= 16.452},
|
||||
{x= -3164.280, y= 1054.705, z= 19.983},
|
||||
{x= -1103.125, y= 2700.599, z= 18.227},
|
||||
}
|
||||
},
|
||||
|
||||
Glasses = {
|
||||
Pos = {
|
||||
{x= 75.287, y= -1391.131, z= 28.406},
|
||||
{x= -713.102, y= -160.116, z= 36.535},
|
||||
{x= -156.171, y= -300.547, z= 38.853},
|
||||
{x= 425.478, y= -807.866, z= 28.611},
|
||||
{x= -820.853, y= -1072.940, z= 10.448},
|
||||
{x= -1458.052, y= -236.783, z= 48.918},
|
||||
{x= 3.587, y= 6511.585, z= 30.997},
|
||||
{x= 131.335, y= -212.336, z= 53.677},
|
||||
{x= 1694.936, y= 4820.837, z= 41.183},
|
||||
{x= 613.972, y= 2768.814, z= 41.208},
|
||||
{x= 1198.678, y= 2711.011, z= 37.342},
|
||||
{x= -1188.227, y= -764.594, z= 16.452},
|
||||
{x= -3173.192, y= 1038.228, z= 19.983},
|
||||
{x= -1100.494, y= 2712.481, z= 18.227},
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
INSERT INTO `datastore` (name, label, shared) VALUES
|
||||
('user_ears','Ears',0),
|
||||
('user_glasses','Glasses',0),
|
||||
('user_helmet','Helmet',0),
|
||||
('user_mask','Mask',0)
|
||||
;
|
||||
@@ -0,0 +1,21 @@
|
||||
Locales ['en'] = {
|
||||
|
||||
['valid_purchase'] = 'validate this purchase?',
|
||||
['yes'] = 'yes',
|
||||
['no'] = 'no',
|
||||
['helmet'] = 'Helmet / Hat',
|
||||
['glasses'] = 'glasses',
|
||||
['mask'] = 'mask',
|
||||
['ears'] = 'ears accessories',
|
||||
['shop'] = 'shop',
|
||||
['set_unset'] = 'put on / Take off',
|
||||
['not_enough_money'] = 'you do not have enough money',
|
||||
['press_access'] = 'press ~INPUT_CONTEXT~ to access the menu',
|
||||
['accessories_blip'] = 'accessories',
|
||||
['no_ears'] = 'you do not have ears accessories',
|
||||
['no_glasses'] = 'you do not have glasses',
|
||||
['no_helmet'] = 'you do not have a helmet',
|
||||
['no_mask'] = 'you do not have a mask',
|
||||
['you_paid'] = 'you paid ',
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
Locales ['fr'] = {
|
||||
|
||||
['valid_purchase'] = 'valider cet achat ?',
|
||||
['yes'] = 'oui',
|
||||
['no'] = 'non',
|
||||
['helmet'] = 'Casque / Chapeau',
|
||||
['glasses'] = 'lunettes',
|
||||
['mask'] = 'masque',
|
||||
['ears'] = 'accessoires d\'oreilles',
|
||||
['shop'] = 'magasin',
|
||||
['set_unset'] = 'mettre / Enlever',
|
||||
['not_enough_money'] = 'vous n\'avez pas assez d\'argent',
|
||||
['press_access'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au menu',
|
||||
['accessories_blip'] = 'accessoires',
|
||||
['no_ears'] = 'vous n\'avez pas d\'accessoires d\'oreilles',
|
||||
['no_glasses'] = 'vous n\'avez pas de lunettes',
|
||||
['no_helmet'] = 'vous n\'avez pas de casque / chapeau',
|
||||
['no_mask'] = 'vous n\'avez pas de masque',
|
||||
['you_paid'] = 'vous avez payé ',
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
RegisterServerEvent('esx_accessories:pay')
|
||||
AddEventHandler('esx_accessories:pay', function()
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
xPlayer.removeMoney(Config.Price)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_paid') .. '$' .. Config.Price)
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_accessories:save')
|
||||
AddEventHandler('esx_accessories:save', function(skin, accessory)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
|
||||
TriggerEvent('esx_datastore:getDataStore', 'user_' .. string.lower(accessory), xPlayer.identifier, function(store)
|
||||
|
||||
store.set('has' .. accessory, true)
|
||||
|
||||
local itemSkin = {}
|
||||
local item1 = string.lower(accessory) .. '_1'
|
||||
local item2 = string.lower(accessory) .. '_2'
|
||||
itemSkin[item1] = skin[item1]
|
||||
itemSkin[item2] = skin[item2]
|
||||
store.set('skin', itemSkin)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_accessories:get', function(source, cb, accessory)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_datastore:getDataStore', 'user_' .. string.lower(accessory), xPlayer.identifier, function(store)
|
||||
|
||||
local hasAccessory = (store.get('has' .. accessory) and store.get('has' .. accessory) or false)
|
||||
local skin = (store.get('skin') and store.get('skin') or {})
|
||||
|
||||
cb(hasAccessory, skin)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
--===================================================================
|
||||
--===================================================================
|
||||
|
||||
ESX.RegisterServerCallback('esx_accessories: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