mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
Use new ESX function, secutiy fixes and cleanup
This commit is contained in:
+15
-39
@@ -490,30 +490,26 @@ function OpenMobileMecanoActionsMenu()
|
||||
|
||||
if data.current.value == 'del_vehicle' then
|
||||
|
||||
local ped = GetPlayerPed( -1 )
|
||||
local ped = GetPlayerPed(-1)
|
||||
|
||||
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then
|
||||
if DoesEntityExist(ped) and not IsEntityDead(ped) then
|
||||
local pos = GetEntityCoords( ped )
|
||||
|
||||
if ( IsPedSittingInAnyVehicle( ped ) ) then
|
||||
if IsPedSittingInAnyVehicle(ped) then
|
||||
local vehicle = GetVehiclePedIsIn( ped, false )
|
||||
|
||||
if ( GetPedInVehicleSeat( vehicle, -1 ) == ped ) then
|
||||
if GetPedInVehicleSeat(vehicle, -1) == ped then
|
||||
ESX.ShowNotification(_U('vehicle_impounded'))
|
||||
SetEntityAsMissionEntity( vehicle, true, true )
|
||||
deleteCar( vehicle )
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
else
|
||||
ESX.ShowNotification(_U('must_seat_driver'))
|
||||
end
|
||||
else
|
||||
local playerPos = GetEntityCoords( ped, 1 )
|
||||
local inFrontOfPlayer = GetOffsetFromEntityInWorldCoords( ped, 0.0, distanceToCheck, 0.0 )
|
||||
local vehicle = GetVehicleInDirection( playerPos, inFrontOfPlayer )
|
||||
local vehicle = ESX.Game.GetVehicleInDirection()
|
||||
|
||||
if ( DoesEntityExist( vehicle ) ) then
|
||||
if DoesEntityExist(vehicle) then
|
||||
ESX.ShowNotification(_U('vehicle_impounded'))
|
||||
SetEntityAsMissionEntity( vehicle, true, true )
|
||||
deleteCar( vehicle )
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
else
|
||||
ESX.ShowNotification(_U('must_near'))
|
||||
end
|
||||
@@ -530,10 +526,7 @@ function OpenMobileMecanoActionsMenu()
|
||||
local isVehicleTow = IsVehicleModel(vehicle, towmodel)
|
||||
|
||||
if isVehicleTow then
|
||||
|
||||
local coordA = GetEntityCoords(playerped, 1)
|
||||
local coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 5.0, 0.0)
|
||||
local targetVehicle = getVehicleInDirection(coordA, coordB)
|
||||
local targetVehicle = ESX.Game.GetVehicleInDirection()
|
||||
|
||||
if CurrentlyTowedVehicle == nil then
|
||||
if targetVehicle ~= 0 then
|
||||
@@ -656,11 +649,7 @@ function OpenMobileMecanoActionsMenu()
|
||||
end
|
||||
|
||||
function OpenGetStocksMenu()
|
||||
|
||||
ESX.TriggerServerCallback('esx_mecanojob:getStockItems', function(items)
|
||||
|
||||
print(json.encode(items))
|
||||
|
||||
local elements = {}
|
||||
|
||||
for i=1, #items, 1 do
|
||||
@@ -692,9 +681,10 @@ function OpenGetStocksMenu()
|
||||
else
|
||||
menu2.close()
|
||||
menu.close()
|
||||
OpenGetStocksMenu()
|
||||
|
||||
TriggerServerEvent('esx_mecanojob:getStockItem', itemName, count)
|
||||
|
||||
Citizen.Wait(1000)
|
||||
OpenGetStocksMenu()
|
||||
end
|
||||
|
||||
end,
|
||||
@@ -754,9 +744,10 @@ ESX.TriggerServerCallback('esx_mecanojob:getPlayerInventory', function(inventory
|
||||
else
|
||||
menu2.close()
|
||||
menu.close()
|
||||
OpenPutStocksMenu()
|
||||
|
||||
TriggerServerEvent('esx_mecanojob:putStockItems', itemName, count)
|
||||
|
||||
Citizen.Wait(1000)
|
||||
OpenPutStocksMenu()
|
||||
end
|
||||
|
||||
end,
|
||||
@@ -874,21 +865,6 @@ AddEventHandler('esx_mecanojob:onFixkit', function()
|
||||
end
|
||||
end)
|
||||
|
||||
function setEntityHeadingFromEntity ( vehicle, playerPed )
|
||||
local heading = GetEntityHeading(vehicle)
|
||||
SetEntityHeading( playerPed, heading )
|
||||
end
|
||||
|
||||
function getVehicleInDirection(coordFrom, coordTo)
|
||||
local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed(-1), 0)
|
||||
local a, b, c, d, vehicle = GetRaycastResult(rayHandle)
|
||||
return vehicle
|
||||
end
|
||||
|
||||
function deleteCar( entity )
|
||||
Citizen.InvokeNative( 0xEA386986E786A54F, Citizen.PointerValueIntInitialized( entity ) )
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
PlayerData = xPlayer
|
||||
|
||||
@@ -79,4 +79,5 @@ Locales['br'] = {
|
||||
['you_used_body_kit'] = 'Você usou um ~b~Kit de corpo',
|
||||
['you_removed'] = 'Você removeu x',
|
||||
['you_added'] = 'Você adicionou x',
|
||||
['player_cannot_hold'] = 'you do ~r~not~w~ have enough ~y~free space~w~ in your inventory!',
|
||||
}
|
||||
|
||||
@@ -79,4 +79,5 @@ Locales['en'] = {
|
||||
['you_used_body_kit'] = 'you used a ~b~Body Kit',
|
||||
['you_removed'] = 'you have removed x',
|
||||
['you_added'] = 'you have added x',
|
||||
['player_cannot_hold'] = 'you do ~r~not~w~ have enough ~y~free space~w~ in your inventory!',
|
||||
}
|
||||
|
||||
@@ -80,4 +80,5 @@ Locales['fr'] = {
|
||||
['you_used_body_kit'] = 'Vous avez utilisé un ~b~Kit de carosserie',
|
||||
['you_removed'] = 'vous avez retiré x',
|
||||
['you_added'] = 'Vous avez ajouté x',
|
||||
['player_cannot_hold'] = 'you do ~r~not~w~ have enough ~y~free space~w~ in your inventory!',
|
||||
}
|
||||
|
||||
+2
-1
@@ -78,5 +78,6 @@ Locales['sv'] = {
|
||||
['you_used_repair_kit'] = 'du har använt en ~b~reparationssats~s~',
|
||||
['you_used_body_kit'] = 'du har använt en ~b~karossverktyg~s~',
|
||||
['you_removed'] = 'du har ~r~tagit bort~s~ x',
|
||||
['you_added'] = 'du ~y~la till~s~ x'
|
||||
['you_added'] = 'du ~y~la till~s~ x',
|
||||
['player_cannot_hold'] = 'du har ~r~inte~w~ tillräckligt med ~y~utrymme~w~ för att hålla det!',
|
||||
}
|
||||
+37
-61
@@ -15,8 +15,6 @@ end
|
||||
TriggerEvent('esx_phone:registerNumber', 'mecano', _U('mechanic_customer'), true, true)
|
||||
TriggerEvent('esx_society:registerSociety', 'mecano', 'Mecano', 'society_mecano', 'society_mecano', 'society_mecano', {type = 'private'})
|
||||
|
||||
-------------- Récupération bouteille de gaz -------------
|
||||
---- Sqlut je teste ------
|
||||
local function Harvest(source)
|
||||
|
||||
SetTimeout(4000, function()
|
||||
@@ -29,8 +27,7 @@ local function Harvest(source)
|
||||
if GazBottleQuantity >= 5 then
|
||||
TriggerClientEvent('esx:showNotification', source, _U('you_do_not_room'))
|
||||
else
|
||||
xPlayer.addInventoryItem('gazbottle', 1)
|
||||
|
||||
xPlayer.addInventoryItem('gazbottle', 1)
|
||||
Harvest(source)
|
||||
end
|
||||
end
|
||||
@@ -62,8 +59,7 @@ local function Harvest2(source)
|
||||
if FixToolQuantity >= 5 then
|
||||
TriggerClientEvent('esx:showNotification', source, _U('you_do_not_room'))
|
||||
else
|
||||
xPlayer.addInventoryItem('fixtool', 1)
|
||||
|
||||
xPlayer.addInventoryItem('fixtool', 1)
|
||||
Harvest2(source)
|
||||
end
|
||||
end
|
||||
@@ -83,7 +79,7 @@ AddEventHandler('esx_mecanojob:stopHarvest2', function()
|
||||
local _source = source
|
||||
PlayersHarvesting2[_source] = false
|
||||
end)
|
||||
----------------- Récupération Outils Carosserie ----------------
|
||||
|
||||
local function Harvest3(source)
|
||||
|
||||
SetTimeout(4000, function()
|
||||
@@ -92,11 +88,10 @@ local function Harvest3(source)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local CaroToolQuantity = xPlayer.getInventoryItem('carotool').count
|
||||
if CaroToolQuantity >= 5 then
|
||||
if CaroToolQuantity >= 5 then
|
||||
TriggerClientEvent('esx:showNotification', source, _U('you_do_not_room'))
|
||||
else
|
||||
xPlayer.addInventoryItem('carotool', 1)
|
||||
|
||||
xPlayer.addInventoryItem('carotool', 1)
|
||||
Harvest3(source)
|
||||
end
|
||||
end
|
||||
@@ -116,7 +111,7 @@ AddEventHandler('esx_mecanojob:stopHarvest3', function()
|
||||
local _source = source
|
||||
PlayersHarvesting3[_source] = false
|
||||
end)
|
||||
------------ Craft Chalumeau -------------------
|
||||
|
||||
local function Craft(source)
|
||||
|
||||
SetTimeout(4000, function()
|
||||
@@ -129,9 +124,8 @@ local function Craft(source)
|
||||
if GazBottleQuantity <= 0 then
|
||||
TriggerClientEvent('esx:showNotification', source, _U('not_enough_gas_can'))
|
||||
else
|
||||
xPlayer.removeInventoryItem('gazbottle', 1)
|
||||
xPlayer.addInventoryItem('blowpipe', 1)
|
||||
|
||||
xPlayer.removeInventoryItem('gazbottle', 1)
|
||||
xPlayer.addInventoryItem('blowpipe', 1)
|
||||
Craft(source)
|
||||
end
|
||||
end
|
||||
@@ -151,7 +145,7 @@ AddEventHandler('esx_mecanojob:stopCraft', function()
|
||||
local _source = source
|
||||
PlayersCrafting[_source] = false
|
||||
end)
|
||||
------------ Craft kit Réparation --------------
|
||||
|
||||
local function Craft2(source)
|
||||
|
||||
SetTimeout(4000, function()
|
||||
@@ -163,9 +157,8 @@ local function Craft2(source)
|
||||
if FixToolQuantity <= 0 then
|
||||
TriggerClientEvent('esx:showNotification', source, _U('not_enough_repair_tools'))
|
||||
else
|
||||
xPlayer.removeInventoryItem('fixtool', 1)
|
||||
xPlayer.addInventoryItem('fixkit', 1)
|
||||
|
||||
xPlayer.removeInventoryItem('fixtool', 1)
|
||||
xPlayer.addInventoryItem('fixkit', 1)
|
||||
Craft2(source)
|
||||
end
|
||||
end
|
||||
@@ -185,7 +178,7 @@ AddEventHandler('esx_mecanojob:stopCraft2', function()
|
||||
local _source = source
|
||||
PlayersCrafting2[_source] = false
|
||||
end)
|
||||
----------------- Craft kit Carosserie ----------------
|
||||
|
||||
local function Craft3(source)
|
||||
|
||||
SetTimeout(4000, function()
|
||||
@@ -197,9 +190,8 @@ local function Craft3(source)
|
||||
if CaroToolQuantity <= 0 then
|
||||
TriggerClientEvent('esx:showNotification', source, _U('not_enough_body_tools'))
|
||||
else
|
||||
xPlayer.removeInventoryItem('carotool', 1)
|
||||
xPlayer.addInventoryItem('carokit', 1)
|
||||
|
||||
xPlayer.removeInventoryItem('carotool', 1)
|
||||
xPlayer.addInventoryItem('carokit', 1)
|
||||
Craft3(source)
|
||||
end
|
||||
end
|
||||
@@ -220,8 +212,6 @@ AddEventHandler('esx_mecanojob:stopCraft3', function()
|
||||
PlayersCrafting3[_source] = false
|
||||
end)
|
||||
|
||||
---------------------------- NPC Job Earnings ------------------------------------------------------
|
||||
|
||||
RegisterServerEvent('esx_mecanojob:onNPCJobMissionCompleted')
|
||||
AddEventHandler('esx_mecanojob:onNPCJobMissionCompleted', function()
|
||||
|
||||
@@ -241,7 +231,6 @@ AddEventHandler('esx_mecanojob:onNPCJobMissionCompleted', function()
|
||||
|
||||
end)
|
||||
|
||||
---------------------------- register usable item --------------------------------------------------
|
||||
ESX.RegisterUsableItem('blowpipe', function(source)
|
||||
|
||||
local _source = source
|
||||
@@ -250,7 +239,7 @@ ESX.RegisterUsableItem('blowpipe', function(source)
|
||||
xPlayer.removeInventoryItem('blowpipe', 1)
|
||||
|
||||
TriggerClientEvent('esx_mecanojob:onHijack', _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_used_blowtorch'))
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_used_blowtorch'))
|
||||
|
||||
end)
|
||||
|
||||
@@ -262,7 +251,7 @@ ESX.RegisterUsableItem('fixkit', function(source)
|
||||
xPlayer.removeInventoryItem('fixkit', 1)
|
||||
|
||||
TriggerClientEvent('esx_mecanojob:onFixkit', _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_used_repair_kit'))
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_used_repair_kit'))
|
||||
|
||||
end)
|
||||
|
||||
@@ -274,34 +263,33 @@ ESX.RegisterUsableItem('carokit', function(source)
|
||||
xPlayer.removeInventoryItem('carokit', 1)
|
||||
|
||||
TriggerClientEvent('esx_mecanojob:onCarokit', _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_used_body_kit'))
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('you_used_body_kit'))
|
||||
|
||||
end)
|
||||
|
||||
----------------------------------
|
||||
---- Ajout Gestion Stock Boss ----
|
||||
----------------------------------
|
||||
|
||||
RegisterServerEvent('esx_mecanojob:getStockItem')
|
||||
AddEventHandler('esx_mecanojob:getStockItem', function(itemName, count)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mecano', function(inventory)
|
||||
|
||||
local item = inventory.getItem(itemName)
|
||||
|
||||
if item.count >= count then
|
||||
inventory.removeItem(itemName, count)
|
||||
xPlayer.addInventoryItem(itemName, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_quantity'))
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_removed') .. count .. ' ' .. item.label)
|
||||
|
||||
end)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mecano', function(inventory)
|
||||
local item = inventory.getItem(itemName)
|
||||
local sourceItem = xPlayer.getInventoryItem(itemName)
|
||||
|
||||
-- is there enough in the society?
|
||||
if count > 0 and item.count >= count then
|
||||
|
||||
-- can the player carry the said amount of x item?
|
||||
if sourceItem.limit ~= -1 and (sourceItem.count + count) > sourceItem.limit then
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('player_cannot_hold'))
|
||||
else
|
||||
inventory.removeItem(itemName, count)
|
||||
xPlayer.addInventoryItem(itemName, count)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn', count, item.label))
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_quantity'))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_mecanojob:getStockItems', function(source, cb)
|
||||
@@ -312,10 +300,6 @@ ESX.RegisterServerCallback('esx_mecanojob:getStockItems', function(source, cb)
|
||||
|
||||
end)
|
||||
|
||||
-------------
|
||||
-- AJOUT 2 --
|
||||
-------------
|
||||
|
||||
RegisterServerEvent('esx_mecanojob:putStockItems')
|
||||
AddEventHandler('esx_mecanojob:putStockItems', function(itemName, count)
|
||||
|
||||
@@ -339,14 +323,6 @@ AddEventHandler('esx_mecanojob:putStockItems', function(itemName, count)
|
||||
|
||||
end)
|
||||
|
||||
--ESX.RegisterServerCallback('esx_mecanojob:putStockItems', function(source, cb)
|
||||
|
||||
-- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_policestock', function(inventory)
|
||||
-- cb(inventory.items)
|
||||
-- end)
|
||||
|
||||
--end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_mecanojob:getPlayerInventory', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
Reference in New Issue
Block a user