[Release] [ESX] Easy Weapon Accessories (Add and remove attachments)

EDIT

New Features:

Major Update!

You now lose a attachment when it’s used on a gun.

You can now remove attachments from guns and you get the attachment back in your inventory. (Up arrow key to remove by default)

Useless config removed.

Integrated @jsfour table system.

Added a bit in the sql that adds the items for sale in the Liquor store. (if you don’t use this system just remove that section of the sql)

Thanks massively to @JiminyKroket for these changes!

What is this?

This resource is basically abit of a fix up of the existing eden_accessories. I have translated it fully to English, Fixed the SQL and made sure the attachments now work as items.

This allows you to purchase weapon attachments from a shop of your choosing (default configured to the liquor store)

Then equip a weapon and then use the attachment in your inventory that then puts the attachment on the gun you’re holding. It then removes the attachment from you inventory but when you take it off you get it back.

Super simple!

Planned Features :

(Added/ESX Supports this by default now) Weapon Attachments saving to the gun via DB

Download : Download here from github.

Full Credit to Solaris who is the original creator of eden_accessories, sadly I couldn’t get a hold of him.

14 Likes

what a load of poop lol… joking <3 you tea drinking crumpet eating human lol

1 Like

I installed this and it works great but it seems my hunger bar stopped working. I disabled the script and it is still not working. Have you had this happen before? I have no errors and didn’t have any issues before installing.

Not sure what the original author did but oh well here’s some feedback:

  • You forgot to add “USE `essentialmode`;” in your SQL file and the `price` column is not a default column. Which means people won’t be able to run it unless they’ve added that column. And they will most likely send you screenshots of their errors. (It’s very simple to fix but you know how people are…)
  • You have an empty config file that you don’t use
  • You have a couple of unused xPlayer variables in the server file
  • I suggest you look into something called tables to narrow your code down. Having hundreds lines of code that pretty much does the same thing is not something you want to have. (Talking about these):
GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_COMBATPISTOL"), GetHashKey("COMPONENT_AT_PI_SUPP"))  
ESX.ShowNotification(("You have equipped your suppressor. Re-equip this next time you're in the city.")) 
used = used + 1

You can have a look at my modifed client and server files. The client file went from 423 lines to 54 lines:
https://pastebin.com/WkbFURcH
https://pastebin.com/drMTdGJu

I might have missed a weapon or component but you get the idea :slight_smile:

9 Likes

I deleted all the files and my hunger bar came back. Any idea on how to fix this? Love the weapon attachments, don’t want to get rid of the script.

All of them noted :slight_smile:

Ah yeah I see what you mean about the client file, much better will push it as a change later. thank you mate!

This script absolutely nothing to do with hunger mate it in no way is linked to basic needs or status

Hey mate, price colunm on the .sql is not default. You should remove it, you will get a toons of people telling “Oh i get an error on sql”.

1 Like

Nice XD

so do we need eden_accessories for this as it still has code relating to it in the main.luas?

Lol … No this is “a fix up of the existing eden_accessories”

It’s a better version of it

i know it doesnt but for some reason when i load it in my hunger stops working every time. just wanted to see if you anyone else had this problem or if there was something i could do.

No mate sorry not a clue, i’m running Status and Basic needs with it no problems

I’m glad he didn’t put that in. I’ve never used a database named essentialmode and it’s not needed. If it’s not there, those that don’t use that for a database name won’t need to edit it out and those that do, don’t need to edit it in. It will just work.

1 Like

As far as checking the player’s inventory for an item, use this snippet of code I found for reference.

if not GUI.IsOpen then --checking if phone hud is already present
          ESX.TriggerServerCallback('esx_phone:getItemAmount', function(qtty)
          if not ESX.UI.Menu.IsOpen('phone', GetCurrentResourceName(), 'main') and qtty > 0 then
            ESX.UI.Menu.CloseAll()
            ESX.UI.Menu.Open('phone', GetCurrentResourceName(), 'main')
          else
            ESX.ShowNotification("~r~You do not have a phone \n~b~(Buy one from a nearby shop)")
          end
        end, 'phone')
        end
1 Like

You’re giving me feedback on my feedback?.. That’s great, instead of giving the author some feedback.

It’s not needed? That depends on how you run the SQL query and you unfortunately can’t assume every user will run it in the selected database.

People will of course have to change that name if they’re using something else. But most of the ESX users does have a database called Essentialmode.

It’s of course up to the author to do whatever he think is necessary. I just know out of experience that some people might contact him and ask him about the error. :slight_smile:

1 Like

Hi mate,

It does the check for the item already just doesn’t remove it when used

Major Update!

You now lose a attachment when it’s used on a gun.

You can now remove attachments from guns and you get the attachment back in your inventory. (Up arrow key to remove by default)

Useless config removed.

Integrated @jsfour table system.

Added a bit in the sql that adds the items for sale in the Liquor store. (if you don’t use this system just remove that section of the sql)

Thanks massively to @JiminyKroket and JSfour for these changes!

1 Like

Got it working in a custom shop last night , really cool.

So the process is , have your gun out > inventory > use item > RIGHT CLICK to close inventory menu.

I found that if i dont right click, and i press escape to exit the inventory menu it will close the menu and not apply the attachment.

other than that works great thank you, Now i just have to add all the other attachments like scopes n stuff :slight_smile:

1 Like

Make sure you redownload the new version, you can now remove attachments off your guns and they’ll go back in your inventory