Hi there. I’ve been looking for a good script that allows you to sell drugs or any items to NPC. I couldn’t find one that was well optimized and didn’t cause hitch threads. I’ve been doing Lua for quite some time, and have learned a couple of things during the process. I went ahead and made my own version of the sell to NPC script.
This version is well optimized for the client, uses 0.01ms (thanks to @IB1G) whilst not next to a ped, and uses 0.12ms whilst you have the item and are next to a ped. It does not cause server hitch thread warnings, but I have not done intensive testing. I have knifed a ped, checked on dead peds, etc…
I used [Release] [ESX] NPC Drug Sales (Optimized) for some parts. I utilized some awesome Google skills to optimize the checks for NPC. I copied the way esx_outlawalerts handles police notifications.
Features
Optimised both server and client-side.
Ability to sell all drugs to NPC, with a configurable price.
Random chance for sell success.
Police notifications if the Ped decides to call the police.
Check for old Ped.
Animations when drugs are sold to NPC.
Config file to allow you to modify the script
Most drugs supported.
Keep in mind…
This doesn’t have a bunch of features, but as time goes on I will add some nice, unique features to it.
You can create pull requests if you want to add features for the community to use.
Use the forum thread or Github for issues.
Download
For the single item version (weed) use the following:
If you have a powerful server and are able to handle hitch threads and need multiple items support, use the following:
Very nice release, i have a similiar version but that works differently, never toud about making it the way you made, but its very simple and it works, congrats !
I also made a pull request, i made some extra otimization, please test it live before merge it and check if everything is as you like
Appreciate the reply. I’ve seen the changes and tested them. You didn’t make a pull request, if you want I’ll wait for you to make the PR and then I’ll merge. Unless you want me to just do it.
very beautiful and without failures, it would be good if you could choose locations where drugs are going to be sold…
and by the way, where proggresbar works I don’t see
This is me being super lazy but could you create a config for adding multiple drugs to it easily? I assume it’d be much easier for you to do than myself because you wrote the script. If not it’s cool I’ll fuck around with it til I do it.
make sure that you activate the sale by a menu of the krz-personal menu type and that it is the pnj which requests the drug by stopping randomly with a colored circle which appears on the pnj which requests the drug (a can like when we do taxi missions and wait for a customer to request a taxi) I hope it’s clear XD (a bit like on the GTA Life server, it’s an en server)
if you can do it you’re the best even if you already are