[ESX stasiek_selldrugs] Sell Drugs to NPC +dispatch NEW! 🚓

police
npc
esx
drug
sell

#128

Ok so everything works, the only issue I’m getting and I don’t know why is the alert to the police is still in Polish. The language in the config is set to en, I see in the server.lua there is English translation for the outlawalert but it’s not coming through. I tried deleting the Polish text and it breaks the script. I tried translating the Polish to English and it breaks the script. Anyone know how to get it in English? OutlawAlert is in English just not when Police get alerts about someone selling drugs. All the messages with this script are in English so I’m at a loss.


#129

You need to change it in the client lua If in not misstaken. Im think it was there i changed it. If not in client then its in the server lua


#131

Norwegian translation:
no.lua (894 Bytes)


#132

So after the latest update for the script and using the latest Es_extended and latest essentials this is the error I get when they sell drugs. Thanks


#133

Try to remove these lines


#134

tried that and now I dont get the option to sell and if I walk up to NPC’s they dont do anything no error in the console but I see in f8,

Its gives me no options to sell at all with that removed , before I could at least hit E as the notification didn’t come up.


#135

Update es_extended :wink:


#136

I am running the latest version that was released 5 days ago


#137

I need help with dispatche’s, So me and my friend was testing dispatches, and my friend sold like 100 pooches of weed and i dont get even one dispatch, can some one help me ??


#138

I’m having this problem when I finish selling the drug.


#139

The first thing I could suggest is to update essentialmode, as you are on version 5.2.1 and current is 6.0.2, and also es-extended.


#140

I already solved the problem was on server.lua


#141

doesn’t come with the sql files


#142

it would really help if you put the sql in the download. (weed, meth, cocaine, opium) b/c it CANT FUNCTION WITHOUT IT


#143

@Shyricaus - It would be nice to mention what you fixed to get it working. I have however found the issue and will share it.

Line 162 in the server.lua

Original

	TriggerClientEvent('esx:showNotification', _source, _U('you_have_sold') .. '~b~'..x..'~w~' .. _U(drugtype) .. blackMoney .. '$')

Fixed

	TriggerClientEvent('esx:showNotification', _source, _U('you_have_sold') .. '~b~'..x..'~w~' .. _U('drugtype') .. blackMoney .. '$')

This did allow me to start selling drugs to the AI however there was still an issue where the drugs were not getting named in notifications.

I made a edit to the server main.lua and I give full credits to @Stasiek.

Here is my edited version of the server main.lua - main.lua (9.8 KB)
It basically has a call per each drug type and spits out an notification for only that one particular
drug.

Here is a small sample :smiley:

--  ======= METH =======
--  ======= METH =======
--  ======= METH =======

RegisterServerEvent('sellDrugs')
AddEventHandler('sellDrugs', function()
	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)
	local methqty = xPlayer.getInventoryItem('meth_pooch').count
	local methqtySingle = xPlayer.getInventoryItem('meth').count
	local x = 0
	local blackMoney = 0
	local drugType = nil
	
	if Config.SellMeth and methqty > 0 or Config.SellMeth and methqtySingle > 0 then
		if methqty > 0 and Config.SellPooch then
			drugType = 'meth_pooch'
			if methqty == 1 then
				x = 1
			elseif methqty == 2 then
				x = math.random(1,2)
			elseif methqty == 3 then
				x = math.random(1,3)
			elseif methqty == 4 then
				x = math.random(1,4)
			elseif methqty >= 5 then
				x = math.random(1,5)
			end
		elseif methqtySingle > 0 and Config.SellSingle then
			drugType = 'meth'
			if methqtySingle == 1 then
				x = 1
			elseif methqtySingle == 2 then
				x = math.random(1,2)
			elseif methqtySingle == 3 then
				x = math.random(1,3)
			elseif methqtySingle == 4 then
				x = math.random(1,4)
			elseif methqtySingle >= 5 then
				x = math.random(1,5)
			end
		end
	else
		TriggerClientEvent('nomoredrugs', _source)
		return
	end
	
	if drugType=='meth_pooch' then
		blackMoney = Config.MethPrice * 5 * x
	elseif drugType=='meth' then
		blackMoney = Config.MethPrice * x
    end
	
	if drugType ~= nil then
		xPlayer.removeInventoryItem(drugType, x)
	end
	
	xPlayer.addAccountMoney('black_money', blackMoney)
	TriggerClientEvent('sold', _source)
	TriggerClientEvent('esx:showNotification', _source, _U('you_have_sold') .. '~b~'..x..'~w~' .. _U('meth') .. blackMoney .. '$')
