The function “player:receiveItem” works fine for another item but for some reason this doesn’t work. I am receiving the item but the item doesn’t have any information
This is the event triggered to give the player the item, this is on the server side of a resource that is triggered on the client side
RegisterServerEvent('ems:extractblood:player')
AddEventHandler("ems:extractblood:player", function()
local src = source
--local target = tonumber(TargetID)
local user = exports["trp-core"]:getModule("Player"):GetUser(src)
local char = user:getCurrentCharacter()
--print(char.first_name.." "..char.last_name)
information = {
["Name"] = char.first_name .. " " ..char.last_name,
["BloodType"] = char.firstname,
["Test"] = char.firstname
}
TriggerClientEvent("player:receiveItem", src, "emptybloodvial", 1, true, information)
end)
This is the function called to give the player the item, it is in a client.js file
RegisterNetEvent('player:receiveItem');
on('player:receiveItem', async (id, amount, generateInformation, itemdata, returnData = '{}', devItem = false) => {
if (!(id in itemList)) {
//Try to hash the ID
let hashed = GetHashKey(id);
if (hashed in itemList) {
id = hashed;
} else {
//If item is still not found, try to find by name
Object.keys(itemList).forEach(function (key) {
if (itemList[key].displayname.toLowerCase().trim().replace(' ', '') === id.toLowerCase().trim().replace(' ', '')) {
id = key;
return;
}
});
}
}
let combined = parseFloat(itemList[id].weight) * parseFloat(amount);
if ((parseFloat(personalWeight) > maxPlayerWeight || parseFloat(personalWeight) + combined > maxPlayerWeight) && !devItem) {
emit('DoLongHudText', id + ' fell on the ground because you are overweight', 2);
let droppedItem = { slot: 3, itemid: id, amount: amount, generateInformation: generateInformation, data: Object.assign({}, itemdata), returnData: returnData };
cid = exports.trp_manager.isPed("cid");
emitNet('server-inventory-open', GetEntityCoords(PlayerPedId()), cid, '42069', "Drop-Overweight", { "items": [droppedItem] });
return;
}
SendNuiMessage(
JSON.stringify({
response: 'GiveItemChecks',
id: id,
amount: amount,
generateInformation: generateInformation,
data: Object.assign({}, itemdata),
returnData: typeof returnData === 'string' ? returnData : JSON.stringify(returnData || {}),
}),
);
});