Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add item to trunk export #119

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

Luke20201
Copy link

@Luke20201 Luke20201 commented Oct 12, 2024

Additions

  • A function to find empty trunk slots, counts the number of slots first via vehiclename, then class then reverts to default
  • Export to add item to trunk
  • Export to remove items from trunk

Modifications

  • Modifies the AddToTrunk function, adding the vehicleName and vehicleClass (purpose is for finding out how many slots there are, maybe there's a better way to do this). There is error handling for where the trunk isn't registered already.

Testing
Tested both exports on qbcore, tested to make sure items still worked when adding/removing etc. No bugs found.

Examples
exports['ps-inventory']:AddToTrunk(plate, false, false, "weapon_pistol", 1, info, false, "asea", 2)
exports['ps-inventory']:AddToTrunk(plate, 1, false, "weapon_pistol", 1, info, false, "asea", 2)
exports['ps-inventory']:RemoveFromTrunk(plate, 1, "weapon_pistol", false)

@Luke20201 Luke20201 changed the title Update main.lua Add item to trunk export Oct 12, 2024
server/main.lua Outdated Show resolved Hide resolved
return nil
end

local function AddToTrunk(plate, slot, otherslot, itemName, amount, info, created, vehicleName, vehicleClass)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While at it, splitting this method into smaller methods for readability would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants