- 80%
This commit is contained in:
1 parent
ebc47ba5d7
commit
66934fd68a
16 files changed
+169
-124
No files matched your search
@@ -38,7 +38,7 @@ local stores = {
|
||||
},
|
||||
}
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetMerchant', function(source)
|
||||
Bridge.Callback.Register('md-drugs:server:GetMerchant', function(source)
|
||||
return {loc = loc, items = stores.travel}
|
||||
end)
|
||||
|
||||
@@ -46,7 +46,7 @@ end)
|
||||
|
||||
RegisterServerEvent("md-drugs:server:purchaseGoods", function(item)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, loc, 10) then
|
||||
if not checkDistance(src, loc, 10) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
@@ -54,8 +54,8 @@ RegisterServerEvent("md-drugs:server:purchaseGoods", function(item)
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.invalidItem'), "error")
|
||||
return
|
||||
end
|
||||
if ps.removeMoney(src, 'cash', stores.travel[item]) then
|
||||
ps.addItem(src, item, 1)
|
||||
if Bridge.Framework.RemoveAccountBalance(src, 'cash', stores.travel[item]) then
|
||||
Bridge.Inventory.AddItem(src, item, 1)
|
||||
else
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
end
|
||||
|
||||
+45
-21
@@ -1,11 +1,12 @@
|
||||
Locations = Locations or {}
|
||||
local prices = {
|
||||
payfortruck = 500,
|
||||
hotchance = 30,
|
||||
itemChance = 20,
|
||||
}
|
||||
local onRoute = {}
|
||||
|
||||
local oxyLocs = {
|
||||
local vehicles = {}
|
||||
Locations.Oxy = {
|
||||
OxyPayForTruck = {
|
||||
{loc = vector3(1437.64, -1491.91, 63.62), truckSpawn = vector4(1450.87, -1482.13, 63.22, 69.95), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
@@ -24,21 +25,25 @@ local oxyLocs = {
|
||||
vector4(474.88, 2609.56, 44.48, 357.0),
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetOxyLocs', function(source)
|
||||
return oxyLocs
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:payfortruck', function(source)
|
||||
Bridge.Callback.Register('md-drugs:server:payfortruck', function(source, loc)
|
||||
local src = source
|
||||
if ps.removeMoney(src, 'cash', prices.payfortruck) or ps.removeMoney(src, 'bank', prices.payfortruck) then
|
||||
onRoute[src] = true
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('oxy.paid', prices.payfortruck), "success")
|
||||
return true
|
||||
else
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
if timeOut(src, 'md-drugs:server:payfortruck') then return false end
|
||||
if not checkDistance(src, Locations.Oxy.OxyPayForTruck[loc].loc, 2.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return false
|
||||
end
|
||||
if not Bridge.Framework.RemoveAccountBalance(src, 'cash', prices.payfortruck) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('oxy.notEnoughCash'), "error")
|
||||
return false
|
||||
end
|
||||
onRoute[src] = {
|
||||
amount = math.random(1, #Locations.Oxy.oxylocations),
|
||||
current = 0
|
||||
}
|
||||
return true
|
||||
end)
|
||||
|
||||
|
||||
@@ -50,11 +55,22 @@ RegisterServerEvent('md-drugs:server:giveoxybox', function()
|
||||
return
|
||||
end
|
||||
|
||||
if not ps.checkDistance(src, oxyLocs.oxylocations[onRoute[src]], 3.5) then
|
||||
if not checkDistance(src, Locations.Oxy.oxylocations[onRoute[src].current], 3.5) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
local vehicles = vehicles[src]
|
||||
if not vehicles or GetEntityModel(vehicles) ~= GetHashKey("burrito3") then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('oxy.notInVeh'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
if #(GetEntityCoords(vehicles) - GetEntityCoords(GetPlayerPed(src))) > 35.0 then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('oxy.notNearVeh'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
local cash = math.random(50, 200)
|
||||
local itemchance = math.random(1,100)
|
||||
local itemList = {
|
||||
@@ -62,21 +78,29 @@ RegisterServerEvent('md-drugs:server:giveoxybox', function()
|
||||
{item = 'houselockpick', amount = 1},
|
||||
}
|
||||
local item = itemList[math.random(1, #itemList)]
|
||||
ps.addMoney(src,"cash", cash)
|
||||
Bridge.Framework.AddAccountBalance(src, 'cash', cash)
|
||||
if itemchance <= prices.itemChance then
|
||||
ps.addItem(src, item.item, item.amount)
|
||||
Bridge.Framework.AddItem(src, item.item, item.amount)
|
||||
end
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:getRoute', function(source)
|
||||
Bridge.Callback.Register('md-drugs:server:getRoute', function(source)
|
||||
if not onRoute[source] then return false end
|
||||
local giveLocation = math.random(1, 10)
|
||||
if giveLocation >= 8 then
|
||||
if onRoute[source].amount == 0 then
|
||||
onRoute[source] = nil
|
||||
vehicles[source] = nil
|
||||
return false
|
||||
else
|
||||
onRoute[source] = math.random(1, #oxyLocs.oxylocations)
|
||||
return oxyLocs.oxylocations[onRoute[source]]
|
||||
end
|
||||
onRoute[source].current = math.random(1, #Locations.Oxy.oxylocations)
|
||||
onRoute[source].amount = onRoute[source].amount - 1
|
||||
return onRoute[source].current
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:startOxyRun', function(netId)
|
||||
local src = source
|
||||
if not onRoute[src] then return end
|
||||
local veh = NetworkGetEntityFromNetworkId(netId)
|
||||
if not veh or GetEntityModel(veh) ~= GetHashKey("burrito3") then return end
|
||||
vehicles[src] = veh
|
||||
|
||||
end)
|
||||
+39
-22
@@ -1,40 +1,56 @@
|
||||
local pharmaLocations = {
|
||||
Locations = Locations or {}
|
||||
|
||||
Locations.Pharma = {
|
||||
FillPrescription = { -- where to fill out your prescription
|
||||
{loc = vector3(2855.62, 4446.73, 48.53), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
}
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetPharmaLocs', function()
|
||||
return pharmaLocations
|
||||
end)
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
|
||||
local function GetJob(source)
|
||||
local src = source
|
||||
return ps.getJobType(src) == 'ems'
|
||||
local jobName = Bridge.Framework.GetPlayerJob(src)
|
||||
return jobName == 'ambulance'
|
||||
end
|
||||
|
||||
ps.createUseable('prescription_pad', function(source, item)
|
||||
local function getNearby(src, distance)
|
||||
local players = Bridge.Framework.GetPlayers()
|
||||
local nearPlayers = {}
|
||||
for index, sources in pairs(players) do
|
||||
--if sources ~= src then
|
||||
local target = GetEntityCoords(GetPlayerPed(sources))
|
||||
local you = GetEntityCoords(GetPlayerPed(src))
|
||||
local distanceBetween = #(you - target)
|
||||
if distanceBetween <= distance then
|
||||
table.insert(nearPlayers, {label = Bridge.Framework.GetPlayerName(sources), value = sources})
|
||||
end
|
||||
--end
|
||||
end
|
||||
return nearPlayers
|
||||
end
|
||||
|
||||
Bridge.Framework.RegisterUsableItem('prescription_pad', function(source, item)
|
||||
local src = source
|
||||
local near = {}
|
||||
if GetJob(src) then
|
||||
near = ps.getNearbyPlayers(src, 5.0)
|
||||
near = getNearby(src, 5.0)
|
||||
local options = {
|
||||
{label = ps.getItemLabel('vicodin_prescription'), value = 'vicodin_prescription'},
|
||||
{label = ps.getItemLabel('adderal_prescription'), value = 'adderal_prescription'},
|
||||
{label = ps.getItemLabel('morphine_prescription'), value = 'morphine_prescription'},
|
||||
{label = ps.getItemLabel('xanax_prescription'), value = 'xanax_prescription'}
|
||||
{label = Bridge.Inventory.GetItemInfo('vicodin_prescription').label, value = 'vicodin_prescription'},
|
||||
{label = Bridge.Inventory.GetItemInfo('adderal_prescription').label, value = 'adderal_prescription'},
|
||||
{label = Bridge.Inventory.GetItemInfo('morphine_prescription').label, value = 'morphine_prescription'},
|
||||
{label = Bridge.Inventory.GetItemInfo('xanax_prescription').label, value = 'xanax_prescription'}
|
||||
}
|
||||
local data = ps.callback('md-drugs:client:prescriptionpad', src, near, options)
|
||||
local data = Bridge.Callback.Trigger('md-drugs:client:prescriptionpad', src, near, options)
|
||||
if not data then return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('pharma.canceled'), "error") end
|
||||
ps.addItem(ps.getSource(data.who), data.what, 1)
|
||||
Bridge.Framework.AddItem(data.who, data.what, 1)
|
||||
end
|
||||
end)
|
||||
|
||||
local pharmabottle = {'vicodinbottle', 'adderalbottle','morphinebottle','xanaxbottle'}
|
||||
for m, d in pairs (pharmabottle) do
|
||||
ps.createUseable(d, function(source, item)
|
||||
Bridge.Framework.RegisterUsableItem(d, function(source, item)
|
||||
local src = source
|
||||
local check = ps.callback("md-drugs:client:unbottle", src)
|
||||
local check = Bridge.Callback.Trigger("md-drugs:client:unbottle", src)
|
||||
if check then
|
||||
local get = {
|
||||
['vicodinbottle'] = 'vicodin',
|
||||
@@ -44,8 +60,8 @@ for m, d in pairs (pharmabottle) do
|
||||
}
|
||||
for k, v in pairs (get) do
|
||||
if d == k then
|
||||
if ps.removeItem(src, d, 1) then
|
||||
ps.addItem(src, v, math.random(10,30))
|
||||
if Bridge.Framework.RemoveItem(src, d, 1) then
|
||||
Bridge.Framework.AddItem(src, v, math.random(10,30))
|
||||
Bridge.Notify.SendNotify(src,Bridge.Language.Locale('pharma.unbottle'), "success")
|
||||
end
|
||||
end
|
||||
@@ -56,8 +72,9 @@ end
|
||||
|
||||
RegisterServerEvent('md-drugs:server:fillprescription', function(num)
|
||||
local src = source
|
||||
|
||||
if timeOut(src, 'md-drugs:server:fillprescription') then return end
|
||||
if not ps.checkDistance(src, pharmaLocations.FillPrescription[num].loc, 3.5) then
|
||||
if not checkDistance(src, Locations.Pharma.FillPrescription[num].loc, 3.5) then
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
end
|
||||
local pres = {
|
||||
@@ -67,9 +84,9 @@ RegisterServerEvent('md-drugs:server:fillprescription', function(num)
|
||||
xanax_prescription = 'xanaxbottle'
|
||||
}
|
||||
for k, v in pairs (pres) do
|
||||
if ps.hasItem(src, k, 1) then
|
||||
ps.removeItem(src, k, 1)
|
||||
ps.addItem(src, v, 1)
|
||||
if Bridge.Framework.HasItem(src, k, 1) then
|
||||
Bridge.Framework.RemoveItem(src, k, 1)
|
||||
Bridge.Framework.AddItem(src, v, 1)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
@@ -123,7 +123,7 @@ local plantData = {
|
||||
GlobalState.CocaPlant = plants.cocaine
|
||||
end,
|
||||
itemGive = function(src)
|
||||
ps.addItem(src, 'coca_leaf', 1)
|
||||
Bridge.Inventory.AddItem(src, 'coca_leaf', 1)
|
||||
end,
|
||||
coolDown = function(loc)
|
||||
CreateThread(function()
|
||||
@@ -142,7 +142,7 @@ local plantData = {
|
||||
GlobalState.PoppyPlants = plants.heroin
|
||||
end,
|
||||
itemGive = function(src)
|
||||
ps.addItem(src, 'poppyresin', 1)
|
||||
Bridge.Inventory.AddItem(src, 'poppyresin', 1)
|
||||
end,
|
||||
coolDown = function(loc)
|
||||
CreateThread(function()
|
||||
@@ -161,7 +161,7 @@ local plantData = {
|
||||
GlobalState.Mescaline = plants.mescaline
|
||||
end,
|
||||
itemGive = function(src)
|
||||
ps.addItem(src, 'cactusbulb', 1)
|
||||
Bridge.Inventory.AddItem(src, 'cactusbulb', 1)
|
||||
end,
|
||||
coolDown = function(loc)
|
||||
CreateThread(function()
|
||||
@@ -180,7 +180,7 @@ local plantData = {
|
||||
GlobalState.shrooms = plants.shrooms
|
||||
end,
|
||||
itemGive = function(src)
|
||||
ps.addItem(src, 'shrooms', 1)
|
||||
Bridge.Inventory.AddItem(src, 'shrooms', 1)
|
||||
end,
|
||||
coolDown = function(loc)
|
||||
CreateThread(function()
|
||||
@@ -199,7 +199,7 @@ local plantData = {
|
||||
GlobalState.WeedPlant = plants.weed
|
||||
end,
|
||||
itemGive = function(src)
|
||||
ps.addItem(src, 'wetcannabis', 1)
|
||||
Bridge.Inventory.AddItem(src, 'wetcannabis', 1)
|
||||
end,
|
||||
coolDown = function(loc)
|
||||
CreateThread(function()
|
||||
@@ -219,7 +219,7 @@ for k, v in pairs (plantData) do
|
||||
RegisterNetEvent(v.label ..":pickupCane", function(loc)
|
||||
local src = source
|
||||
if timeOut(src, v.label .. ":pickupCane") then return end
|
||||
if ps.checkDistance(src, v.plants[loc].location, 5.0) then
|
||||
if checkDistance(src, v.plants[loc].location, 5.0) then
|
||||
if not v.plants[loc].taken then
|
||||
v.plants[loc].taken = true
|
||||
v.globalState()
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
|
||||
ps.createUseable('shrooms', function(source, item)
|
||||
Bridge.Framework.RegisterUsableItem('shrooms', function(source, item)
|
||||
local src = source
|
||||
if not ps.callback("md-drugs:client:shrooms", src) then
|
||||
if not Bridge.Callback.Trigger("md-drugs:client:shrooms", src) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('shrooms.cancel'), "error")
|
||||
return
|
||||
end
|
||||
ps.removeItem(src, 'shrooms', 1)
|
||||
Bridge.Inventory.RemoveItem(src, 'shrooms', 1)
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('shrooms.took'), 'success')
|
||||
end)
|
||||
|
||||
Reference in new issue
Block a user