From f1de165ca5aaff1032f2f21b9cc77503a9c7fe2e Mon Sep 17 00:00:00 2001 From: your_username Date: Thu, 25 Jul 2024 16:02:22 -0500 Subject: [PATCH] Added Chat Message per ID --- server/main.lua | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/server/main.lua b/server/main.lua index c20b6365d..1c126a63f 100644 --- a/server/main.lua +++ b/server/main.lua @@ -183,6 +183,54 @@ RegisterNetEvent('qb-inventory:server:useItem', function(item) if itemData.type == 'weapon' then TriggerClientEvent('qb-weapons:client:UseWeapon', src, itemData, itemData.info.quality and itemData.info.quality > 0) TriggerClientEvent('qb-inventory:client:ItemBox', src, itemInfo, 'use') + elseif itemData.name == 'id_card' then + UseItem(itemData.name, src, itemData) + TriggerClientEvent('qb-inventory:client:ItemBox', source, itemInfo, 'use') + local playerPed = GetPlayerPed(src) + local playerCoords = GetEntityCoords(playerPed) + local players = QBCore.Functions.GetPlayers() + local gender = item.info.gender == 0 and 'Male' or 'Female' + for _, v in pairs(players) do + local targetPed = GetPlayerPed(v) + local dist = #(playerCoords - GetEntityCoords(targetPed)) + if dist < 3.0 then + TriggerClientEvent('chat:addMessage', v, { + template = '', + args = { + 'ID Card', + item.info.citizenid, + item.info.firstname, + item.info.lastname, + item.info.birthdate, + gender, + item.info.nationality + } + }) + end + end + elseif itemData.name == 'driver_license' then + UseItem(itemData.name, src, itemData) + TriggerClientEvent('qb-inventory:client:ItemBox', src, itemInfo, 'use') + local playerPed = GetPlayerPed(src) + local playerCoords = GetEntityCoords(playerPed) + local players = QBCore.Functions.GetPlayers() + for _, v in pairs(players) do + local targetPed = GetPlayerPed(v) + local dist = #(playerCoords - GetEntityCoords(targetPed)) + if dist < 3.0 then + TriggerClientEvent('chat:addMessage', v, { + template = '', + args = { + 'Drivers License', + item.info.firstname, + item.info.lastname, + item.info.birthdate, + item.info.type + } + } + ) + end + end else UseItem(itemData.name, src, itemData) TriggerClientEvent('qb-inventory:client:ItemBox', src, itemInfo, 'use') @@ -357,13 +405,13 @@ QBCore.Functions.CreateCallback('qb-inventory:server:giveItem', function(source, return end - local removeItem = RemoveItem(source, item, giveAmount, slot, 'Item given to ID #'..target) + local removeItem = RemoveItem(source, item, giveAmount, slot, 'Item given to ID #' .. target) if not removeItem then cb(false) return end - local giveItem = AddItem(target, item, giveAmount, false, info, 'Item given from ID #'..source) + local giveItem = AddItem(target, item, giveAmount, false, info, 'Item given from ID #' .. source) if not giveItem then cb(false) return