the 3 triggers is already a thing with the default script.
Yeah just count the cops on and send it to the client and if its > Number then allow selling or something like that
the 3 triggers is already a thing with the default script.
Yeah just count the cops on and send it to the client and if its > Number then allow selling or something like that
Does any one have a vrp version?
cheers for that mate! and is there anyway to have this setup to only sell in one place and not the whole map like lets say you can sell from like 4 different map cords so its like a box and you can only sell in that area or else put in the area like davis street and you can only sell it there?
Kinda unreal but yeah you would have to do something to check between cords.
Or if you want it street based just check (i think its possible) what street they are on.
i was on a server and they had it that you could only sell drugs in davis/grovestreet, chamberlain hills, strawberry, rancho, davis, davis/davis ave. im not sure if they used this script but i most likely presume they did!
i recommend you look at like the street label script that would tell you how to do it.
Hey, how can i adjust the time that i need to sell the drug, for example, on the server i was, the time was 40 seconds, how can i adjust that to 20?
Thank you
yeah, getting hitch warnings when players are selling, otherwise its an amazing script!
on line 30 change the wait(0) to 50 or so. and if that makes the text not draw correctly let me know and ill update it.
Tried that just now, resmon shows the ms dropped significantly, idles at around 0.03ms now, but “press E to sell” text is flashing rapidly, at wait(50).
Even at wait(10) the text flashes very rapidly, but its possible to spam E to sell, and ms rises to 0.13ms, idle at 0.10ms.
Not ideal though
At wait(5), the text seems stable, but little improvement in performance, there seems to be improvement though, about 0.05ms.
Is this the reason NP went with AI going to you instead possibly? with DrawText3Ds?
Thank you for the input, appreciated!
try replacing the client with this
SX = nil
local myJob = nil
local selling = false
local has = false
local copsc = false
local draw = false
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function()
TriggerServerEvent('fetchjob')
end)
-- RETURN NUMBER OF ITEMS FROM SERVER
RegisterNetEvent('getjob')
AddEventHandler('getjob', function(jobName)
myJob = jobName
end)
currentped = nil
Citizen.CreateThread(function()
while true do
Wait(75)
local player = GetPlayerPed(-1)
local playerloc = GetEntityCoords(player, 0)
local handle, ped = FindFirstPed()
repeat
success, ped = FindNextPed(handle)
local pos = GetEntityCoords(ped)
local distance = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, playerloc['x'], playerloc['y'], playerloc['z'], true)
if IsPedInAnyVehicle(GetPlayerPed(-1)) == false then
if DoesEntityExist(ped)then
if IsPedDeadOrDying(ped) == false then
if IsPedInAnyVehicle(ped) == false then
local pedType = GetPedType(ped)
if pedType ~= 28 and IsPedAPlayer(ped) == false then
currentped = pos
if distance <= 2 and ped ~= GetPlayerPed(-1) and ped ~= oldped then
TriggerServerEvent('checkD')
if has == true then
draw = true
if IsControlJustPressed(1, 86) then
oldped = ped
SetEntityAsMissionEntity(ped)
TaskStandStill(ped, 9.0)
pos1 = GetEntityCoords(ped)
TriggerServerEvent('drugs:trigger')
Citizen.Wait(2850)
TriggerEvent('sell')
draw = false
has = false
SetPedAsNoLongerNeeded(oldped)
end
end
end
end
end
end
end
end
until not success
EndFindPed(handle)
end
end)
Citizen.CreateThread( function()
local player = GetPlayerPed(-1)
local playerloc = GetEntityCoords(player, 0)
local distance = GetDistanceBetweenCoords(pos1.x, pos1.y, pos1.z, playerloc['x'], playerloc['y'], playerloc['z'], true)
while draw do
Citizen.Wait(0)
if distance <= 2 then
drawTxt(0.90, 1.40, 1.0,1.0,0.4, "Press ~g~E ~w~to sell drugs", 255, 255, 255, 255)
end
end
end)
RegisterNetEvent('sell')
AddEventHandler('sell', function()
local player = GetPlayerPed(-1)
local playerloc = GetEntityCoords(player, 0)
local distance = GetDistanceBetweenCoords(pos1.x, pos1.y, pos1.z, playerloc['x'], playerloc['y'], playerloc['z'], true)
if distance <= 2 then
TriggerServerEvent('drugs:sell')
elseif distance > 2 then
TriggerServerEvent('sell_dis')
end
end)
RegisterNetEvent('checkR')
AddEventHandler('checkR', function(test)
has = test
end)
RegisterNetEvent('notifyc')
AddEventHandler('notifyc', function()
local coords = GetEntityCoords(GetPlayerPed(-1))
TriggerServerEvent('esx_phone:send', "police", 'Someone is selling me drugs' , true, {
x = coords.x,
y = coords.y,
z = coords.z
})
end)
RegisterNetEvent('animation')
AddEventHandler('animation', function()
local pid = PlayerPedId()
RequestAnimDict("amb@prop_human_bum_bin@idle_b")
while (not HasAnimDictLoaded("amb@prop_human_bum_bin@idle_b")) do Citizen.Wait(0) end
TaskPlayAnim(pid,"amb@prop_human_bum_bin@idle_b","idle_d",100.0, 200.0, 0.3, 120, 0.2, 0, 0, 0)
Wait(750)
StopAnimTask(pid, "amb@prop_human_bum_bin@idle_b","idle_d", 1.0)
end)
function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline)
SetTextFont(0)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
if(outline)then
SetTextOutline()
end
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end
Tried this, but same result, just text doesnt show at all now even threw me an error on line 79, but i think you forgot to add local pos1 like this:
Citizen.CreateThread( function()
local player = GetPlayerPed(-1)
local playerloc = GetEntityCoords(player, 0)
local pos1 = GetEntityCoords(ped)
local distance = GetDistanceBetweenCoords(pos1.x, pos1.y, pos1.z, playerloc['x'], playerloc['y'], playerloc['z'], true)
while draw do
Citizen.Wait(0)
if distance <= 2 then
drawTxt(0.90, 1.40, 1.0,1.0,0.4, "Press ~g~E ~w~to sell drugs", 255, 255, 255, 255)
end
end
end)
Im not very experienced, so im not sure, but it seems it cant get currentped pos from the currentped function, to draw the text.
Also still with wait(75), you have to truly spam E to be able to sell, even though text doesnt show.
Thank you for your time
EDIT:
Going back to the original version, with wait(7), i have managed to get the ms down to 0.17ms, not too bad, could be better though! just some input.
how to make it dirty money
there is a dirty money one on the github already.
Hi, I would like someone to help me with my problem. I liked your script a lot and I tried to make it when the sale is denied and the npc calls the police to give the correct gps position. He always sends them the same position and there is nothing and nobody there. Use gcphone.
But this line is not working.
Try this
RegisterNetEvent('notifyc')
AddEventHandler('notifyc', function()
PedPosition = GetEntityCoords(GetPlayerPed(-1))
local PlayerCoords = { x = PedPosition.x, y = PedPosition.y, z = PedPosition.z }
TriggerServerEvent('esx_addons_gcphone:startCall', 'police', 'Someone is selling me drugs', PlayerCoords, {
PlayerCoords = { x = PedPosition.x, y = PedPosition.y, z = PedPosition.z },
})
end)
Not sure if this works… but you can test
Where is here the solution button Thanks mate.
I have weed and opium on me but keep receiving this error and not really sure as to why ?
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:218: in function citizen:/scripting/lua/scheduler.lua:182
Error running system event handling function for resource esx_sellDirtyMoney: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: @esx_sellDirtyMoney/server.lua:173: attempt to index a nil value
stack traceback:
@esx_sellDirtyMoney/server.lua:173: in upvalue ‘handler’
citizen:/scripting/lua/scheduler.lua:219: in function citizen:/scripting/lua/scheduler.lua:218
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:218: in function citizen:/scripting/lua/scheduler.lua:182
Is it possible to connect with another phone mods instead of esx_phone?
Nice script, thank you very much!
I have a small suggestion to ask you, would it be possible to add a specific area to sell to the peds.
In that way, not just sell to all ped found in our way? Thank you.