[Release] [vRP] Sell drugs to NPC

Hello, I changed to choose some of the existing drugs in my server, if you want to use it there

server.lua (search RegisterServerEvent(‘drugs:item’) and replace all lines) for:

RegisterServerEvent('drugs:item')
AddEventHandler('drugs:item', function()
    local user_id = vRP.getUserId({source})
    local player = vRP.getUserSource({user_id})
    local drugs = {"weed", "cocaine", "lsd"} -- total drugs list
    local t = math.random(1,#drugs) -- count and choose one drugs list
    if vRP.tryGetInventoryItem({user_id,drugs[t],1,true}) then
      TriggerClientEvent('cancel', player)
    else
      TriggerClientEvent('done', player)
      TriggerClientEvent('cancel', player)
    end
  end)

Please test…

bye

3 Likes

Worked for me LeonardoR. Updated. Thanks.

Hey guys.

I’m having some issue converting this to ESX. I understand some coders like to keep tight lips about code they create, but I know most of us are cool. I’m not really asking for a code, just some help getting this system to work on ESX. Can anyone be of some guidance?

Never messed with ESX myself. Wouldn’t know where to even start

1 Like

Search for esx_boilerplate
With that template you can adapt most of the code.
Search for esx_fishing to see how to remove items.
Look at the existing esx scripts to see how they make things work.

1 Like

I’ve got it to approach the NPC, offer the drug, and they have refused and denied. But I can’t get paid or get inventory to adjust. Also can’t get the refusals to notify police…

Upload your work to github and link it to me, I’ll see if I can take a look.
I don’t have FiveM installed now so all work will need to be tested by you later.

1 Like

That would be really nice if someone could manage to translate this script in ESX because it would be perfect script for selling drugs… Thank you Kraker and Hypr9xa on your time spent on this !

1 Like

Good Morning,

My base is Vrpex vcs would know to inform me if I could install vrp sell drugs to npc for this base?
appears the button to tighten and sell to the NPC he does the animation but does not sell, the money does not enter and the drug does not leave the inventory, could any one help me?

Thank you

Can you make it so you only can sell one place on the map? or its i global only? :smiley:

Not familiar with Vrpex vcs so I wouldn’t be able to answer that, perhaps someone else here is though

Never really looked at restricting to an area. I suppose you could. I know someone else had also added a check to see how many cops were online before you could sell, similar to the the bank-robbery script, but to me both of of those kind of kill the realism a bit. Even dirty money/ vs clean. I changed it to clean for our server because of the whole “why are civilians walking around buying drugs with marked bills” argument.

Im new to this, its there some code you can use so the script only will work between 2 coords?

I have 3 diffrent drugs that i want to sell to 3 diffrent price ore random prices, how can that be done. Thanks

Hi, did you manage to somehow make this only works in specifics area ?

Hi guys, how can i delete markers on the map? i cant do that. And when i’m addin DrugsToNpcs it dont work. It say’s when im joinning on server ''couldn’t load DrugsToNpcs. Someone can help?

Please help i love this script but when i press h they cant move and i want them to be able to move after the deal is made but they are just stuck forever and when i press h it says person rejected even if they accepts HELP

Hypr9xa can i talk to you in private? Maybe in a discord?

noice

How can I make dirty money?

Do you have the script/ code for esx on this please as that’s something I would love to be able to do. Thanks