This commit is contained in:
Mycroft
2022-03-29 16:30:41 +01:00
18 changed files with 266 additions and 344 deletions
+6 -21
View File
@@ -6,33 +6,18 @@ description 'ESX Atm'
version '1.6.5'
shared_script '@es_extended/imports.lua'
shared_scripts {
'@es_extended/imports.lua',
'@es_extended/locale.lua',
'locales/*.lua',
'config.lua'
}
server_scripts {
'@es_extended/locale.lua',
'locales/de.lua',
'locales/br.lua',
'locales/en.lua',
'locales/fi.lua',
'locales/fr.lua',
'locales/es.lua',
'locales/sv.lua',
'locales/cs.lua',
'config.lua',
'server/main.lua'
}
client_scripts {
'@es_extended/locale.lua',
'locales/de.lua',
'locales/br.lua',
'locales/en.lua',
'locales/fi.lua',
'locales/fr.lua',
'locales/es.lua',
'locales/sv.lua',
'locales/cs.lua',
'config.lua',
'client/main.lua'
}
+5 -11
View File
@@ -1,5 +1,4 @@
fx_version 'adamant'
fx_version 'bodacious'
game 'gta5'
description 'ESX Job Listing'
@@ -9,17 +8,12 @@ version '1.6.5'
shared_scripts {
'@es_extended/imports.lua',
'@es_extended/locale.lua',
'locales/*.lua',
'config.lua'
}
server_scripts {
'@oxmysql/lib/MySQL.lua',
'locales/*.lua',
'server/main.lua'
}
client_scripts {
'locales/*.lua',
'client/main.lua'
}
server_script 'server/main.lua'
client_script 'client/main.lua'
dependency 'es_extended'
+14 -8
View File
@@ -1,14 +1,18 @@
local availableJobs = {}
for k,v in pairs(ESX.Jobs) do
print(v.whitelisted)
if v.whitelisted == false then
availableJobs[k] = {label = v.label}
function getJobs()
local jobs = ESX.GetJobs()
local availableJobs = {}
for k,v in pairs(jobs) do
print(v.whitelisted)
if v.whitelisted == false then
availableJobs[k] = {label = v.label}
end
end
return availableJobs
end
ESX.RegisterServerCallback('esx_joblisting:getJobsList', function(source, cb)
cb(availableJobs)
local jobs = getJobs()
cb(jobs)
end)
function IsNearCentre(player)
@@ -27,10 +31,12 @@ end
RegisterServerEvent('esx_joblisting:setJob')
AddEventHandler('esx_joblisting:setJob', function(job)
local source = source
local xPlayer = ESX.GetPlayerFromId(source)
local jobs = getJobs()
if xPlayer and IsNearCentre(source) then
if availableJobs[job] then
if jobs[job] then
xPlayer.setJob(job, 0)
end
end
+15 -14
View File
@@ -391,6 +391,21 @@ CreateThread(function()
ESX.UI.Menu.CloseAll()
GetAction({value = 'main'})
-- Prevent Free Tunning Bug
CreateThread(function()
while lsMenuIsShowed do
DisableControlAction(2, 288, true)
DisableControlAction(2, 289, true)
DisableControlAction(2, 170, true)
DisableControlAction(2, 167, true)
DisableControlAction(2, 168, true)
DisableControlAction(2, 23, true)
DisableControlAction(0, 75, true) -- Disable exit vehicle
DisableControlAction(27, 75, true) -- Disable exit vehicle
Wait(0)
end
end)
end
end
end
@@ -399,17 +414,3 @@ CreateThread(function()
Wait(Sleep)
end
end)
-- Prevent Free Tunning Bug
CreateThread(function()
while lsMenuIsShowed do
DisableControlAction(2, 288, true)
DisableControlAction(2, 289, true)
DisableControlAction(2, 170, true)
DisableControlAction(2, 167, true)
DisableControlAction(2, 168, true)
DisableControlAction(2, 23, true)
DisableControlAction(0, 75, true) -- Disable exit vehicle
DisableControlAction(27, 75, true) -- Disable exit vehicle
end
end)
-26
View File
@@ -2,33 +2,7 @@
ESX Weapon Shop adds.. well you guessed it - weapon shops to the already existing shops in the world.
## Download & Installation
### Using [fvm](https://github.com/qlaffont/fvm-installer)
```
fvm install --save --folder=esx esx-org/esx_weaponshop
```
### Using Git
```
cd resources
git clone https://github.com/ESX-Org/esx_weaponshop.git [esx]/esx_weaponshop
```
### Manually
- Download https://github.com/ESX-Org/esx_weaponshop/archive/master.zip
- Put it in the `[esx]` directory
## Installation
- Import `esx_weaponshop.sql` in your database
- Add this to your `server.cfg`:
```
start esx_weaponshop
```
# Legal
### License
esx_weaponshop - Legal and illegal weapon shops
Copyright (C) 2015-2022 Jérémie N'gadi
+22 -89
View File
@@ -5,19 +5,6 @@ local CurrentActionMsg = ''
local CurrentActionData = {}
local ShopOpen = false
ESX.TriggerServerCallback('esx_weaponshop:getShop', function(shopItems)
for k,v in pairs(shopItems) do
Config.Zones[k].Items = v
end
end)
RegisterNetEvent('esx_weaponshop:sendShop')
AddEventHandler('esx_weaponshop:sendShop', function(shopItems)
for k,v in pairs(shopItems) do
Config.Zones[k].Items = v
end
end)
function OpenBuyLicenseMenu(zone)
ESX.UI.Menu.CloseAll()
@@ -48,11 +35,12 @@ function OpenShopMenu(zone)
for i=1, #Config.Zones[zone].Items, 1 do
local item = Config.Zones[zone].Items[i]
item.label = ESX.GetWeaponLabel(item.name)
table.insert(elements, {
label = ('%s - <span style="color: green;">%s</span>'):format(item.label, _U('shop_menu_item', ESX.Math.GroupDigits(item.price))),
price = item.price,
weaponName = item.item
weaponName = item.name
})
end
@@ -95,7 +83,6 @@ function DisplayBoughtScaleform(weaponName, price)
ScaleformMovieMethodAddParamInt(GetHashKey(weaponName))
ScaleformMovieMethodAddParamTextureNameString('')
ScaleformMovieMethodAddParamInt(100)
EndScaleformMovieMethod()
PlaySoundFrontend(-1, 'WEAPON_PURCHASE', 'HUD_AMMO_SHOP_SOUNDSET', false)
@@ -110,19 +97,6 @@ function DisplayBoughtScaleform(weaponName, price)
end)
end
AddEventHandler('esx_weaponshop:hasEnteredMarker', function(zone)
if zone == 'GunShop' or zone == 'BlackWeashop' then
CurrentAction = 'shop_menu'
CurrentActionMsg = _U('shop_menu_prompt')
CurrentActionData = { zone = zone }
end
end)
AddEventHandler('esx_weaponshop:hasExitedMarker', function(zone)
CurrentAction = nil
ESX.UI.Menu.CloseAll()
end)
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
if ShopOpen then
@@ -140,7 +114,7 @@ CreateThread(function()
SetBlipSprite (blip, 110)
SetBlipDisplay(blip, 4)
SetBlipScale (blip, 1.0)
SetBlipScale (blip, 0.8)
SetBlipColour (blip, 81)
SetBlipAsShortRange(blip, true)
@@ -163,69 +137,28 @@ CreateThread(function()
for i = 1, #v.Locations, 1 do
if (Config.Type ~= -1 and #(coords - v.Locations[i]) < Config.DrawDistance) then
Sleep = 0
ESX.ShowHelpNotification(_U('shop_menu_prompt'))
if IsControlJustReleased(0, 38) then
if Config.LicenseEnable and v.Legal then
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasWeaponLicense)
if hasWeaponLicense then
OpenShopMenu(k)
else
OpenBuyLicenseMenu(k)
end
end, GetPlayerServerId(PlayerId()), 'weapon')
else
OpenShopMenu(k)
end
end
DrawMarker(Config.Type, v.Locations[i], 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
Wait(Sleep)
end
end)
-- Enter / Exit marker events
CreateThread(function()
while true do
local Sleep = 1000
local coords = GetEntityCoords(PlayerPedId())
local isInMarker, currentZone = false, nil
for k,v in pairs(Config.Zones) do
for i=1, #v.Locations, 1 do
if #(coords - v.Locations[i]) < Config.Size.x then
Sleep = 0
isInMarker, ShopItems, currentZone, LastZone = true, v.Items, k, k
end
end
end
if isInMarker and not HasAlreadyEnteredMarker then
HasAlreadyEnteredMarker = true
TriggerEvent('esx_weaponshop:hasEnteredMarker', currentZone)
end
if not isInMarker and HasAlreadyEnteredMarker then
HasAlreadyEnteredMarker = false
TriggerEvent('esx_weaponshop:hasExitedMarker', LastZone)
end
Wait(Sleep)
end
end)
-- Key Controls
CreateThread(function()
while true do
local Sleep = 1500
if CurrentAction ~= nil then
Sleep = 0
ESX.ShowHelpNotification(CurrentActionMsg)
if IsControlJustReleased(0, 38) then
if CurrentAction == 'shop_menu' then
if Config.LicenseEnable and Config.Zones[CurrentActionData.zone].Legal then
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasWeaponLicense)
if hasWeaponLicense then
OpenShopMenu(CurrentActionData.zone)
else
OpenBuyLicenseMenu(CurrentActionData.zone)
end
end, GetPlayerServerId(PlayerId()), 'weapon')
else
OpenShopMenu(CurrentActionData.zone)
else
if ShopOpen then
ESX.UI.Menu.CloseAll()
ShopOpen = false
end
end
CurrentAction = nil
end
end
Wait(Sleep)
+141 -4
View File
@@ -1,6 +1,6 @@
Config = {}
Config.DrawDistance = 10
Config.DrawDistance = 10.0
Config.Size = { x = 1.5, y = 1.5, z = 0.5 }
Config.Color = { r = 0, g = 128, b = 255 }
Config.Type = 1
@@ -16,7 +16,76 @@ Config.Zones = {
GunShop = {
Legal = true,
Items = {},
Items = {
{
name = "WEAPON_PISTOL",
price = 500
},
{
name = "WEAPON_FLASHLIGHT",
price = 70
},
{
name = "WEAPON_MACHETE",
price = 110
},
{
name = "WEAPON_NIGHTSTICK",
price = 150
},
{
name = "WEAPON_BAT",
price = 50
},
{
name = "WEAPON_STUNGUN",
price = 60
},
{
name = "WEAPON_MICROSMG",
price = 1700
},
{
name = "WEAPON_ASSAULTRIFLE",
price = 11000
},
{
name = "WEAPON_STUNGUN",
price = 60
},
{
name = "WEAPON_SPECIALCARBINE",
price = 15000
},
{
name = "WEAPON_SNIPERRIFLE",
price = 24000
},
{
name = "WEAPON_FIREWORK",
price = 21000
},
{
name = "WEAPON_GRENADE",
price = 700
},
{
name = "WEAPON_BZGAS",
price = 200
},
{
name = "WEAPON_FIREEXTINGUISHER",
price = 100
},
{
name = "WEAPON_BALL",
price = 30
},
{
name = "WEAPON_SMOKEGRENADE",
price = 100
},
},
Locations = {
vector3(-662.1, -935.3, 20.8),
vector3(810.2, -2157.3, 28.6),
@@ -32,10 +101,78 @@ Config.Zones = {
BlackWeashop = {
Legal = false,
Items = {},
Items = {
{
name = "WEAPON_PISTOL",
price = 500
},
{
name = "WEAPON_FLASHLIGHT",
price = 70
},
{
name = "WEAPON_MACHETE",
price = 110
},
{
name = "WEAPON_NIGHTSTICK",
price = 150
},
{
name = "WEAPON_BAT",
price = 50
},
{
name = "WEAPON_STUNGUN",
price = 60
},
{
name = "WEAPON_MICROSMG",
price = 1700
},
{
name = "WEAPON_ASSAULTRIFLE",
price = 11000
},
{
name = "WEAPON_STUNGUN",
price = 60
},
{
name = "WEAPON_SPECIALCARBINE",
price = 15000
},
{
name = "WEAPON_SNIPERRIFLE",
price = 24000
},
{
name = "WEAPON_FIREWORK",
price = 21000
},
{
name = "WEAPON_GRENADE",
price = 700
},
{
name = "WEAPON_BZGAS",
price = 200
},
{
name = "WEAPON_FIREEXTINGUISHER",
price = 100
},
{
name = "WEAPON_BALL",
price = 30
},
{
name = "WEAPON_SMOKEGRENADE",
price = 100
},
},
Locations = {
vector3(-1306.2, -394.0, 35.6)
}
}
}
+1 -54
View File
@@ -1,58 +1,5 @@
USE `es_extended`;
CREATE TABLE `weashops` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`zone` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`price` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `licenses` (`type`, `label`) VALUES
('weapon', "Permis de port d'arme")
;
INSERT INTO `weashops` (`zone`, `item`, `price`) VALUES
('GunShop','WEAPON_PISTOL', 300),
('BlackWeashop','WEAPON_PISTOL', 500),
('GunShop', 'WEAPON_FLASHLIGHT', 60),
('BlackWeashop', 'WEAPON_FLASHLIGHT', 70),
('GunShop', 'WEAPON_MACHETE', 90),
('BlackWeashop', 'WEAPON_MACHETE', 110),
('GunShop', 'WEAPON_NIGHTSTICK', 150),
('BlackWeashop', 'WEAPON_NIGHTSTICK', 150),
('GunShop', 'WEAPON_BAT', 100),
('BlackWeashop', 'WEAPON_BAT', 100),
('GunShop', 'WEAPON_STUNGUN', 50),
('BlackWeashop', 'WEAPON_STUNGUN', 50),
('GunShop', 'WEAPON_MICROSMG', 1400),
('BlackWeashop', 'WEAPON_MICROSMG', 1700),
('GunShop', 'WEAPON_PUMPSHOTGUN', 3400),
('BlackWeashop', 'WEAPON_PUMPSHOTGUN', 3500),
('GunShop', 'WEAPON_ASSAULTRIFLE', 10000),
('BlackWeashop', 'WEAPON_ASSAULTRIFLE', 11000),
('GunShop', 'WEAPON_SPECIALCARBINE', 15000),
('BlackWeashop', 'WEAPON_SPECIALCARBINE', 16500),
('GunShop', 'WEAPON_SNIPERRIFLE', 22000),
('BlackWeashop', 'WEAPON_SNIPERRIFLE', 24000),
('GunShop', 'WEAPON_FIREWORK', 18000),
('BlackWeashop', 'WEAPON_FIREWORK', 20000),
('GunShop', 'WEAPON_GRENADE', 500),
('BlackWeashop', 'WEAPON_GRENADE', 650),
('GunShop', 'WEAPON_BZGAS', 200),
('BlackWeashop', 'WEAPON_BZGAS', 350),
('GunShop', 'WEAPON_FIREEXTINGUISHER', 100),
('BlackWeashop', 'WEAPON_FIREEXTINGUISHER', 100),
('GunShop', 'WEAPON_BALL', 50),
('BlackWeashop', 'WEAPON_BALL', 50),
('GunShop', 'WEAPON_SMOKEGRENADE', 100),
('BlackWeashop', 'WEAPON_SMOKEGRENADE', 100),
('BlackWeashop', 'WEAPON_APPISTOL', 1100),
('BlackWeashop', 'WEAPON_CARBINERIFLE', 12000),
('BlackWeashop', 'WEAPON_HEAVYSNIPER', 30000),
('BlackWeashop', 'WEAPON_MINIGUN', 45000),
('BlackWeashop', 'WEAPON_RAILGUN', 50000),
('BlackWeashop', 'WEAPON_STICKYBOMB', 500)
('weapon', "Weapon licence")
;
@@ -14,7 +14,6 @@ shared_scripts {
}
server_scripts {
'@oxmysql/lib/MySQL.lua',
'server/main.lua'
}
+9 -31
View File
@@ -1,28 +1,3 @@
local shopItems = {}
MySQL.ready(function()
MySQL.query('SELECT * FROM weashops', function(result)
for i=1, #result, 1 do
if shopItems[result[i].zone] == nil then
shopItems[result[i].zone] = {}
end
table.insert(shopItems[result[i].zone], {
item = result[i].item,
price = result[i].price,
label = ESX.GetWeaponLabel(result[i].item)
})
end
TriggerClientEvent('esx_weaponshop:sendShop', -1, shopItems)
end)
end)
ESX.RegisterServerCallback('esx_weaponshop:getShop', function(source, cb)
cb(shopItems)
end)
ESX.RegisterServerCallback('esx_weaponshop:buyLicense', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
@@ -77,13 +52,16 @@ ESX.RegisterServerCallback('esx_weaponshop:buyWeapon', function(source, cb, weap
end)
function GetPrice(weaponName, zone)
local price = MySQL.scalar.await('SELECT price FROM weashops WHERE zone = @zone AND item = @item', {
['@zone'] = zone,
['@item'] = weaponName
})
local weapon = nil
for k,v in pairs(Config.Zones[zone].items) do
if v.name == weaponName then
weapon = v
break
end
end
if price then
return price
if weapon then
return v.price
else
return 0
end
-26
View File
@@ -1,32 +1,6 @@
# esx_whitelist
## Download & Installation
### Using [fvm](https://github.com/qlaffont/fvm-installer)
```
fvm install --save --folder=esx esx-org/esx_whitelist
```
### Using Git
```
cd resources
git clone https://github.com/ESX-Org/esx_whitelist [esx]/esx_whitelist
```
### Manually
- Download https://github.com/ESX-Org/esx_whitelist/archive/master.zip
- Put it in the `[esx]` directory
## Installation
- Import `esx_whitelist.sql` to your database
- Add this in your `server.cfg`:
```
start esx_whitelist
```
# Legal
### License
esx_whitelist - Whitelist script
Copyright (C) 2015-2022 Jérémie N'gadi
@@ -1,8 +0,0 @@
USE `es_extended`;
CREATE TABLE `whitelist` (
`identifier` varchar(60) NOT NULL,
PRIMARY KEY (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+3 -3
View File
@@ -6,12 +6,12 @@ description 'ESX Whitelist'
version '1.6.5'
server_only 'yes'
server_scripts {
'@es_extended/imports.lua',
'@oxmysql/lib/MySQL.lua',
'@es_extended/locale.lua',
'config.lua',
'locales/*.lua',
'server/main.lua',
'server/commands.lua'
'server/main.lua'
}
+4 -4
View File
@@ -1,8 +1,8 @@
Locales['en'] = {
['whitelist_check'] = 'making sure you\'re whitelisted on this server . . .',
['not_whitelisted'] = 'you are not whitelisted on this server',
['whitelist_empty'] = 'the whitelist hasn\'t been loaded yet, or alternatively no one has been whitelisted!',
['license_missing'] = 'your license could not be found',
['whitelist_check'] = 'Checking you are Allowlisted.',
['not_whitelisted'] = 'You Must be Allowlisted to join this server!',
['whitelist_empty'] = 'There Are no whitelists saved for this server.',
['license_missing'] = 'Error: Your Identifier is missing!',
['help_whitelist_add'] = 'add someone to the whitelist',
['help_whitelist_load'] = 'reload the whitelist',
}
+1
View File
@@ -0,0 +1 @@
[]
@@ -1,26 +0,0 @@
ESX.RegisterCommand('wlrefresh', 'admin', function(xPlayer, args, showError)
loadWhiteList(function()
showError('Whitelist reloaded')
end)
end, true, {help = _U('help_whitelist_load')})
ESX.RegisterCommand('wladd', 'admin', function(xPlayer, args, showError)
args.license = args.license:lower()
if string.len(args.license) == 40 then
if WhiteList[args.license] then
showError('The player is already whitelisted on this server!')
else
MySQL.update('INSERT INTO whitelist (identifier) VALUES (@identifier)', {
['@identifier'] = args.license
}, function(rowsChanged)
WhiteList[args.license] = true
showError('The player has been whitelisted!')
end)
end
else
showError('Invalid license ID length!')
end
end, true, {help = _U('help_whitelist_add'), validate = true, arguments = {
{name = 'license', help = 'the player license', type = 'string'}
}})
+44 -17
View File
@@ -1,28 +1,20 @@
WhiteList = {}
function loadWhiteList(cb)
Whitelist = {}
function loadWhiteList()
Whitelist = nil
MySQL.query('SELECT identifier FROM whitelist', function(result)
for k,v in ipairs(result) do
WhiteList[v.identifier] = true
end
if cb then
cb()
end
end)
local List = LoadResourceFile(GetCurrentResourceName(),'players.json')
if List then
Whitelist = json.decode(List)
end
end
MySQL.ready(function()
loadWhiteList()
end)
loadWhiteList()
AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
if #GetPlayers() < Config.MinPlayer then
if #(GetPlayers()) < Config.MinPlayer then
deferrals.done()
end
else
-- Mark this connection as deferred, this is to prevent problems while checking player identifiers.
deferrals.defer()
@@ -49,4 +41,39 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
else
deferrals.done()
end
end
end)
ESX.RegisterCommand('wlrefresh', 'admin', function(xPlayer, args, showError)
loadWhiteList(function()
showError('Whitelist reloaded')
end)
end, true, {help = _U('help_whitelist_load')})
ESX.RegisterCommand('wladd', 'admin', function(xPlayer, args, showError)
args.license = args.license:lower()
if WhiteList[args.license] then
showError('The player is already allowlisted on this server!')
else
WhiteList[args.license] = true
SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(WhiteList))
loadWhiteList()
end
end, true, {help = _U('help_whitelist_add'), validate = true, arguments = {
{name = 'license', help = 'the player license', type = 'string'}
}})
ESX.RegisterCommand('wlremove', 'admin', function(xPlayer, args, showError)
args.license = args.license:lower()
if WhiteList[args.license] then
WhiteList[args.license] = nil
SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(WhiteList))
loadWhiteList()
else
showError('Identifier is not Allowlisted on this server!')
end
end, true, {help = _U('help_whitelist_add'), validate = true, arguments = {
{name = 'license', help = 'the player license', type = 'string'}
}})
+1 -1
View File
@@ -1,4 +1,4 @@
<h1 align='center'>ESX Legacy</a></h1><p align='center'><b><a href='https://discord.gg/cNx6HF9P5J'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>ESX Legacy</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
**IMPORTANT**: ESX Legacy now supports ox Inventory. **HOWEVER, THIS SHOULD ONLY BE USED IF YOU ARE EXPERIENCED AND KNOW WHAT YOU ARE DOING**.