end)

--  ======= COKE =======
--  ======= COKE =======
--  ======= COKE =======

RegisterServerEvent('sellDrugs')
AddEventHandler('sellDrugs', function()
	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)
	local cokeqty = xPlayer.getInventoryItem('coke_pooch').count
	local cokeqtySingle = xPlayer.getInventoryItem('coke').count
	local x = 0
	local blackMoney = 0
	local drugType = nil

	if Config.SellCoke and cokeqty > 0 or Config.SellCoke and cokeqtySingle > 0 then
			if cokeqty > 0 and Config.SellPooch then
			drugType = 'coke_pooch'
			if cokeqty == 1 then
				x = 1
			elseif cokeqty == 2 then
				x = math.random(1,2)
			elseif cokeqty == 3 then
				x = math.random(1,3)
			elseif cokeqty == 4 then
				x = math.random(1,4)
			elseif cokeqty >= 5 then
				x = math.random(1,5)
			end
		elseif cokeqtySingle > 0 and Config.SellSingle then
			drugType = 'coke'
			if cokeqtySingle == 1 then
				x = 1
			elseif cokeqtySingle == 2 then
				x = math.random(1,2)
			elseif cokeqtySingle == 3 then
				x = math.random(1,3)
			elseif cokeqtySingle == 4 then
				x = math.random(1,4)
			elseif cokeqtySingle >= 5 then
				x = math.random(1,5)
			end
		end
	else
		TriggerClientEvent('nomoredrugs', _source)
		return
	end

	if drugType=='coke' then
		blackMoney = Config.CokePrice * x
	elseif drugType=='coke_pooch' then
		blackMoney = Config.CokePrice * 5 * x
    end

	if drugType ~= nil then
		xPlayer.removeInventoryItem(drugType, x)
	end
	
	xPlayer.addAccountMoney('black_money', blackMoney)
	TriggerClientEvent('sold', _source)
	TriggerClientEvent('esx:showNotification', _source, _U('you_have_sold') .. '~b~'..x..'~w~' .. _U('coke') .. blackMoney .. '$')
end)

#144

I also made a quick edit to the en.lua file

Original

['no_more_drugs'] = '~r~You dont have~s~ more ~g~drugs!',

Edited

['no_more_drugs'] = '~r~The person doesnt want any more drugs.~s~ or ~g~ Maybe you are out?',


After making the typo fix. The drugs were not getting named.

After my fix.


#145

for those who use English translation do not need to modify much, that is to modify this line of commando in line 162.

Original

TriggerClientEvent('esx:showNotification', _source, _U('you_have_sold') .. '~b~'..x..'~w~' .. _U(drugtype) .. blackMoney .. '$')

Fixed

TriggerClientEvent('esx:showNotification', _source, _U('you_have_sold') .. '~b~' .. x .. '~w~ ' .. drugType .. ' por ' .. blackMoney .. '$')

#146

Nice script, installed and went over settings. For some reason no matter where I go it says “You’re too far away from city” and It’s set to 10000 like it was from the start. Any ideas what could be wrong? Thanks


#147

Change it to 20000


#148

Okay well I did that, now I don’t get any errors but it also doesn’t sell. Is it because I don’t have whatever mod that turns the marijuana into pooches? Sorry new to this so learning as I go. I have esxdrugs which only has Marijuana. Was told can’t get the coke, meth, opium anymore. Anyway, It’s setup to go to the Cannabis field, then take that to processor which turns the cannabis to marijuana then sell.