[Release] [ESX] Sell to NPC

Check for any errors in F8 or server console.
Check to see if it’s called weed_pooch?

Required?

  • mythic_notify (i can’t download! It Error 404)

A simple google search will help you find it.

Does the multiple drugs item works?? or for now is only working the np_selltonpc-single?

i used this to stop NPC store keeper sales

if ped ~= oldped and not selling and (IsPedAPlayer(ped) == false and IsPedModel(ped, 416176080) == false and pedType ~= 28) then

1 Like

Hello, I have updated to be able to sell in a specific location. Sorry for my bad English.
If you want to use with location you need to change it in client / client.lua
This:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10)
		if ped ~= 0 then 
			if not IsPedDeadOrDying(ped) and not IsPedInAnyVehicle(ped) then
                        local pedType = GetPedType(ped)
				if ped ~= oldped and not selling and (IsPedAPlayer(ped) == false and pedType ~= 28) then
					TriggerServerEvent('checkD')
					if drugtype ~= false then
						TriggerServerEvent('checkC')
						if numberofcops >= Config.NumberOfCops then
							local pos = GetEntityCoords(ped)
							DrawText3Ds(pos.x, pos.y, pos.z, 'Press E to sell ' .. drugtype)
							if IsControlJustPressed(1, 86) then
								selling = true
								interact(drugtype)
							end
						end
					end
				end
			else
				Citizen.Wait(500)
			end
		end
	end
end)

To This:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10)
		if ped ~= 0 then 
			local player = GetPlayerPed(-1)
			local playerloc = GetEntityCoords(player, 0)
			local distanceFromCity = GetDistanceBetweenCoords(Config.CityPoint.x, Config.CityPoint.y, Config.CityPoint.z, playerloc['x'], playerloc['y'], playerloc['z'], true)
			if not IsPedDeadOrDying(ped) and not IsPedInAnyVehicle(ped) then
                        local pedType = GetPedType(ped)
				if ped ~= oldped and not selling and (IsPedAPlayer(ped) == false and pedType ~= 28) then
					if distanceFromCity < Config.DistanceFromCity then
						TriggerServerEvent('checkD')
						if drugtype ~= false then
							TriggerServerEvent('checkC')
							if numberofcops >= Config.NumberOfCops then
								local pos = GetEntityCoords(ped)
								DrawText3Ds(pos.x, pos.y, pos.z, 'Press E to sell ' .. drugtype)
								if IsControlJustPressed(1, 86) then
									selling = true
									interact(drugtype)
								end
							end
						end
					end
				end
			else
				Citizen.Wait(500)
			end
		end
	end
end)

And in the config lua add this two lines:

Config.DistanceFromCity = 370 -- set distance Radius
Config.CityPoint = {x= -1687.68, y= -1055.75, z= 13.09} -- Pier location

Enjoy!

3 Likes

HUGE thank you for this man, works a charm! @jonare

1 Like

Is there a possibility of adding a blip on the map for the police when they’re notified?

2 Likes

Police notification is very scarce, it would be nice to add a mark type on the map for a few minutes when it is warned.

I have tried installing the single version and the full version, but neither works for me. I use ESX 1.2 and I have dependencies, could someone help me? The message to sell does not appear. Should I go to a specific area? Thank you.

would it be possible to add more than one zone? and put a mark for a few minutes when the police are called?

Do you have the item weed_pooch in your inventory?

Yes, for example: I go to pier to sell, from time to time it makes the action of selling to a person, but then it does not work until I restart the server.

Edit: Is it necessary to have the latest artifacts on the server? I use the option: latest recommended (2431) on my Linux server.

Edit2: Now appears in F8: script:np_selltonpc script error: citizen:/scripting/lua/scheduler.lua:924: no such export sendalert in resource mythic_notify

How can i resolve this?

Yes of course, in the line, you need add the OR condition.

if distanceFromCity < Config.DistanceFromCity then

Like this:

if distanceFromCity1 < Config.DistanceFromCity or distanceFromCity2 < Config.DistanceFromCity then

If you need add more, before need add the next condition with OR.
In config.lua add coordenates.

Config.CityPointWeed1 = {x= -1687.68, y= -1055.75, z= 13.09}
Config.CityPointWeed2 = {x= -1446.49, y= -1543.07, z= 0.87}

I´m working in the automatic mark with calling another script. When is done I´ll share it here.

Enjoy

4 Likes

in client.lua replace all SendAlert to DoHudText

Official thread has been updated with the mythic notifications used in this script

https://github.com/FlawwsX/mythic_notify

Enjoy.

1 Like

Feel free to do a pull request of this.
You could make it so that the option to have the radius enabled is configurable.

1 Like

Download the mythic notifications.

Thank you, I will wait for you to finish your version

i need help please i get this error, thanks for your time
SCRIPT ERROR: @ np_selltonpc / server / server.lua: 70: Attempt to index a null value