[Release]drugs to npc's [ESX]

if i was to add a random number to remove from inventory how would i then cause it to recognise the number it has removed and pay that amount,

so if it took 1 it paid 1
but if it took 5 it paid 5

1 Like

^^ I would also like to know how to make the number of bags you sell to the npc random between say 1-3 bags and get paid for all the bags I sell, I currently can only make it pay for 1 bag even if i sell the npc 3, Regardless of how many I sell i only get paid for 1. Does anyone know how I can get the payout to recognise the math.random number please, Thanks.

I am using this script, and gcphone, didnt change anything, and the Messages are working.
There is just a thing thats very problematic… it sends a phone number
From #xxx-xxxx and that number is the drug sellers number… well i dont know how to mask that… its important because of metagaming… is there anyone that can help me with this? :slight_smile:

This works well, if you want to try it … with notice to the police if they reject drugs npcs

1 Like

how can i only sell it to the chosen npc

sorry for the late reply. but you could do something pretty simple

create a math.random
then just put that in for the amount to remove and then multiply the price times the amount sold.

  	local xPlayer = ESX.GetPlayerFromId(source)
	local meth = xPlayer.getInventoryItem('meth_pooch').count
	local coke 	  = xPlayer.getInventoryItem('coke_pooch').count
	local weed = xPlayer.getInventoryItem('weed_pooch').count
	local opium = xPlayer.getInventoryItem('opium_pooch').count
	local paymentc = math.random (500,1000)
	local paymentw = math.random (150,300)
	local paymentm = math.random (300,700)
	local paymento = math.random (150,300)
        local sellAmount = math.random(1,3)

		if coke >= 1 and success == true then
			 	TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
				TriggerClientEvent("pNotify:SendNotification", source, {
					text = "You have sold a bag of cocaine for $" .. paymentc ,
					type = "success",
					progressBar = false,
					queue = "lmao",
					timeout = 2000,
					layout = "CenterLeft"
			})
			TriggerClientEvent("animation", source)
			xPlayer.removeInventoryItem('coke_pooch',  sellAmount)
  			xPlayer.addAccountMoney('black_money', (paymentc *  sellAmount))
  			selling = false

how can i sell it only to gang npc ?

I didn’t want it to sell to all npcs

how can i add a min numbers of cops to sell?

when i go to sell to a npc i get this error

Hey how do I add a drug?

So I’ve been trying to use this script all day and cant figure out what im doing wrong. Ive put it into my resources and started it in the .cfg… Am I missing something? Becasuse I’ve tried multiple scripts for this now and never get a sell prompt or any prompt at all … Please Help

Do you have pnotify?

if i want to add crack to this do i just do

 if crack >= 1 and success == true then
			 	TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
				TriggerClientEvent("pNotify:SendNotification", source, {
					text = "You have sold a bag of crack for $" .. paymentc ,
					type = "success",
					progressBar = false,
					queue = "lmao",
					timeout = 2000,
					layout = "CenterLeft"
			})
			TriggerClientEvent("animation", source)
			xPlayer.removeInventoryItem('crack', 1)
  			xPlayer.addAccountMoney('black_money', paymentc)
  			selling = false

and then add local paymentc = math.random (1100,2200)

Is this correct ?

edit :
hmm, so i cant seem to get this script working, have added it to server.cfg, have drugs in inventory, made cop limit 0…

it says “press e to sell drugs” , so i press e, the ped freezes and then just walks off, i get no money and no drugs taken from inventory.

hmm, idk haven’t worked with fivem in a while. It should work.

is there a way you can tone down the number of times you sell to the same ped because for example

when i sell to 2 ped standing close to each other you can continue to sell to both and spam it and keep getting money without them walking away or they wont buy anymore

Need a minimum ammount of cops system, or this mod isnt at all useful

its not a mod. and it already has that system. Dont blame the script if you are to stupid to use it.

it is a way to sell drugs by zones? for exmaple:
weed only can be sold in the beach
coke only can be sold in grove street or forum drive zone
meth only can be sold in vinewood
etc
thanks.

1 Like

This. It should not be a call with the criminal’s phone number…

Why can’t the alert simply be a circle similar to ESX_outlaw alert…???

lol dirty money is not just marked bills, dirty money is also money you get from drug deals and/or any money gained from any criminal acts. So if the Police just so happens to mark special bills to a certain area and had agents give them to try and bust dealer yet the dealers escape then the dealers need to wash that money so that they are not traced back to them .