Skip to content

Commit c772d7d

Browse files
committed
refactor: esx inv into menu_default & separate resource
1 parent 2c285e1 commit c772d7d

41 files changed

Lines changed: 971 additions & 1009 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

[core]/es_extended/client/functions.lua

Lines changed: 1 addition & 264 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,275 +1270,12 @@ function ESX.GetAccount(account)
12701270
return nil
12711271
end
12721272

1273-
---@return nil
12741273
function ESX.ShowInventory()
12751274
if not Config.EnableDefaultInventory then
12761275
return
12771276
end
12781277

1279-
local playerPed = ESX.PlayerData.ped
1280-
local elements = {
1281-
{ unselectable = true, icon = "fas fa-box" },
1282-
}
1283-
local currentWeight = 0
1284-
1285-
for i = 1, #ESX.PlayerData.accounts do
1286-
if ESX.PlayerData.accounts[i].money > 0 then
1287-
local formattedMoney = TranslateCap("locale_currency", ESX.Math.GroupDigits(ESX.PlayerData.accounts[i].money))
1288-
local canDrop = ESX.PlayerData.accounts[i].name ~= "bank"
1289-
1290-
elements[#elements + 1] = {
1291-
icon = "fas fa-money-bill-wave",
1292-
title = ('%s: <span style="color:green;">%s</span>'):format(ESX.PlayerData.accounts[i].label, formattedMoney),
1293-
count = ESX.PlayerData.accounts[i].money,
1294-
type = "item_account",
1295-
value = ESX.PlayerData.accounts[i].name,
1296-
usable = false,
1297-
rare = false,
1298-
canRemove = canDrop,
1299-
}
1300-
end
1301-
end
1302-
1303-
for i = 1, #ESX.PlayerData.inventory do
1304-
local v = ESX.PlayerData.inventory[i]
1305-
if v.count > 0 then
1306-
currentWeight = currentWeight + (v.weight * v.count)
1307-
1308-
elements[#elements + 1] = {
1309-
icon = "fas fa-box",
1310-
title = ("%s x%s"):format(v.label, v.count),
1311-
count = v.count,
1312-
type = "item_standard",
1313-
value = v.name,
1314-
usable = v.usable,
1315-
rare = v.rare,
1316-
canRemove = v.canRemove,
1317-
}
1318-
end
1319-
end
1320-
1321-
elements[1].title = TranslateCap("inventory", currentWeight, Config.MaxWeight)
1322-
1323-
for i = 1, #Config.Weapons do
1324-
local v = Config.Weapons[i]
1325-
local weaponHash = joaat(v.name)
1326-
1327-
if HasPedGotWeapon(playerPed, weaponHash, false) then
1328-
local ammo = GetAmmoInPedWeapon(playerPed, weaponHash)
1329-
1330-
elements[#elements + 1] = {
1331-
icon = "fas fa-gun",
1332-
title = v.ammo and ("%s - %s %s"):format(v.label, ammo, v.ammo.label) or v.label,
1333-
count = 1,
1334-
type = "item_weapon",
1335-
value = v.name,
1336-
usable = false,
1337-
rare = false,
1338-
ammo = ammo,
1339-
canGiveAmmo = (v.ammo ~= nil),
1340-
canRemove = true,
1341-
}
1342-
end
1343-
end
1344-
1345-
ESX.CloseContext()
1346-
1347-
ESX.OpenContext("right", elements, function(_, element)
1348-
local player, distance = ESX.Game.GetClosestPlayer()
1349-
1350-
local elements2 = {}
1351-
1352-
if element.usable then
1353-
elements2[#elements2 + 1] = {
1354-
icon = "fas fa-utensils",
1355-
title = TranslateCap("use"),
1356-
action = "use",
1357-
type = element.type,
1358-
value = element.value,
1359-
}
1360-
end
1361-
1362-
if element.canRemove then
1363-
if player ~= -1 and distance <= 3.0 then
1364-
elements2[#elements2 + 1] = {
1365-
icon = "fas fa-hands",
1366-
title = TranslateCap("give"),
1367-
action = "give",
1368-
type = element.type,
1369-
value = element.value,
1370-
}
1371-
end
1372-
1373-
elements2[#elements2 + 1] = {
1374-
icon = "fas fa-trash",
1375-
title = TranslateCap("remove"),
1376-
action = "remove",
1377-
type = element.type,
1378-
value = element.value,
1379-
}
1380-
end
1381-
1382-
if element.type == "item_weapon" and element.canGiveAmmo and element.ammo > 0 and player ~= -1 and distance <= 3.0 then
1383-
elements2[#elements2 + 1] = {
1384-
icon = "fas fa-gun",
1385-
title = TranslateCap("giveammo"),
1386-
action = "give_ammo",
1387-
type = element.type,
1388-
value = element.value,
1389-
}
1390-
end
1391-
1392-
elements2[#elements2 + 1] = {
1393-
icon = "fas fa-arrow-left",
1394-
title = TranslateCap("return"),
1395-
action = "return",
1396-
}
1397-
1398-
ESX.OpenContext("right", elements2, function(_, element2)
1399-
local item, itemType = element2.value, element2.type
1400-
1401-
if element2.action == "give" then
1402-
local playersNearby = ESX.Game.GetPlayersInArea(GetEntityCoords(playerPed), 3.0)
1403-
1404-
if #playersNearby > 0 then
1405-
local players = {}
1406-
local elements3 = {
1407-
{ unselectable = true, icon = "fas fa-users", title = "Nearby Players" },
1408-
}
1409-
1410-
for currentNearbyPlayerIndex = 1, #playersNearby do
1411-
players[GetPlayerServerId(playersNearby[currentNearbyPlayerIndex])] = true
1412-
end
1413-
1414-
ESX.TriggerServerCallback("esx:getPlayerNames", function(returnedPlayers)
1415-
for playerId, playerName in pairs(returnedPlayers) do
1416-
elements3[#elements3 + 1] = {
1417-
icon = "fas fa-user",
1418-
title = playerName,
1419-
playerId = playerId,
1420-
}
1421-
end
1422-
1423-
ESX.OpenContext("right", elements3, function(_, element3)
1424-
local selectedPlayer, selectedPlayerId = GetPlayerFromServerId(element3.playerId), element3.playerId
1425-
playersNearby = ESX.Game.GetPlayersInArea(GetEntityCoords(playerPed), 3.0)
1426-
playersNearby = ESX.Table.Set(playersNearby)
1427-
1428-
if playersNearby[selectedPlayer] then
1429-
local selectedPlayerPed = GetPlayerPed(selectedPlayer)
1430-
1431-
if IsPedOnFoot(selectedPlayerPed) and not IsPedFalling(selectedPlayerPed) then
1432-
if itemType == "item_weapon" then
1433-
TriggerServerEvent("esx:giveInventoryItem", selectedPlayerId, itemType, item, nil)
1434-
ESX.CloseContext()
1435-
else
1436-
local elementsG = {
1437-
{ unselectable = true, icon = "fas fa-trash", title = element.title },
1438-
{ icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to give..", inputMin = 1, inputMax = 1000 },
1439-
{ icon = "fas fa-check-double", title = "Confirm", val = "confirm" },
1440-
}
1441-
1442-
ESX.OpenContext("right", elementsG, function(menuG, _)
1443-
local quantity = tonumber(menuG.eles[2].inputValue)
1444-
1445-
if quantity and quantity > 0 and element.count >= quantity then
1446-
TriggerServerEvent("esx:giveInventoryItem", selectedPlayerId, itemType, item, quantity)
1447-
ESX.CloseContext()
1448-
else
1449-
ESX.ShowNotification(TranslateCap("amount_invalid"))
1450-
end
1451-
end)
1452-
end
1453-
else
1454-
ESX.ShowNotification(TranslateCap("in_vehicle"))
1455-
end
1456-
else
1457-
ESX.ShowNotification(TranslateCap("players_nearby"))
1458-
ESX.CloseContext()
1459-
end
1460-
end)
1461-
end, players)
1462-
end
1463-
elseif element2.action == "remove" then
1464-
if IsPedOnFoot(playerPed) and not IsPedFalling(playerPed) then
1465-
local dict, anim = "weapons@first_person@aim_rng@generic@projectile@sticky_bomb@", "plant_floor"
1466-
ESX.Streaming.RequestAnimDict(dict)
1467-
1468-
if itemType == "item_weapon" then
1469-
ESX.CloseContext()
1470-
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
1471-
RemoveAnimDict(dict)
1472-
Wait(1000)
1473-
TriggerServerEvent("esx:removeInventoryItem", itemType, item)
1474-
else
1475-
local elementsR = {
1476-
{ unselectable = true, icon = "fas fa-trash", title = element.title },
1477-
{ icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to remove..", inputMin = 1, inputMax = 1000 },
1478-
{ icon = "fas fa-check-double", title = "Confirm", val = "confirm" },
1479-
}
1480-
1481-
ESX.OpenContext("right", elementsR, function(menuR, _)
1482-
local quantity = tonumber(menuR.eles[2].inputValue)
1483-
1484-
if quantity and quantity > 0 and element.count >= quantity then
1485-
ESX.CloseContext()
1486-
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
1487-
RemoveAnimDict(dict)
1488-
Wait(1000)
1489-
TriggerServerEvent("esx:removeInventoryItem", itemType, item, quantity)
1490-
else
1491-
ESX.ShowNotification(TranslateCap("amount_invalid"))
1492-
end
1493-
end)
1494-
end
1495-
end
1496-
elseif element2.action == "use" then
1497-
ESX.CloseContext()
1498-
TriggerServerEvent("esx:useItem", item)
1499-
elseif element2.action == "return" then
1500-
ESX.CloseContext()
1501-
ESX.ShowInventory()
1502-
elseif element2.action == "give_ammo" then
1503-
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
1504-
local closestPed = GetPlayerPed(closestPlayer)
1505-
local pedAmmo = GetAmmoInPedWeapon(playerPed, joaat(item))
1506-
1507-
if IsPedOnFoot(closestPed) and not IsPedFalling(closestPed) then
1508-
if closestPlayer ~= -1 and closestDistance < 3.0 then
1509-
if pedAmmo > 0 then
1510-
local elementsGA = {
1511-
{ unselectable = true, icon = "fas fa-trash", title = element.title },
1512-
{ icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to give..", inputMin = 1, inputMax = 1000 },
1513-
{ icon = "fas fa-check-double", title = "Confirm", val = "confirm" },
1514-
}
1515-
1516-
ESX.OpenContext("right", elementsGA, function(menuGA, _)
1517-
local quantity = tonumber(menuGA.eles[2].inputValue)
1518-
1519-
if quantity and quantity > 0 then
1520-
if pedAmmo >= quantity then
1521-
TriggerServerEvent("esx:giveInventoryItem", GetPlayerServerId(closestPlayer), "item_ammo", item, quantity)
1522-
ESX.CloseContext()
1523-
else
1524-
ESX.ShowNotification(TranslateCap("noammo"))
1525-
end
1526-
else
1527-
ESX.ShowNotification(TranslateCap("amount_invalid"))
1528-
end
1529-
end)
1530-
else
1531-
ESX.ShowNotification(TranslateCap("noammo"))
1532-
end
1533-
else
1534-
ESX.ShowNotification(TranslateCap("players_nearby"))
1535-
end
1536-
else
1537-
ESX.ShowNotification(TranslateCap("in_vehicle"))
1538-
end
1539-
end
1540-
end)
1541-
end)
1278+
exports.esx_inventory:ShowInventory()
15421279
end
15431280

15441281
RegisterNetEvent('esx:showNotification', ESX.ShowNotification)

[core]/es_extended/client/modules/events.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,6 @@ function StartServerSyncLoops()
348348
end)
349349
end
350350

351-
if not Config.CustomInventory and Config.EnableDefaultInventory then
352-
ESX.RegisterInput("showinv", TranslateCap("keymap_showinventory"), "keyboard", "F2", function()
353-
if not ESX.PlayerData.dead then
354-
ESX.ShowInventory()
355-
end
356-
end)
357-
end
358-
359351
if not Config.CustomInventory then
360352
CreateThread(function()
361353
while true do

[core]/es_extended/locales/cs.lua

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,4 @@
11
return {
2-
-- Inventory
3-
["inventory"] = "Inventář ( Váha %s / %s )",
4-
["use"] = "Použít",
5-
["give"] = "Darovat",
6-
["remove"] = "Odhodit",
7-
["return"] = "Vrátit",
8-
["give_to"] = "Darováno",
9-
["amount"] = "Počet",
10-
["giveammo"] = "Podat náboje",
11-
["amountammo"] = "Počet nábojů",
12-
["noammo"] = "Nedostatek!",
13-
["gave_item"] = "Daroval %sx %s pro %s",
14-
["received_item"] = "Získáno %sx %s od %s",
15-
["gave_weapon"] = "Předání %s pro %s",
16-
["gave_weapon_ammo"] = "Darování ~o~%sx %s do %s pro %s",
17-
["gave_weapon_withammo"] = "Darování %s s ~o~%sx %s pro %s",
18-
["gave_weapon_hasalready"] = "%s již vlastní %s",
19-
["gave_weapon_noweapon"] = "%s nemá tuto zbraň",
20-
["received_weapon"] = "Obdrženo %s od %s",
21-
["received_weapon_ammo"] = "Obdrženo ~o~%sx %s pro zbraň %s od %s",
22-
["received_weapon_withammo"] = "Obdrženo %s s ~o~%sx %s od %s",
23-
["received_weapon_hasalready"] = "%s se snažil darovat %s, ale již tuto zbraň máš",
24-
["received_weapon_noweapon"] = "%s se snažil ti dát náboje %s, ale nemáš potřebnou zbrań",
25-
["gave_account_money"] = "Darováno $%s (%s) pro %s",
26-
["received_account_money"] = "Získáno $%s (%s) od %s",
27-
["amount_invalid"] = "Špatné množství",
28-
["players_nearby"] = "Žádný hráč není poblíž",
29-
["ex_inv_lim"] = "Nelze sebrat,protože máš plné kapsy %s",
30-
["imp_invalid_quantity"] = "Neplatné množství",
31-
["imp_invalid_amount"] = "Nelze provést, neplatné množství",
32-
["threw_standard"] = "Zahozeno %sx %s",
33-
["threw_account"] = "Zahozeno $%s %s",
34-
["threw_weapon"] = "Zahozeno %s",
35-
["threw_weapon_ammo"] = "Zahozeno %s s ~o~%sx %s",
36-
["threw_weapon_already"] = "Již vlastníš tuto zbraň",
37-
["threw_cannot_pickup"] = "Kapsy máš plné, nemůžeš sebrat!",
38-
["threw_pickup_prompt"] = "Zmáčkni E pro sebrání!",
39-
40-
-- Key mapping
41-
["keymap_showinventory"] = "Otevřít inventář",
42-
432
-- Salary related
443
["received_salary"] = "Obdržel jsi: $%s",
454
["received_help"] = "Obdržel jsi svůj podíl: $%s",

[core]/es_extended/locales/de.lua

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,4 @@
11
return {
2-
-- Inventory
3-
["inventory"] = "Inventar ( Gewicht %s / %s )",
4-
["use"] = "Benutzen",
5-
["give"] = "Geben",
6-
["remove"] = "Entsorgen",
7-
["return"] = "Zurück",
8-
["give_to"] = "Geben an",
9-
["amount"] = "Anzahl",
10-
["giveammo"] = "Munition geben",
11-
["amountammo"] = "Munitions Anzahl",
12-
["noammo"] = "Nicht Genug!",
13-
["gave_item"] = "Du gibst %sx %s an %s",
14-
["received_item"] = "Du bekommst %sx %s von %s",
15-
["gave_weapon"] = "Du gibst %s an %s",
16-
["gave_weapon_ammo"] = "Du gibst ~o~%sx %s für %s an %s",
17-
["gave_weapon_withammo"] = "Du gibst %s mit ~o~%sx %s an %s",
18-
["gave_weapon_hasalready"] = "%s hat bereits %s",
19-
["gave_weapon_noweapon"] = "%s hat diese Waffe nicht",
20-
["received_weapon"] = "Du bekommst %s von %s",
21-
["received_weapon_ammo"] = "Du bekommst ~o~%sx %s für deine %s von %s",
22-
["received_weapon_withammo"] = "Du bekommst %s mit ~o~%sx %s von %s",
23-
["received_weapon_hasalready"] = "%s hat versucht dir eine %s zu geben, jedoch hast du diese Waffe bereits!",
24-
["received_weapon_noweapon"] = "%s hat versucht dir Munition für eine %s zu geben, jedoch hast du diese Waffe nicht!",
25-
["gave_account_money"] = "Du gibst %s€ (%s) an %s",
26-
["received_account_money"] = "Du bekommst %s€ (%s) von %s",
27-
["amount_invalid"] = "Ungültige Anzahl",
28-
["players_nearby"] = "Keine Personen in der Nähe!",
29-
["ex_inv_lim"] = "Du kannst diese Aktion nicht ausführen!, Inventarlimit für %s überschritten.",
30-
["imp_invalid_quantity"] = "Du kannst diese Aktion nicht ausführen!, Ungültige Anzahl!",
31-
["imp_invalid_amount"] = "Du kannst diese Aktion nicht ausführen!, Ungültige Anzahl",
32-
["threw_standard"] = "Du entsorgst %sx %s",
33-
["threw_account"] = "Du Entsorgst %s€ %s",
34-
["threw_weapon"] = "Du entsorgst %s",
35-
["threw_weapon_ammo"] = "Du entsorgst %s mit ~o~%sx %s",
36-
["threw_weapon_already"] = "Du hast diese Waffe bereits!",
37-
["threw_cannot_pickup"] = "Inventar ist voll! Du kannst dies nicht aufheben",
38-
["threw_pickup_prompt"] = "Drücke [E] zum aufheben",
39-
40-
-- Key mapping
41-
["keymap_showinventory"] = "Inventar Anzeigen",
42-
432
-- Salary related
443
["received_salary"] = "Dein Gehaltscheck ist angekommen!: %s€",
454
["received_help"] = "Deine Sozialhilfe ist angekommen: %s€",

0 commit comments

Comments
 (0)