- half done
This commit is contained in:
1 parent
d2f70d78ed
commit
ebc47ba5d7
41 files changed
+1499
-1012
No files matched your search
+59
-28
@@ -9,31 +9,56 @@ end
|
||||
|
||||
local function sellDrug(item, amount, price, targ)
|
||||
PoliceCall(20)
|
||||
if ps.vehicleData() then
|
||||
ps.notify(ps.lang('Cornerselling.inVeh'), 'error')
|
||||
if IsPedInAnyVehicle(PlayerPedId(), true) then
|
||||
Bridge.Notify.SendNotify(Bridge.Language.Locale('Cornerselling.inVeh'), 'error')
|
||||
walkAway(targ)
|
||||
return
|
||||
end
|
||||
|
||||
if not ps.progressbar(string.format(ps.lang('Cornerselling.selling', ps.getLabel(item), price)), 4000, 'uncuff') then walkAway(targ) return end
|
||||
if not progressbar(Bridge.Language.Locale('Cornerselling.selling', Bridge.Inventory.GetItemInfo(item).label, price), 4000, 'uncuff') then
|
||||
walkAway(targ)
|
||||
return
|
||||
end
|
||||
buyers[targ] = 'sold'
|
||||
TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, amount, price)
|
||||
TriggerServerEvent('md-drugs:server:sellCornerDrugs', item, amount, price, NetworkGetNetworkIdFromEntity(targ))
|
||||
walkAway(targ)
|
||||
end
|
||||
|
||||
local function deny(targ)
|
||||
PoliceCall(20)
|
||||
PoliceCall(20)
|
||||
buyers[targ] = 'sold'
|
||||
if not ps.progressbar(ps.lang('Cornerselling.deny'), 4000, 'argue5') then return end
|
||||
if not progressbar(Bridge.Language.Locale('Cornerselling.deny'), 4000, 'argue5') then return end
|
||||
walkAway(targ)
|
||||
end
|
||||
|
||||
local function getClosestPed()
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local distance = 10.0
|
||||
local pedList = GetGamePool('CPed')
|
||||
local closestDistance = 1000.0
|
||||
local PED = nil
|
||||
for i = 1, #pedList do
|
||||
local ped = pedList[i]
|
||||
if ped ~= PlayerPedId() then
|
||||
local pedCoords = GetEntityCoords(ped)
|
||||
local dist = #(coords - pedCoords)
|
||||
if dist < closestDistance then
|
||||
PED = ped
|
||||
closestDistance = dist
|
||||
end
|
||||
end
|
||||
end
|
||||
if PED and closestDistance < distance then
|
||||
return PED, closestDistance
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local function findPed()
|
||||
local targ = nil
|
||||
repeat
|
||||
Wait(100)
|
||||
targ = ps.getNearestPed(GetEntityCoords(PlayerPedId()), 8)
|
||||
|
||||
targ = getClosestPed()
|
||||
if IsPedInAnyVehicle(targ, false) or GetEntityHealth(targ) == 0 or not IsPedHuman(targ) then
|
||||
targ = nil
|
||||
end
|
||||
@@ -47,15 +72,17 @@ local function findPed()
|
||||
if not sell then return end
|
||||
buyers[targ] = true
|
||||
|
||||
ps.drawText(ps.lang('Cornerselling.wait'))
|
||||
Bridge.HelpText.ShowHelpText(Bridge.Language.Locale('Cornerselling.wait'))
|
||||
|
||||
repeat
|
||||
Wait(1000)
|
||||
TaskGoToCoordAnyMeans(targ, GetEntityCoords(PlayerPedId()), 1.0, 0, 0, 0, 0)
|
||||
until #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(targ)) < 2.0 or sell == false or inZone
|
||||
|
||||
if not sell then return end
|
||||
|
||||
TaskTurnPedToFaceEntity(targ, PlayerPedId(), -1)
|
||||
ps.hideText()
|
||||
Bridge.HelpText.HideHelpText()
|
||||
CreateThread(function()
|
||||
Wait(45000)
|
||||
walkAway(targ)
|
||||
@@ -65,14 +92,17 @@ local function findPed()
|
||||
end
|
||||
|
||||
local function checkItems()
|
||||
local count = 0
|
||||
local has = false
|
||||
for k, v in pairs (GlobalState.DrugNames) do
|
||||
if ps.hasItem(v) then
|
||||
count = count + 1
|
||||
if Bridge.Inventory.HasItem(v) then
|
||||
has = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if count == 0 then ps.notify(ps.lang('Cornerselling.nodrugs', 'error')) return false end
|
||||
if not has then
|
||||
Bridge.Notify.SendNotify(Bridge.Language.Locale('Cornerselling.nodrugs', 'error'))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -89,10 +119,10 @@ local function Cornersell()
|
||||
return
|
||||
end
|
||||
|
||||
ps.drawText(ps.lang('Cornerselling.searching'))
|
||||
Bridge.HelpText.ShowHelpText(Bridge.Language.Locale('Cornerselling.searching'))
|
||||
|
||||
local targ = findPed()
|
||||
local data = ps.callback('md-drugs:server:cornerselling:getAvailableDrugs', targ)
|
||||
local data = Bridge.Callback.Trigger('md-drugs:server:cornerselling:getAvailableDrugs', NetworkGetNetworkIdFromEntity(targ))
|
||||
if data == false then
|
||||
sell = false
|
||||
return
|
||||
@@ -102,13 +132,13 @@ local function Cornersell()
|
||||
TaskGoStraightToCoord(targ, -1858.232910, -1242.395630, 8.60510, 100.0, -1, 0.0, 0.0)
|
||||
SetPedMoveRateOverride(targ, 10.0)
|
||||
local got = false
|
||||
ps.entityTarget(targ, {
|
||||
Bridge.Target.AddLocalEntity(targ, {
|
||||
{
|
||||
label = ps.lang('Cornerselling.targetTakeBack'),
|
||||
label = Bridge.Language.Locale('Cornerselling.targetTakeBack'),
|
||||
icon ="fa-solid fa-money-bill",
|
||||
action = function()
|
||||
got = true
|
||||
TriggerServerEvent('md-drugs:server:getBackRobbed')
|
||||
TriggerServerEvent('md-drugs:server:getBackRobbed', NetworkGetNetworkIdFromEntity(targ))
|
||||
Cornersell()
|
||||
end,
|
||||
canInteract = function()
|
||||
@@ -116,14 +146,15 @@ local function Cornersell()
|
||||
return true
|
||||
end
|
||||
end,
|
||||
}}, nil)
|
||||
}
|
||||
})
|
||||
else
|
||||
ps.requestAnim("rcmme_tracey1")
|
||||
Bridge.Anim.RequestDict("rcmme_tracey1")
|
||||
TaskStartScenarioInPlace(targ, "WORLD_HUMAN_STAND_IMPATIENT_UPRIGHT", 0, false)
|
||||
FreezeEntityPosition(targ, true)
|
||||
ps.entityTarget(targ, {
|
||||
Bridge.Target.AddLocalEntity(targ, {
|
||||
{
|
||||
label = string.format(ps.lang('Cornerselling.targetSell'), data.amount, ps.getLabel(data.item), data.price),
|
||||
label = Bridge.Language.Locale('Cornerselling.targetSell', data.amount, Bridge.Inventory.GetItemInfo(data.item).label, data.price),
|
||||
icon ="fa-solid fa-money-bill",
|
||||
action = function()
|
||||
sellDrug(data.item, data.amount, data.price, targ)
|
||||
@@ -136,7 +167,7 @@ local function Cornersell()
|
||||
end,
|
||||
},
|
||||
{
|
||||
label = ps.lang('Cornerselling.targetDeny'),
|
||||
label = Bridge.Language.Locale('Cornerselling.targetDeny'),
|
||||
icon = "fa-solid fa-person-harassing",
|
||||
action = function()
|
||||
deny(targ)
|
||||
@@ -156,11 +187,11 @@ end
|
||||
RegisterNetEvent('md-drugs:client:cornerselling', function()
|
||||
if sell then
|
||||
sell = false
|
||||
ps.hideText()
|
||||
ps.notify(ps.lang('Cornerselling.stopped'), 'error')
|
||||
Bridge.HelpText.HideHelpText()
|
||||
Bridge.Notify.SendNotify(Bridge.Language.Locale('Cornerselling.stopped'), 'error')
|
||||
else
|
||||
sell = true
|
||||
ps.notify(ps.lang('Cornerselling.start'), 'success')
|
||||
Bridge.Notify.SendNotify(Bridge.Language.Locale('Cornerselling.start'), 'success')
|
||||
Cornersell()
|
||||
end
|
||||
end)
|
||||
@@ -170,4 +201,4 @@ CreateThread(function()
|
||||
local box = ps.zones.box({ coords = v.loc, size = vec3(v.width, v.length, v.height), rotation = 180.0, debug = false,
|
||||
onEnter = function() inZone = true end, onExit = function() inZone = false end})
|
||||
end
|
||||
end)
|
||||
end)
|
||||
Reference in new issue
Block a user