From 6cf4f337e8384a3da740b796ab0375c029498fa7 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 25 Oct 2022 22:27:35 -0500 Subject: [PATCH] Fix spawning all ground items + take/put item owner --- scripts/server/item.js | 43 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/scripts/server/item.js b/scripts/server/item.js index f8072a9d..0ab04605 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -702,7 +702,7 @@ function dropItemCommand(command, params, client) { * */ function putItemCommand(command, params, client) { - clearPlayerItemActionState(client); + //clearPlayerItemActionState(client); let hotBarSlot = toInteger(params); @@ -745,6 +745,8 @@ function putItemCommand(command, params, client) { return false; } + clearPlayerItemActionState(client); + if (getItemTypeData(getItemData(itemId).itemTypeIndex).putAnimationIndex != -1 && !isPlayerInAnyVehicle(client)) { forcePlayerPlayAnimation(client, getItemTypeData(getItemData(itemId).itemTypeIndex).putAnimationIndex, 0.0); } @@ -2141,7 +2143,7 @@ function cacheAllGroundItems() { function createAllGroundItemObjects() { for (let i in getServerData().groundItemCache) { - createGroundItemObject(i); + createGroundItemObject(getServerData().groundItemCache[i]); } } @@ -2270,6 +2272,20 @@ function deleteItem(itemId, whoDeleted = -1) { function getBestNewOwnerToPutItem(client) { let position = getPlayerPosition(client); + let possibleItem = getClosestItemOnGround(position); + if (possibleItem != -1) { + if (getDistance(getItemPosition(possibleItem), position) <= getGlobalConfig().itemContainerDistance) { + return [AGRP_ITEM_OWNER_ITEM, possibleItem]; + } + } + + let possibleVehicle = getClosestVehicle(position); + if (possibleVehicle != false) { + if (getVehicleData(possibleVehicle) != false && getDistance(getVehicleTrunkPosition(possibleVehicle), position) <= getGlobalConfig().vehicleTrunkDistance) { + return [AGRP_ITEM_OWNER_VEHTRUNK, possibleVehicle]; + } + } + let possibleHouse = getPlayerHouse(client); if (possibleHouse != -1) { if (getHouseData(possibleHouse) != false) { @@ -2284,20 +2300,6 @@ function getBestNewOwnerToPutItem(client) { } } - let possibleVehicle = getClosestVehicle(position); - if (possibleVehicle != false) { - if (getVehicleData(possibleVehicle) != false && getDistance(getVehicleTrunkPosition(possibleVehicle), position) <= getGlobalConfig().vehicleTrunkDistance) { - return [AGRP_ITEM_OWNER_VEHTRUNK, possibleVehicle]; - } - } - - let possibleItem = getClosestItemOnGround(position); - if (possibleItem != -1) { - if (getDistance(getItemPosition(possibleItem), position) <= getGlobalConfig().itemContainerDistance) { - return [AGRP_ITEM_OWNER_ITEM, possibleItem]; - } - } - return [AGRP_ITEM_OWNER_NONE, 0]; } @@ -2310,6 +2312,15 @@ function getBestItemToTake(client, slot) { let ownerType = AGRP_ITEM_OWNER_NONE; let ownerId = 0; + let possibleItem = getClosestItemOnGround(position); + if (getItemData(possibleItem)) { + if (typeof getItemData(possibleItem).itemCache[slot] != "undefined") { + itemId = getItemData(possibleItem).itemCache[slot] + ownerType = AGRP_ITEM_OWNER_ITEM; + ownerId = possibleItem; + } + } + let possibleHouse = getPlayerHouse(client); if (getHouseData(possibleHouse)) { if (typeof getHouseData(possibleHouse).itemCache[slot] != "undefined") {