fix(rv-maphold): foloseste QBCore nativ pt HasItem, fara export qb-inventory
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:CraftItems', function(itemName, itemCosts, points, amount, toSlot, rep, time, chance)
|
||||
local ped = PlayerPedId()
|
||||
local itemData = ItemList[itemName:lower()]
|
||||
local randomNum = math.random(1, 100)
|
||||
|
||||
SendNUIMessage({
|
||||
action = 'close',
|
||||
})
|
||||
inInventory = false
|
||||
if itemData['type'] == 'weapon' and tonumber(amount) > 1 then
|
||||
return SendTextMessage(Lang('INVENTORY_NOTIFICATION_CRAFTING_WEAPONS'), 'error')
|
||||
end
|
||||
|
||||
if chance then
|
||||
Debug('Crafting started with a chance of ' .. randomNum .. '% and you had ' .. chance .. '%')
|
||||
else
|
||||
chance = 100
|
||||
Debug('There is no chance option in your configuration or in this item, and the crafting chance is set to 100%')
|
||||
end
|
||||
|
||||
isCrafting = true
|
||||
time = time or 1000
|
||||
ProgressBar('crafting_item', Lang('INVENTORY_PROGRESS_CRAFTING'), (time * amount), false, false, {
|
||||
move = true,
|
||||
car = true,
|
||||
mouse = false,
|
||||
combat = true,
|
||||
}, {
|
||||
animDict = 'mini@repair',
|
||||
anim = 'fixing_a_player',
|
||||
flags = 1,
|
||||
}, {}, {}, function()
|
||||
if randomNum <= chance then
|
||||
Debug('Crafting successful with ' .. randomNum .. '% chance and you had ' .. chance .. '%')
|
||||
itemData.count = tonumber(amount)
|
||||
StopAnimTask(ped, 'mini@repair', 'fixing_a_player', 1.0)
|
||||
else
|
||||
Debug('Crafting failed with ' .. randomNum .. '% chance and you had ' .. chance .. '%')
|
||||
StopAnimTask(ped, 'mini@repair', 'fixing_a_player', 1.0)
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_CRAFTING_FAILED'), 'inform')
|
||||
Wait(550)
|
||||
TaskPlayAnim(ped, 'gestures@m@standing@casual', 'gesture_damn', 8.0, -8.0, -1, 1, 0, false, false, false)
|
||||
Wait(1250)
|
||||
StopAnimTask(ped, 'gestures@m@standing@casual', 'gesture_damn', 1.0)
|
||||
end
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:CraftItems', itemName, itemCosts, points, amount, toSlot, rep, randomNum, chance)
|
||||
isCrafting = false
|
||||
end, function()
|
||||
StopAnimTask(ped, 'mini@repair', 'fixing_a_player', 1.0)
|
||||
isCrafting = false
|
||||
end)
|
||||
TriggerScreenblurFadeOut(300)
|
||||
if Config.Clothing then DeletePedScreen() end
|
||||
end)
|
||||
|
||||
-- RegisterCommand('tt', function(source, args)
|
||||
-- ProgressBar('crafting_item', Lang('INVENTORY_PROGRESS_CRAFTING'), (1000), false, false, {
|
||||
-- move = true,
|
||||
-- car = true,
|
||||
-- mouse = false,
|
||||
-- combat = true,
|
||||
-- }, {
|
||||
-- animDict = 'mini@repair',
|
||||
-- anim = 'fixing_a_player',
|
||||
-- flags = 1,
|
||||
-- }, {}, {}, function()
|
||||
-- end, function()
|
||||
-- end)
|
||||
-- end, false)
|
||||
@@ -0,0 +1,10 @@
|
||||
--[[
|
||||
We recommend not modifying anything on this side, the Starter Items
|
||||
are all in your server/custom/framework/esx.lua, it won't work in
|
||||
qb-core since that framework has its native ones that do it automatically.
|
||||
]]
|
||||
|
||||
AddEventHandler(Config.InventoryPrefix .. ':client:GiveStarterItems', function()
|
||||
local id = PlayerId()
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:GiveStarterItems', id)
|
||||
end)
|
||||
@@ -0,0 +1,105 @@
|
||||
local checkDistanceInventories = {
|
||||
'shop',
|
||||
'stash',
|
||||
'crafting',
|
||||
'attachment_crafting',
|
||||
'traphouse',
|
||||
'customcrafting'
|
||||
}
|
||||
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:OpenInventory', function(PlayerAmmo, inventory, other, otherName)
|
||||
if not inventory then return Error('Inventory is not working, clear the inventory column [sql] to continue.') end
|
||||
inventory = FormatItemsToInfo(inventory)
|
||||
ToggleHud(false)
|
||||
ToggleHotbar(false)
|
||||
SetFocus(true)
|
||||
IdleCamera(true)
|
||||
SetPedCanPlayAmbientAnims(PlayerPedId(), false)
|
||||
SetResourceKvp('idleCam', 'off')
|
||||
|
||||
if other then
|
||||
currentOtherInventory = other.name
|
||||
end
|
||||
|
||||
OpenedInventoryCoords = GetEntityCoords(PlayerPedId())
|
||||
|
||||
TriggerServerCallback(Config.InventoryPrefix .. ':server:QualityDecay', function(data)
|
||||
local hungerValue = hunger
|
||||
local thirstValue = thirst
|
||||
if Config.Framework == 'qb' then
|
||||
local data = GetPlayerData()
|
||||
hungerValue = data.metadata and data.metadata.hunger
|
||||
thirstValue = data.metadata and data.metadata.thirst
|
||||
end
|
||||
|
||||
local PlayerSlots = Config.InventoryWeight.slots
|
||||
if not Config.BlockedSlot then
|
||||
PlayerSlots = Config.InventoryWeight.slots - 1
|
||||
end
|
||||
|
||||
inventory = data.inventory
|
||||
other = data.other
|
||||
|
||||
data = GetPlayerData()
|
||||
if Config.Framework == 'esx' then
|
||||
firstName = data.firstName or ''
|
||||
lastName = data.lastName or ''
|
||||
for i = 1, #data.accounts do
|
||||
if data.accounts[i].name == 'money' then
|
||||
money = data.accounts[i].money or 'Not found'
|
||||
elseif data.accounts[i].name == 'bank' then
|
||||
bank = data.accounts[i].money or 'Not found'
|
||||
elseif data.accounts[i].name == 'black_money' then
|
||||
blackmoney = data.accounts[i].money or 'Not found'
|
||||
end
|
||||
end
|
||||
elseif Config.Framework == 'qb' then
|
||||
firstName = data.charinfo.firstname or ''
|
||||
lastName = data.charinfo.lastname or ''
|
||||
money = data.money.cash or 'Not found'
|
||||
bank = data.money.bank or 'Not found'
|
||||
blackmoney = data.money.crypto or 'Not found'
|
||||
end
|
||||
|
||||
|
||||
SendNUIMessage({
|
||||
action = 'open',
|
||||
inventory = inventory,
|
||||
slots = PlayerSlots,
|
||||
other = other,
|
||||
maxweight = Config.InventoryWeight.weight,
|
||||
Ammo = PlayerAmmo,
|
||||
playerName = firstName .. ' ' .. lastName,
|
||||
logo = Config.Logo,
|
||||
openAnimation = Config.OpenInventoryScene,
|
||||
optionClothes = Config.InventoryOptions.clothes,
|
||||
optionConfiguration = Config.InventoryOptions.configuration,
|
||||
optionHealth = Config.InventoryOptions.health,
|
||||
optionArmor = Config.InventoryOptions.armor,
|
||||
optionHunger = Config.InventoryOptions.hunger,
|
||||
optionThirst = Config.InventoryOptions.thirst,
|
||||
optionId = Config.InventoryOptions.id,
|
||||
optionMoney = Config.InventoryOptions.money,
|
||||
optionBank = Config.InventoryOptions.bank,
|
||||
optionBlackMoney = Config.InventoryOptions.blackmoney,
|
||||
playerhp = GetEntityHealth(PlayerPedId()),
|
||||
playerarmor = GetPedArmour(PlayerPedId()),
|
||||
playerhunger = hungerValue or 0,
|
||||
playerthirst = thirstValue or 0,
|
||||
playerId = GetPlayerServerId(PlayerId()),
|
||||
playerMoney = money,
|
||||
playerBank = bank,
|
||||
playerBlackMoney = blackmoney,
|
||||
notStolenItems = Config.notStolenItems,
|
||||
notStoredItems = Config.notStoredItems,
|
||||
labelChanger = Config.LabelChange
|
||||
})
|
||||
inInventory = true
|
||||
if table.includes(checkDistanceInventories, otherName) then
|
||||
CheckNearbyOtherInventory()
|
||||
end
|
||||
end, inventory, other)
|
||||
|
||||
if not Config.Handsup then return end
|
||||
checkPlayerRobbery(other)
|
||||
end)
|
||||
@@ -0,0 +1,48 @@
|
||||
if not Config.UseTarget then
|
||||
local nearby = false
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local sleep = 1000
|
||||
if nearby then
|
||||
DrawText3D(Config.SellItems[nearby].coords.x, Config.SellItems[nearby].coords.y, Config.SellItems[nearby].coords.z, Lang('INVENTORY_TEXT_SELLING'), 'selling', 'E')
|
||||
sleep = 1
|
||||
if IsControlJustPressed(0, 38) then
|
||||
local PawnshopItems = {}
|
||||
PawnshopItems.label = nearby
|
||||
PawnshopItems.items = Config.SellItems[nearby].items
|
||||
PawnshopItems.slots = #Config.SellItems[nearby].items
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'selling', 'itemselling_' .. nearby, PawnshopItems)
|
||||
end
|
||||
end
|
||||
Wait(sleep)
|
||||
end
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
for k, v in pairs(Config.SellItems) do
|
||||
if v.blip and v.blip.active then
|
||||
local ff = v.blip
|
||||
local blip = AddBlipForCoord(v.coords)
|
||||
SetBlipSprite(blip, ff.sprite)
|
||||
SetBlipColour(blip, ff.color)
|
||||
SetBlipScale(blip, ff.scale)
|
||||
BeginTextCommandSetBlipName('STRING')
|
||||
AddTextComponentString(ff.name)
|
||||
EndTextCommandSetBlipName(blip)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local playercoords = GetEntityCoords(PlayerPedId())
|
||||
local finded = false
|
||||
for k, v in pairs(Config.SellItems) do
|
||||
if #(playercoords - v.coords) <= 2 then finded = k end
|
||||
end
|
||||
nearby = finded
|
||||
Wait(700)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,72 @@
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:UseWeapon', function(weaponData, shootbool)
|
||||
if FiringWeapon then
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_STOP_FIRING'), 'error')
|
||||
return false
|
||||
end
|
||||
local ped = PlayerPedId()
|
||||
local weaponName = tostring(weaponData.name)
|
||||
local weaponHash = joaat(weaponData.name)
|
||||
for i = 1, #Config.WeaponTints do
|
||||
if tostring(GetHashKey(weaponName)) == Config.WeaponTints[i].hash then
|
||||
AddReplaceTexture(Config.WeaponTints[i].ytd, Config.WeaponTints[i].texture, Config.WeaponTints[i].ytd, Config.WeaponTints[i].texture)
|
||||
break
|
||||
end
|
||||
end
|
||||
if currentWeapon == weaponName then
|
||||
TriggerEvent('weapons:client:DrawWeapon', nil)
|
||||
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
|
||||
RemoveAllPedWeapons(ped, true)
|
||||
TriggerEvent('weapons:client:SetCurrentWeapon', nil, shootbool)
|
||||
currentWeapon = nil
|
||||
elseif weaponName == 'weapon_stickybomb' or weaponName == 'weapon_pipebomb' or weaponName == 'weapon_smokegrenade' or weaponName == 'weapon_flare' or weaponName == 'weapon_proxmine' or weaponName == 'weapon_ball' or weaponName == 'weapon_molotov' or weaponName == 'weapon_grenade' or weaponName == 'weapon_bzgas' then
|
||||
TriggerEvent('weapons:client:DrawWeapon', weaponName)
|
||||
GiveWeaponToPed(ped, weaponHash, 1, false, false)
|
||||
SetPedAmmo(ped, weaponHash, 1)
|
||||
SetCurrentPedWeapon(ped, weaponHash, true)
|
||||
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:RemoveItem', weaponName, 1)
|
||||
currentWeapon = weaponName
|
||||
elseif weaponName == 'weapon_snowball' then
|
||||
TriggerEvent('weapons:client:DrawWeapon', weaponName)
|
||||
GiveWeaponToPed(ped, weaponHash, 10, false, false)
|
||||
SetPedAmmo(ped, weaponHash, 10)
|
||||
SetCurrentPedWeapon(ped, weaponHash, true)
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:snowball', 'remove')
|
||||
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
|
||||
currentWeapon = weaponName
|
||||
elseif weaponName == 'weapon_petrolcan' then
|
||||
GiveWeaponToPed(ped, weaponHash, 10, false, false)
|
||||
SetPedAmmo(ped, weaponHash, weaponData.info.ammo or 4500)
|
||||
SetCurrentPedWeapon(ped, weaponHash, true)
|
||||
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
|
||||
currentWeapon = weaponName
|
||||
else
|
||||
TriggerEvent('weapons:client:DrawWeapon', weaponName)
|
||||
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
|
||||
local ammo = tonumber(weaponData.info.ammo) or 0
|
||||
|
||||
if weaponName == 'weapon_petrolcan' or weaponName == 'weapon_fireextinguisher' then
|
||||
ammo = 4000
|
||||
end
|
||||
|
||||
GiveWeaponToPed(ped, weaponHash, ammo, false, false)
|
||||
SetPedAmmo(ped, weaponHash, ammo)
|
||||
SetCurrentPedWeapon(ped, weaponHash, true)
|
||||
|
||||
if weaponData.info.attachments then
|
||||
for _, attachment in pairs(weaponData.info.attachments) do
|
||||
if attachment.tint then
|
||||
if attachment.urltint ~= 'none' then
|
||||
ChangeWeaponTintWithUrl(weaponHash, attachment.urltint)
|
||||
else
|
||||
SetPedWeaponTintIndex(ped, weaponHash, attachment.tint)
|
||||
end
|
||||
else
|
||||
GiveWeaponComponentToPed(ped, weaponHash, joaat(attachment.component))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
currentWeapon = weaponName
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,175 @@
|
||||
local isAdminGiveItemOpen = false
|
||||
local currentPlayers = {}
|
||||
local currentItems = {}
|
||||
local selectedPlayer = nil
|
||||
local selectedItem = nil
|
||||
|
||||
-- Open the admin giveitem interface
|
||||
RegisterNetEvent('inventory:admin:openGiveItemInterface', function()
|
||||
Debug('Opening admin interface...')
|
||||
if isAdminGiveItemOpen then
|
||||
return
|
||||
end
|
||||
|
||||
isAdminGiveItemOpen = true
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
-- Get initial data
|
||||
GetOnlinePlayers()
|
||||
GetAllItems()
|
||||
|
||||
-- Open the UI
|
||||
SendNUIMessage({
|
||||
action = 'openAdminGiveItem',
|
||||
data = {
|
||||
title = 'Admin Give Item System',
|
||||
subtitle = 'Player item giving system'
|
||||
}
|
||||
})
|
||||
end)
|
||||
|
||||
-- Get online players
|
||||
function GetOnlinePlayers()
|
||||
lib.callback('inventory:admin:getOnlinePlayers', false, function(players)
|
||||
currentPlayers = players
|
||||
SendNUIMessage({
|
||||
action = 'updatePlayers',
|
||||
data = players
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
-- Get all items
|
||||
function GetAllItems()
|
||||
local items = {}
|
||||
for itemName, itemData in pairs(ItemList) do
|
||||
table.insert(items, {
|
||||
name = itemName,
|
||||
label = itemData.label,
|
||||
type = itemData.type,
|
||||
weight = itemData.weight,
|
||||
unique = itemData.unique or false,
|
||||
image = itemData.image or 'default.png'
|
||||
})
|
||||
end
|
||||
|
||||
-- Sort items alphabetically
|
||||
table.sort(items, function(a, b)
|
||||
return a.label < b.label
|
||||
end)
|
||||
|
||||
SendNUIMessage({
|
||||
action = 'updateItems',
|
||||
data = items
|
||||
})
|
||||
end
|
||||
|
||||
-- Search players
|
||||
function SearchPlayers(searchTerm)
|
||||
lib.callback('inventory:admin:searchPlayers', false, function(players)
|
||||
currentPlayers = players
|
||||
SendNUIMessage({
|
||||
action = 'updatePlayers',
|
||||
data = players
|
||||
})
|
||||
end, searchTerm)
|
||||
end
|
||||
|
||||
-- Search items
|
||||
function SearchItems(searchTerm)
|
||||
local items = {}
|
||||
local searchLower = string.lower(searchTerm or '')
|
||||
|
||||
for itemName, itemData in pairs(ItemList) do
|
||||
local itemLabelLower = string.lower(itemData.label)
|
||||
local itemNameLower = string.lower(itemName)
|
||||
|
||||
if searchLower == '' or
|
||||
string.find(itemLabelLower, searchLower, 1, true) or
|
||||
string.find(itemNameLower, searchLower, 1, true) then
|
||||
table.insert(items, {
|
||||
name = itemName,
|
||||
label = itemData.label,
|
||||
type = itemData.type,
|
||||
weight = itemData.weight,
|
||||
unique = itemData.unique or false,
|
||||
image = itemData.image or 'default.png'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Sort items alphabetically
|
||||
table.sort(items, function(a, b)
|
||||
return a.label < b.label
|
||||
end)
|
||||
|
||||
SendNUIMessage({
|
||||
action = 'updateItems',
|
||||
data = items
|
||||
})
|
||||
end
|
||||
|
||||
function GiveItemToPlayer(targetId, itemName, amount, metadata)
|
||||
lib.callback('inventory:admin:giveItem', false, function(success, message)
|
||||
if success then
|
||||
SendTextMessage(message, 'success')
|
||||
CloseAdminGiveItemInterface()
|
||||
else
|
||||
SendTextMessage(message, 'error')
|
||||
end
|
||||
end, targetId, itemName, amount, metadata)
|
||||
end
|
||||
|
||||
-- Close admin giveitem interface
|
||||
function CloseAdminGiveItemInterface()
|
||||
Debug('Closing admin interface...')
|
||||
isAdminGiveItemOpen = false
|
||||
SetNuiFocus(false, false)
|
||||
SendNUIMessage({
|
||||
action = 'closeAdminGiveItem'
|
||||
})
|
||||
end
|
||||
|
||||
-- NUI Callbacks
|
||||
RegisterNUICallback('closeAdminGiveItem', function(data, cb)
|
||||
CloseAdminGiveItemInterface()
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('searchPlayers', function(data, cb)
|
||||
SearchPlayers(data.searchTerm)
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('searchItems', function(data, cb)
|
||||
SearchItems(data.searchTerm)
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('selectPlayer', function(data, cb)
|
||||
selectedPlayer = data.player
|
||||
SendNUIMessage({
|
||||
action = 'updateSelectedPlayer',
|
||||
data = data.player
|
||||
})
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('selectItem', function(data, cb)
|
||||
selectedItem = data.item
|
||||
SendNUIMessage({
|
||||
action = 'updateSelectedItem',
|
||||
data = data.item
|
||||
})
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('giveItem', function(data, cb)
|
||||
local player = data.player
|
||||
local item = data.item
|
||||
local amount = tonumber(data.amount) or 1
|
||||
local metadata = data.metadata or ''
|
||||
|
||||
GiveItemToPlayer(player.id, item.name, amount, metadata)
|
||||
cb('ok')
|
||||
end)
|
||||
@@ -0,0 +1,208 @@
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:openVending')
|
||||
AddEventHandler(Config.InventoryPrefix .. ':client:openVending', function(Data)
|
||||
local Category = Data['category']
|
||||
TriggerServerEvent('inventory:openVending', Category)
|
||||
end)
|
||||
|
||||
local spamCount = 0
|
||||
local lastSpamId = nil
|
||||
|
||||
local inventory_opening_anim = {
|
||||
-- dict = 'mp_player_inteat@burger',
|
||||
-- clip = 'mp_player_int_eat_burger_fp'
|
||||
}
|
||||
|
||||
local inventory_opening_disable = {
|
||||
move = true,
|
||||
car = true,
|
||||
mouse = true,
|
||||
combat = true
|
||||
}
|
||||
|
||||
local openingInv = false
|
||||
RegisterCommand('inventory', function()
|
||||
if inInventory then
|
||||
return Debug('Inventory is already open')
|
||||
end
|
||||
if Config.OpenProgressBar and openingInv then return end
|
||||
if IsNuiFocused() then return Debug('NUI Focused') end
|
||||
if spamCount > 2 then
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_SPAM'), 'error')
|
||||
return
|
||||
end
|
||||
spamCount = spamCount + 1
|
||||
lastSpamId = math.random(1, 999999)
|
||||
local spamId = lastSpamId
|
||||
SetTimeout(1000, function()
|
||||
if spamId == lastSpamId then
|
||||
spamCount = 0
|
||||
end
|
||||
end)
|
||||
if LocalPlayer.state.inv_busy or not CanUseInventory() then
|
||||
Warning("You can't use this action because inv_busy is active (avoids dupes)")
|
||||
return SendTextMessage(Lang('INVENTORY_NOTIFICATION_NOT_ACCESSIBLE'), 'error')
|
||||
end
|
||||
|
||||
if Config.OpenProgressBar then
|
||||
openingInv = true
|
||||
local success = ProgressBarSync('inventory', 'Inventory opening', 800, true, true, inventory_opening_disable, inventory_opening_anim)
|
||||
openingInv = false
|
||||
if not success then
|
||||
print('failed')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if inInventory and not IsNuiFocused() then
|
||||
SetFocus(true)
|
||||
return
|
||||
end
|
||||
|
||||
if not isCrafting and not inInventory and not inventoryDisabled then
|
||||
if not IsPauseMenuActive() then
|
||||
local ped = PlayerPedId()
|
||||
local curVeh = nil
|
||||
local VendingMachine = nil
|
||||
local garbage = nil
|
||||
local CurrentGarbage = {}
|
||||
local entity, entityModel, data = GetNearbyGarbage()
|
||||
if entity then
|
||||
local x, y, z = table.unpack(GetEntityCoords(entity))
|
||||
local _, floorZ = GetGroundZFor_3dCoord(x, y, z, false)
|
||||
garbage = getOwnerFromCoordsForGarbage(vector3(x, y, floorZ))
|
||||
CurrentGarbage.label = data.label
|
||||
CurrentGarbage.items = data.items
|
||||
CurrentGarbage.slots = data.slots
|
||||
end
|
||||
|
||||
if not Config.UseTarget then
|
||||
VendingMachine = GetClosestVending()
|
||||
end
|
||||
|
||||
if IsPedInAnyVehicle(ped, false) then -- Is Player In Vehicle
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
CurrentGlovebox = Trim(GetVehicleNumberPlateText(vehicle))
|
||||
curVeh = vehicle
|
||||
CurrentVehicle = nil
|
||||
else
|
||||
local vehicle = getClosestVehicle()
|
||||
if vehicle ~= 0 and vehicle ~= nil then
|
||||
local pos = GetEntityCoords(ped)
|
||||
local dimensionMin, dimensionMax = GetModelDimensions(GetEntityModel(vehicle))
|
||||
local trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, (dimensionMin.y), 0.0)
|
||||
if (IsBackEngine(GetEntityModel(vehicle))) then
|
||||
trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, (dimensionMax.y), 0.0)
|
||||
end
|
||||
if #(pos - trunkpos) < 1.5 and not IsPedInAnyVehicle(ped) then
|
||||
if GetVehicleDoorLockStatus(vehicle) < 2 then
|
||||
CurrentVehicle = Trim(GetVehicleNumberPlateText(vehicle))
|
||||
curVeh = vehicle
|
||||
CurrentGlovebox = nil
|
||||
else
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_VEHICLE_LOCKED'), 'error')
|
||||
return
|
||||
end
|
||||
else
|
||||
CurrentVehicle = nil
|
||||
end
|
||||
else
|
||||
CurrentVehicle = nil
|
||||
end
|
||||
end
|
||||
|
||||
if CurrentVehicle then -- Trunk
|
||||
local vehicleClass = GetVehicleClass(curVeh)
|
||||
Debug('Current vehicleClass of the vehicle that is being unlocked:', vehicleClass)
|
||||
local maxweight = Config.VehicleClass[vehicleClass].trunk.maxweight or 60000
|
||||
local slots = Config.VehicleClass[vehicleClass].trunk.slots or 35
|
||||
local isCustomVehicle = Config.CustomTrunk[GetEntityModel(curVeh)]
|
||||
|
||||
if isCustomVehicle then
|
||||
maxweight = isCustomVehicle.maxweight
|
||||
slots = isCustomVehicle.slots
|
||||
end
|
||||
|
||||
local other = {
|
||||
maxweight = maxweight,
|
||||
slots = slots,
|
||||
}
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'trunk', CurrentVehicle, other)
|
||||
OpenTrunk()
|
||||
elseif CurrentGlovebox then
|
||||
local vehicleClass = GetVehicleClass(curVeh)
|
||||
Debug('Current vehicleClass of the vehicle that is being unlocked:', vehicleClass)
|
||||
local maxweight = Config.VehicleClass[vehicleClass].glovebox.maxweight or 60000
|
||||
local slots = Config.VehicleClass[vehicleClass].glovebox.slots or 35
|
||||
local isCustomVehicle = Config.CustomGlovebox[GetEntityModel(curVeh)]
|
||||
|
||||
if isCustomVehicle then
|
||||
maxweight = isCustomVehicle.maxweight
|
||||
slots = isCustomVehicle.slots
|
||||
end
|
||||
local other = {
|
||||
maxweight = maxweight,
|
||||
slots = slots
|
||||
}
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'glovebox', CurrentGlovebox, other)
|
||||
elseif CurrentDrop ~= 0 then
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'drop', CurrentDrop)
|
||||
elseif garbage then
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'garbage', garbage, CurrentGarbage, entityModel)
|
||||
OpenGarbage()
|
||||
elseif VendingMachine then
|
||||
local vendingCategory = nil
|
||||
local vendingModel = GetEntityModel(VendingMachine)
|
||||
for _, vendingData in pairs(Config.Vendings) do
|
||||
local vendingDataModel = GetHashKey(vendingData.Model)
|
||||
if vendingDataModel == vendingModel then
|
||||
vendingCategory = vendingData.Category
|
||||
break
|
||||
end
|
||||
end
|
||||
if vendingCategory then
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:openVending', { category = vendingCategory })
|
||||
end
|
||||
else
|
||||
OpenAnim()
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory')
|
||||
end
|
||||
end
|
||||
end
|
||||
end, false)
|
||||
|
||||
RegisterKeyMapping('inventory', Lang('INVENTORY_KEYMAPPING_OPEN_LABEL'), 'keyboard', Config.KeyBinds.inventory)
|
||||
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:OpenPlayerInventory')
|
||||
AddEventHandler(Config.InventoryPrefix .. ':client:OpenPlayerInventory', function()
|
||||
ExecuteCommand('inventory')
|
||||
end)
|
||||
|
||||
RegisterCommand('hotbar', function()
|
||||
if inventoryDisabled then return end
|
||||
if IsNuiFocused() then return end
|
||||
if LocalPlayer.state.inv_busy or not CanUseInventory() then
|
||||
Warning("You can't use this action because inv_busy is active (avoids dupes)")
|
||||
return
|
||||
end
|
||||
|
||||
isHotbar = not isHotbar
|
||||
if not IsPauseMenuActive() then
|
||||
ToggleHotbar(isHotbar)
|
||||
end
|
||||
end, false)
|
||||
|
||||
RegisterKeyMapping('hotbar', Lang('INVENTORY_KEYMAPPING_HOTBAR_LABEL'), 'keyboard', Config.KeyBinds.hotbar)
|
||||
|
||||
RegisterKeyMapping('reloadweapon', Lang('INVENTORY_KEYMAPPING_RELOAD_LABEL'), 'keyboard', Config.KeyBinds.reload)
|
||||
|
||||
RegisterCommand('reloadweapon', function()
|
||||
if not CurrentWeaponData?.name then return end
|
||||
local weaponData = WeaponList[joaat(CurrentWeaponData?.name)]
|
||||
if not weaponData then return end
|
||||
|
||||
if LocalPlayer.state.inv_busy or not CanUseInventory() then
|
||||
Debug("You can't use this action because inv_busy is active (avoids dupes)")
|
||||
return SendTextMessage(Lang('INVENTORY_NOTIFICATION_NOT_ACCESSIBLE'), 'error')
|
||||
end
|
||||
TriggerServerEvent('weapons:reloadWeapon', weaponData.ammotype)
|
||||
end, false)
|
||||
@@ -0,0 +1,41 @@
|
||||
local color = {} --[[@as Color]]
|
||||
|
||||
---@param data Color
|
||||
RegisterNUICallback('updateColors', function(data, cb)
|
||||
color.primaryColor = data.primaryColor or color.primaryColor
|
||||
color.primaryOpacity = data.primaryOpacity or color.primaryOpacity
|
||||
color.secondaryColor = data.secondaryColor or color.secondaryColor
|
||||
color.secondaryOpacity = data.secondaryOpacity or color.secondaryOpacity
|
||||
color.borderColor = data.borderColor or color.borderColor
|
||||
color.borderOpacity = data.borderOpacity or color.borderOpacity
|
||||
color.borderRadius = data.borderRadius or color.borderRadius
|
||||
|
||||
LocalPlayer.state:set('primaryColor', color.primaryColor, true)
|
||||
LocalPlayer.state:set('primaryOpacity', color.primaryOpacity, true)
|
||||
|
||||
TriggerEvent('inventory:updateColors', color)
|
||||
cb(true)
|
||||
end)
|
||||
|
||||
exports('getColors', function()
|
||||
return color
|
||||
end)
|
||||
|
||||
|
||||
local function handleThemeChange()
|
||||
local handler
|
||||
handler = AddEventHandler('inventory:updateColors', function()
|
||||
if not IsPlayerLoaded() then
|
||||
Debug('handleThemeChange', 'Player not loaded, skipping color update')
|
||||
return
|
||||
end
|
||||
|
||||
Debug('handleThemeChange', 'Theme color updated successfully')
|
||||
|
||||
RemoveEventHandler(handler)
|
||||
handler = nil
|
||||
end)
|
||||
end
|
||||
|
||||
handleThemeChange()
|
||||
TriggerEvent('inventory:updateColors')
|
||||
@@ -0,0 +1,41 @@
|
||||
if not GetResourceState('jobs_creator') == 'missing' then
|
||||
return
|
||||
end
|
||||
|
||||
-- Warning('Started the compatibility module with jobs_creator')
|
||||
|
||||
CreateThread(function()
|
||||
local other = {}
|
||||
other.maxweight = 100000 -- Custom weight stash.
|
||||
other.slots = 50 -- Custom slots spaces.
|
||||
|
||||
RegisterNetEvent('jobs_creator:stash:openStash', function(markerId)
|
||||
local stashId = 'job_stash_' .. markerId
|
||||
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'stash', stashId, other)
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:SetCurrentStash', stashId)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jobs_creator:safe:openSafe', function(markerId)
|
||||
local safeId = 'job_safe_' .. markerId
|
||||
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'stash', safeId, other)
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:SetCurrentStash', safeId)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jobs_creator:armory:openArmory', function(markerId)
|
||||
local armoryId = 'job_armory_' .. markerId
|
||||
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'stash', armoryId, other)
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:SetCurrentStash', armoryId)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jobs_creator:framework:ready', function()
|
||||
-- Disables the default script search (otherwise there would be 2 searches)
|
||||
exports['jobs_creator']:disableScriptEvent('jobs_creator:actions:search:searchPlayer')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jobs_creator:actions:search:searchPlayer', function(targetServerId)
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'otherplayer', targetServerId)
|
||||
end)
|
||||
end)
|
||||
@@ -0,0 +1,10 @@
|
||||
function JonskaItemThrow(item)
|
||||
local data = {
|
||||
name = item.name, -- needed for adding and removing item
|
||||
label = item.label, -- MUST HAVE!
|
||||
amount = item.amount, -- needed for adding and removing item
|
||||
info = item.info, -- needed for adding item
|
||||
created = item.created or 0 -- needed for adding item (if your inventory have decay system)
|
||||
}
|
||||
return exports['jonska-itemthrowing']:throwItem(data, item.name, item.amount)
|
||||
end
|
||||
@@ -0,0 +1,196 @@
|
||||
if not Config.Handsup then
|
||||
return
|
||||
end
|
||||
|
||||
local lib, anim = 'missminuteman_1ig_2', 'handsup_base'
|
||||
local canHandsUp = true
|
||||
local deadPlayer = false
|
||||
|
||||
local function LoadAnimDict(dict)
|
||||
if HasAnimDictLoaded(dict) then return end
|
||||
|
||||
RequestAnimDict(dict)
|
||||
while not HasAnimDictLoaded(dict) do
|
||||
Wait(10)
|
||||
end
|
||||
end
|
||||
|
||||
RegisterKeyMapping('+handsup', Lang('INVENTORY_KEYMAPPING_HANDSUP_LABEL'), 'keyboard', Config.KeyBinds.handsup)
|
||||
|
||||
local handsUpActive = false
|
||||
|
||||
RegisterCommand('+handsup', function()
|
||||
if not IsPedInAnyVehicle(PlayerPedId(), false) and GetEntityHealth(PlayerPedId()) > 1 then
|
||||
if canHandsUp and not handsUpActive then
|
||||
handsUpActive = true
|
||||
RequestAnimDict(lib)
|
||||
while not HasAnimDictLoaded(lib) do
|
||||
Wait(100)
|
||||
end
|
||||
SetCurrentPedWeapon(PlayerPedId(), GetHashKey('WEAPON_UNARMED'), true)
|
||||
TaskPlayAnim(PlayerPedId(), lib, anim, 2.0, 2.5, -1, 49, 0, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand('-handsup', function()
|
||||
if handsUpActive then
|
||||
handsUpActive = false
|
||||
ClearPedSecondaryTask(PlayerPedId())
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:RobPlayer')
|
||||
AddEventHandler(Config.InventoryPrefix .. ':client:RobPlayer', function(TargetId)
|
||||
local ped = PlayerPedId()
|
||||
if IsPedArmed(ped, 1) or IsPedArmed(ped, 2) or IsPedArmed(ped, 4) or deadPlayer or Config.StealWithoutWeapons then
|
||||
SendNUIMessage({
|
||||
action = 'RobPlayer',
|
||||
TargetId = TargetId,
|
||||
})
|
||||
end
|
||||
deadPlayer = false
|
||||
end)
|
||||
|
||||
local function checkPlayerIsNear(targetPlayer)
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(100)
|
||||
local targetPed = GetPlayerPed(targetPlayer)
|
||||
|
||||
if not DoesEntityExist(targetPed) or NetworkIsPlayerActive(targetPlayer) == false then
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:closeinv')
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_ROBBERY_AWAY'), 'inform')
|
||||
break
|
||||
end
|
||||
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
local targetCoords = GetEntityCoords(targetPed)
|
||||
local distance = #(playerCoords - targetCoords)
|
||||
|
||||
if distance > 5 then
|
||||
Wait(500)
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:closeinv')
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_ROBBERY_AWAY'), 'inform')
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:search', function()
|
||||
local player, distance = GetClosestPlayer(GetEntityCoords(PlayerPedId()))
|
||||
if player ~= -1 and distance < 2.5 then
|
||||
local playerId = GetPlayerServerId(player)
|
||||
local searchPlayerPed = GetPlayerPed(player)
|
||||
if IsEntityPlayingAnim(searchPlayerPed, 'missminuteman_1ig_2', 'handsup_base', 3) or Config.StealDeadPlayer and checkEntityDead(playerId, searchPlayerPed) or GetEntityHealth(searchPlayerPed) <= 0 then
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'otherplayer', playerId)
|
||||
checkPlayerIsNear(player)
|
||||
inRobbery = true
|
||||
else
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_NO_HANDSUP'), 'error')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_NO_PLAYERS'), 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent(Config.InventoryPrefix .. ':client:playerRobbery')
|
||||
AddEventHandler(Config.InventoryPrefix .. ':client:playerRobbery', function()
|
||||
local player, distance = GetClosestPlayer(GetEntityCoords(PlayerPedId()))
|
||||
if player ~= -1 and distance < 3.0 then
|
||||
local searchPlayerPed = GetPlayerPed(player)
|
||||
local playerId = GetPlayerServerId(player)
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:forceCloseInventory')
|
||||
Wait(500)
|
||||
|
||||
if checkEntityDead(playerId, searchPlayerPed) then
|
||||
RequestAnimDict('amb@world_human_gardener_plant@male@base')
|
||||
while not HasAnimDictLoaded('amb@world_human_gardener_plant@male@base') do
|
||||
Wait(100)
|
||||
end
|
||||
TaskPlayAnim(PlayerPedId(), 'amb@world_human_gardener_plant@male@base', 'base', 8.0, -8, -1, 1, 0, 0, 0, 0)
|
||||
ProgressBar('steal_playerdead', Lang('INVENTORY_PROGRESS_STEAL'), 5500, false, true, {
|
||||
move = true,
|
||||
car = true,
|
||||
mouse = false,
|
||||
combat = true,
|
||||
}, {}, {}, {}, function() -- Done
|
||||
TaskPlayAnim(PlayerPedId(), 'amb@world_human_gardener_plant@male@base', 'base', 8.0, -8, -1, 1, 0, 0, 0, 0)
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'otherplayer', playerId)
|
||||
checkPlayerIsNear(player)
|
||||
inRobbery = true
|
||||
end, function() -- Cancel
|
||||
ClearPedTasks(PlayerPedId())
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
if DoesEntityExist(searchPlayerPed) and IsEntityPlayingAnim(searchPlayerPed, lib, anim, 3) and not checkEntityDead(playerId, searchPlayerPed) then
|
||||
LoadAnimDict('combat@aim_variations@arrest')
|
||||
TaskPlayAnim(PlayerPedId(), 'combat@aim_variations@arrest', 'cop_med_arrest_01', 8.0, -8, -1, 1, 0, 0, 0, 0)
|
||||
ProgressBar('steal_player', Lang('INVENTORY_PROGRESS_STEAL'), 5500, false, true, {
|
||||
move = true,
|
||||
car = true,
|
||||
mouse = false,
|
||||
combat = true,
|
||||
}, {}, {}, {}, function() -- Done
|
||||
TaskPlayAnim(PlayerPedId(), 'combat@aim_variations@arrest', 'cop_med_arrest_01', 8.0, -8, -1, 1, 0, 0, 0, 0)
|
||||
TriggerServerEvent(Config.InventoryPrefix .. ':server:OpenInventory', 'otherplayer', playerId)
|
||||
SetPedConfigFlag(PlayerPedId(), 36, true)
|
||||
checkPlayerIsNear(player)
|
||||
inRobbery = true
|
||||
end, function() -- Cancel
|
||||
ClearPedTasks(PlayerPedId())
|
||||
end)
|
||||
else
|
||||
SendTextMessage(Lang('INVENTORY_NOTIFICATION_NO_HANDSUP'), 'error')
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function checkPlayerRobbery(other)
|
||||
if other and other.id then
|
||||
local target = tonumber(other.id)
|
||||
local playerTarget = GetPlayerFromServerId(target)
|
||||
local pedTarget = GetPlayerPed(playerTarget)
|
||||
if other ~= nil then
|
||||
currentOtherInventory = other.name
|
||||
end
|
||||
if target and DoesEntityExist(pedTarget) then
|
||||
local pos = GetEntityCoords(playerPed)
|
||||
local targetPos = GetEntityCoords(pedTarget)
|
||||
local distance = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, targetPos.x, targetPos.y, targetPos.z, true)
|
||||
if distance < 3.0 then
|
||||
inInventory = true
|
||||
deadPlayer = true
|
||||
StealingPed = pedTarget
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:RobPlayer', target)
|
||||
end
|
||||
end
|
||||
else
|
||||
local closestPlayer, closestDistance = GetClosestPlayer(GetEntityCoords(PlayerPedId()))
|
||||
if closestPlayer and closestPlayer ~= -1 and closestDistance < 3.0 then
|
||||
local playerId = GetPlayerServerId(closestPlayer)
|
||||
local searchPlayerPed = GetPlayerPed(closestPlayer)
|
||||
if searchPlayerPed and searchPlayerPed ~= 0 then
|
||||
if Config.StealDeadPlayer and checkEntityDead(playerId, searchPlayerPed) then
|
||||
inInventory = true
|
||||
deadPlayer = true
|
||||
StealingPed = searchPlayerPed
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:RobPlayer', playerId)
|
||||
end
|
||||
if IsEntityPlayingAnim(searchPlayerPed, lib, anim, 3) then
|
||||
inInventory = true
|
||||
deadPlayer = false
|
||||
StealingPed = searchPlayerPed
|
||||
TriggerEvent(Config.InventoryPrefix .. ':client:RobPlayer', playerId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('inventory:robClosestPlayer', function()
|
||||
checkPlayerRobbery()
|
||||
end)
|
||||
Reference in New Issue
Block a user