remove blips| switch to waypoint. function spawning tables, code condense
This commit is contained in:
1 parent
1224133815
commit
83f2749101
13 files changed
+147
-269
No files matched your search
+24
-35
@@ -3,40 +3,33 @@ local sell = false
|
||||
local sold = false
|
||||
local targbusy = false
|
||||
|
||||
local function reset(targ)
|
||||
FreezeEntityPosition(targ, false)
|
||||
ClearPedTasks(targ)
|
||||
Wait(10000)
|
||||
DeletePed(targ)
|
||||
targbusy = false
|
||||
sold = true
|
||||
end
|
||||
|
||||
local function sellDrug(item, amount, price, targ)
|
||||
PoliceCall(20)
|
||||
targbusy = true
|
||||
if IsPedInAnyVehicle(PlayerPedId(), true) then
|
||||
Notify(Lang.Cornerselling.inveh, 'error')
|
||||
FreezeEntityPosition(targ, false)
|
||||
ClearPedTasks(targ)
|
||||
Wait(10000)
|
||||
DeletePed(targ)
|
||||
targbusy = false
|
||||
sold = true
|
||||
sell = false
|
||||
reset(targ)
|
||||
return end
|
||||
if not progressbar(string.format(Lang.Cornerselling.selling, GetLabel(item), price), 4000, 'uncuff') then return end
|
||||
TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, amount, price)
|
||||
FreezeEntityPosition(targ, false)
|
||||
ClearPedTasks(targ)
|
||||
Wait(10000)
|
||||
DeletePed(targ)
|
||||
targbusy = false
|
||||
sold = true
|
||||
reset(targ)
|
||||
end
|
||||
|
||||
local function deny(targ)
|
||||
PoliceCall(20)
|
||||
targbusy = true
|
||||
if not progressbar(Lang.Cornerselling.deny, 4000, 'argue5') then return end
|
||||
FreezeEntityPosition(targ, false)
|
||||
ClearPedTasks(targ)
|
||||
Wait(10000)
|
||||
DeletePed(targ)
|
||||
targbusy = false
|
||||
sold = true
|
||||
end
|
||||
reset(targ)
|
||||
end
|
||||
|
||||
function Cornersell()
|
||||
local targ = lib.GetClosestPed(GetEntityCoords(PlayerPedId()), 8)
|
||||
@@ -48,27 +41,24 @@ function Cornersell()
|
||||
until #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(targ)) < 2.0
|
||||
lib.requestAnimDict("rcmme_tracey1")
|
||||
TaskStartScenarioInPlace(targ, "WORLD_HUMAN_STAND_IMPATIENT_UPRIGHT", 0, false) FreezeEntityPosition(targ, true)
|
||||
|
||||
local item, amount, price = lib.callback.await('md-drugs:server:cornerselling:getAvailableDrugs', false)
|
||||
if item == 'nothing' then Notify(Lang.Cornerselling.nodrugs, 'error') sell = false FreezeEntityPosition(targ, false) ClearPedTasks(targ) return false end
|
||||
local options = {
|
||||
{ label = string.format(Lang.Targets.CornerSell.sell, amount, GetLabel(item), price), icon = "fas fa-eye",
|
||||
action = function() sellDrug(item, amount, price, targ) end,
|
||||
onSelect = function() sellDrug(item, amount, price, targ) end,
|
||||
{ label = string.format(Lang.Targets.CornerSell.sell, amount, GetLabel(item), price), icon ="fa-solid fa-money-bill",
|
||||
action = function() sellDrug(item, amount, price, targ) end,
|
||||
canInteract = function()
|
||||
if not targbusy then return true end end,
|
||||
},
|
||||
{ label = Lang.targets.CornerSell.deny, icon = "fas fa-eye",
|
||||
action = function() deny(targ) end,
|
||||
onSelect = function() deny(targ) end,
|
||||
canInteract = function()
|
||||
if not targbusy then return true end end,
|
||||
{ label = Lang.targets.CornerSell.deny, icon = "fa-solid fa-person-harassing",
|
||||
action = function() deny(targ) end,
|
||||
canInteract = function()
|
||||
if not targbusy then return true end end,
|
||||
},
|
||||
}
|
||||
AddMultiModel(targ, options, nil)
|
||||
repeat
|
||||
Wait(1000)
|
||||
until sold
|
||||
until sold
|
||||
if sold then sold = false return true end
|
||||
end
|
||||
|
||||
@@ -76,7 +66,7 @@ RegisterNetEvent('md-drugs:client:cornerselling', function()
|
||||
if not GetCops(QBConfig.MinimumDrugSalePolice) then return end
|
||||
local item, amount, price = lib.callback.await('md-drugs:server:cornerselling:getAvailableDrugs', false)
|
||||
if item ~= 'nothing' then
|
||||
if sell then
|
||||
if sell then
|
||||
Notify(Lang.Cornerselling.stop, 'error')
|
||||
sell = false
|
||||
else
|
||||
@@ -84,11 +74,10 @@ RegisterNetEvent('md-drugs:client:cornerselling', function()
|
||||
Notify(Lang.Cornerselling.start, 'success')
|
||||
repeat
|
||||
Wait(1000)
|
||||
if not Cornersell() then end
|
||||
until sell == false
|
||||
if not Cornersell() then end
|
||||
until not sell
|
||||
end
|
||||
else
|
||||
Notify(Lang.Cornerselling.nodrugs, 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
Reference in new issue
Block a user