[Release]drugs to npc's [ESX]

hmm anything in the f8 console? idk why it should work :frowning:

Nothing on f8 console as well :frowning:

hmm i really have no clue sorry

well now im curious if others are having this issue.

same cause mine works just fine

does this version notify police with location of were a sell was made incase the ped called the cops?

no i find that super unrealistic but you coud add it pretty easy

I see thanks :slight_smile: I know the other esx version had a part of it but not fully. I’m thinking I want like 10% chance that it triggers an Npc calling cops so it still have small risk to selling drugs. :slight_smile: I’m pretty new to typeing code… so if you have any tip for me so I can get it to trigger a notification for police then that would be awesome :slight_smile: if u don’t want to I understand :slight_smile: much love

well if you like at the server.lua for mine i have a pass or fail. You could put that on client or one similar and just make it so if like number 9 or 8 etc etc and then if it == 10 then trigger the notifaction

So like
https://pastebin.com/cU4kEPD0

or edit the server one to trigger the notifaction

ill see if i can figure it out… first time dealing with Pnotify :stuck_out_tongue:

Thank you for this script! Is there any way to let the script check for a minimum amount of cops online and give a notification when there’s not enough cops online to sell?

You could try something like this

Then just edit the

CopsConnected >= 3

and

CopsConnected < 3

to whatever you want

local CopsConnected           = 0
 
function CountCops()
 
    local xPlayers = ESX.GetPlayers()
 
    CopsConnected = 0
 
    for i=1, #xPlayers, 1 do
        local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
        if xPlayer.job.name == 'police' then
            CopsConnected = CopsConnected + 1
        end
    end
 
    SetTimeout(1000, CountCops)
 
end
CountCops()
 
RegisterNetEvent('drugs:trigger')
AddEventHandler('drugs:trigger', function()
    TriggerEvent('currentlySelling')
        if selling == true and CopsConnected >= 3 then
            TriggerEvent('pass_or_fail')
            TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 1)
            TriggerClientEvent("pNotify:SendNotification", source, {
            text = "trying to convince person to buy the product",
            type = "error",
            queue = "lmao",
            timeout = 2500,
            layout = "Centerleft"
            })
        elseif CopsConnected < 3 then
            TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 1)
            TriggerClientEvent("pNotify:SendNotification", source, {
            text = "There is not enough cops on to sell drugs",
            type = "error",
            queue = "lmao",
            timeout = 2500,
            layout = "Centerleft"
            })
    end

How would you trigger so the police gets notified and a marker on the map when a player doesn’t want to buy drugs?

edit the pass or fail to make it so if it fails it will trigger a notifaction

That works like a charm @ExoticNx, thanks. @notcool you could try to implement it in esx_outlawalert. Maybe it would be even better to calculate a percentage chance that the police will be alerted.

@ExoticNx hey man, I’ve been doing little tweaks and such… but I can’t seem to be able to trigger an event for it to display a notification, have you any luck in doing this yourself?

i haven’t tried at all. What are you trying to achive again?

Well, I’ve been looking around your code and it doesn’t have the “notify” trigger setup, but because of the way it was coded it makes it a little bit more trickier to add the Notification of “Press ~INPUT_HEADLIGHT~ to sell drugs” (Or something along the lines) of that, I’m just not sure how I can adapt your script for the notification to display… was wondering if you would shed some light

I never really planned on making it a thing but here you go.

Update 3/17/18
Added if you have the drugs it will say on screen “Press E to sell drugs”
Changed Trigger key for H to E
Changed % of failing to 40% instead of 30%

1 Like