Files
md-drugs/client/functions.lua
T

384 lines
12 KiB
Lua
Raw Normal View History

2024-05-02 18:34:14 -07:00
local minigametype = Config.minigametype
local dispatch = Config.Dispatch
2024-10-23 17:44:46 -07:00
function loadParticle(dict)
if not HasNamedPtfxAssetLoaded(dict) then
RequestNamedPtfxAsset(dict)
end
while not HasNamedPtfxAssetLoaded(dict) do
Wait(0)
end
SetPtfxAssetNextCall(dict)
end
function LoadModel(hash)
2024-10-28 14:11:49 -07:00
RequestModel(hash)
while not HasModelLoaded(hash) do
Wait(0)
end
end
2024-10-23 17:44:46 -07:00
function minigame()
2024-10-02 01:00:46 -07:00
local time = 0
local game = Config.Minigames
if minigametype == 'ps_circle' then
local check
2024-10-02 01:00:46 -07:00
exports['ps-ui']:Circle(function(success)
check = success
end, game['ps_circle'].amount, game['ps_circle'].speed)
return check
elseif minigametype == 'ps_maze' then
local check
exports['ps-ui']:Maze(function(success)
check = success
end, game['ps_maze'].timelimit)
2024-12-16 03:34:20 -08:00
repeat Wait(10) until check ~= nil
2024-10-02 01:00:46 -07:00
return check
elseif minigametype == 'ps_scrambler' then
local check
exports['ps-ui']:Scrambler(function(success)
check = success
end, game['ps_scrambler'].type, game['ps_scrambler'].time, game['ps_scrambler'].mirrored)
2024-12-16 03:34:20 -08:00
repeat Wait(10) until check ~= nil
2024-10-02 01:00:46 -07:00
return check
elseif minigametype == 'ps_var' then
local check
exports['ps-ui']:VarHack(function(success)
check = success
end, game['ps_var'].numBlocks, game['ps_var'].time)
2024-12-16 03:34:20 -08:00
repeat Wait(10) until check ~= nil
2024-10-02 01:00:46 -07:00
return check
elseif minigametype == 'ps_thermite' then
local check
exports['ps-ui']:Thermite(function(success)
check = success
end, game['ps_thermite'].time, game['ps_thermite'].gridsize, game['ps_thermite'].incorrect)
2024-12-16 03:34:20 -08:00
repeat Wait(10) until check ~= nil
2024-10-02 01:00:46 -07:00
return check
2024-05-02 18:34:14 -07:00
elseif minigametype == 'ox' then
local success = lib.skillCheck(game['ox'], {'1', '2', '3', '4'})
2024-05-02 18:34:14 -07:00
return success
2024-10-02 01:00:46 -07:00
elseif minigametype == 'blcirprog' then
local success = exports.bl_ui:CircleProgress(game['blcirprog'].amount, game['blcirprog'].speed)
return success
elseif minigametype == 'blprog' then
local success = exports.bl_ui:Progress(game['blprog'].amount, game['blprog'].speed)
return success
elseif minigametype == 'blkeyspam' then
local success = exports.bl_ui:KeySpam(game['blkeyspam'].amount, game['blprog'].difficulty)
return success
elseif minigametype == 'blkeycircle' then
local success = exports.bl_ui:KeyCircle(game['blkeycircle'].amount, game['blkeycircle'].difficulty, game['blkeycircle'].keynumbers)
return success
elseif minigametype == 'blnumberslide' then
local success = exports.bl_ui:NumberSlide(game['blnumberslide'].amount, game['blnumberslide'].difficulty, game['blnumberslide'].keynumbers)
return success
elseif minigametype == 'blrapidlines' then
local success = exports.bl_ui:RapidLines(game['blrapidlines'].amount, game['blrapidlines'].difficulty, game['blrapidlines'].numberofline)
return success
elseif minigametype == 'blcircleshake' then
local success = exports.bl_ui:CircleShake(game['blcircleshake'].amount, game['blcircleshake'].difficulty, game['blcircleshake'].stages)
return success
elseif minigametype == 'glpath' then
2024-10-02 01:00:46 -07:00
local settings = {gridSize = game['glpath'].gridSize, lives = game['glpath'].lives, timeLimit = game['glpath'].timelimit}
local successes = false
exports["glow_minigames"]:StartMinigame(function(success)
if success then successes = true else successes = false end
end, "path", settings)
repeat
Wait(1000)
time = time + 1
until successes or time == 100
if successes then return true end
elseif minigametype == 'glspot' then
2024-10-02 01:00:46 -07:00
local settings = {gridSize = game['glspot'].gridSize, timeLimit = game['glspot'].gridSize, charSet = game['glspot'].charSet, required = game['glspot'].required}
local successes = false
exports["glow_minigames"]:StartMinigame(function(success)
2024-10-02 01:00:46 -07:00
if success then successes = true else successes = false end
end, "spot", settings)
repeat
Wait(1000)
time = time + 1
until successes or time == 100
elseif minigametype == 'glmath' then
2024-10-02 01:00:46 -07:00
local settings = {timeLimit = game['glmath'].timeLimit}
local successes = false
exports["glow_minigames"]:StartMinigame(function(success)
2024-10-02 01:00:46 -07:00
if success then successes = true else successes = false end
end, "math", settings)
repeat
Wait(1000)
time = time + 1
until successes or time == 100
elseif minigametype == 'none' then
return true
2024-11-04 16:46:27 -08:00
else
print"^1 SCRIPT ERROR: Md-Drugs set your minigame with one of the options!"
2024-10-02 01:00:46 -07:00
end
2025-07-16 01:48:56 -07:00
end
2024-07-11 17:39:58 -07:00
2024-10-23 16:04:09 -07:00
function GetRep()
2025-07-01 03:09:46 -07:00
local rep = ps.callback('md-drugs:server:GetRep')
2024-10-23 16:04:09 -07:00
return rep
end
function sorter(sorting, value)
2024-10-28 14:11:49 -07:00
table.sort(sorting, function(a, b) return a[value] < b[value] end)
2024-10-23 16:04:09 -07:00
end
function makeMenu(name, rep)
local menu = {}
2025-07-01 03:09:46 -07:00
local data = ps.callback('md-drugs:server:menu', name)
for k, v in pairs (data.table) do
local allow = false
if rep == nil then
allow = true
else
if rep.dealerrep >= v.minrep then allow = true end
end
if allow then
menu[#menu + 1] = {
icon = GetImage(v.name),
description = '$'.. v.price,
title = GetLabel(v.name),
onSelect = function()
local settext = "Cost: $"..v.price
local dialog = exports.ox_lib:inputDialog(v.name .."!", {
{ type = 'select', label = "Payment Type", default = "cash", options = { { value = "cash"}, { value = "bank"},}},
{ type = 'number', label = "Amount to buy", description = settext, min = 0, max = v.amount, default = 1 },
})
if not dialog[1] then return end
TriggerServerEvent("md-drugs:server:purchaseGoods", dialog[2], dialog[1], v.name, v.price, data.table, k)
end,
}
end
end
sorter(menu, 'title')
lib.registerContext({id = data.id, title = data.title, options = menu})
end
2024-10-23 16:04:09 -07:00
2024-05-02 18:34:14 -07:00
function Email(sender, subject, message)
if Config.Phone == 'yflip' then
local receiver = GetPlayerServerId(PlayerId())
local insertId, received = exports["yflip-phone"]:SendMail({
title = subject,
sender = sender,
senderDisplayName = sender,
content = message,
}, 'phoneNumber', receiver)
2024-05-02 20:00:54 -07:00
elseif Config.Phone == 'qs' then
TriggerServerEvent('qs-smartphone:server:sendNewMail', {
sender = sender,
subject = subject,
message = message,
button = {}
})
2024-05-02 18:34:14 -07:00
else
TriggerServerEvent('qb-phone:server:sendNewMail', {
sender = sender,
subject = subject,
message = message,
})
end
2024-11-04 16:46:27 -08:00
end
2024-05-02 18:34:14 -07:00
function PoliceCall(chance)
local math = math.random(1,100)
if math <= chance then
if dispatch == 'ps' then
exports['ps-dispatch']:DrugSale()
elseif dispatch == 'cd' then
local data = exports['cd_dispatch']:GetPlayerInfo()
TriggerServerEvent('cd_dispatch:AddNotification', {
job_table = {'police', },
coords = data.coords,
title = '420-69 Drug Sale',
message = 'A '..data.sex..' robbing a store at '..data.street,
flash = 0,
unique_id = data.unique_id,
sound = 1,
2024-10-28 14:11:49 -07:00
blip = { sprite = 431, scale = 1.2, colour = 3, flashes = false, text = '420-69 Drug Sale', time = 5, radius = 0,}
2024-05-02 18:34:14 -07:00
})
elseif dispatch == 'core' then
exports['core_dispatch']:addCall("420-69", "Drugs Are Being Sold", {
{icon="fa-ruler", info="4.5 MILES"},
}, {GetEntityCoords(PlayerPedId())}, "police", 3000, 11, 5 )
elseif dispatch == 'aty' then
exports["aty_dispatch"]:SendDispatch('Drug Sale', '420-69', 40, {'police'})
2024-06-20 18:46:51 -07:00
elseif dispatch == 'qs' then
exports['qs-dispatch']:DrugSale()
2024-11-26 17:26:46 -08:00
elseif dispatch == 'codem' then
local Data = {
type = 'Drug Sale',
header = 'Someone Selling Drugs',
text = 'Hurry up and save the community',
code = '420-69',
}
exports['codem-dispatch']:CustomDispatch(Data)
2024-05-02 18:34:14 -07:00
else
print('Congrats, You Choose 0 of the options :)')
end
else
2024-11-26 17:26:46 -08:00
return
2024-05-02 18:34:14 -07:00
end
end
function GetCops(number)
2024-05-12 00:22:09 -07:00
if number == 0 then return true end
2025-07-01 03:09:46 -07:00
local amount = ps.callback('md-drugs:server:GetCoppers')
2025-07-17 02:06:17 -05:00
if amount >= number then return true else ps.notify('You Need '.. number - amount .. ' More Cops To Do This', 'error') end
2024-05-02 18:34:14 -07:00
end
2024-06-13 22:12:37 -07:00
2024-07-11 17:39:58 -07:00
function Freeze(entity, toggle, head)
SetEntityInvincible(entity, toggle)
SetEntityAsMissionEntity(entity, toggle, toggle)
FreezeEntityPosition(entity, toggle)
SetEntityHeading(entity, head)
SetBlockingOfNonTemporaryEvents(entity, toggle)
end
function tele(coords)
DoScreenFadeOut(500)
Wait(1000)
SetEntityCoords(PlayerPedId(),coords.x, coords.y, coords.z)
Wait(1000)
DoScreenFadeIn(500)
end
local created = false
local heading = 180.0
function StartRay()
local run = true
local pedcoord = GetEntityCoords(PlayerPedId())
2024-11-12 17:08:02 -08:00
lib.requestModel('v_ret_ml_tablea', 30000)
local table = CreateObject('v_ret_ml_tablea', pedcoord.x, pedcoord.y, pedcoord.z+1, heading, false, false)
repeat
local hit, entityHit, endCoords, surfaceNormal, matHash = lib.raycast.cam(511, 4, 10)
if not created then
created = true
lib.showTextUI([[[E] To Place
[DEL] To Cancel
[<-] To Move Left
[->] To Move Right]])
else
SetEntityCoords(table, endCoords.x, endCoords.y, endCoords.z+1)
SetEntityHeading(table, heading)
SetEntityCollision(table, false, false)
SetEntityAlpha(table, 100)
end
if IsControlPressed(0, 174) then
heading = heading - 2
end
if IsControlPressed(0, 175) then
heading = heading + 2
end
if IsControlPressed(0, 38) then
lib.hideTextUI()
run = false
DeleteObject(table)
created = false
return endCoords, heading
end
if IsControlPressed(0, 178) then
lib.hideTextUI()
run = false
created = false
DeleteObject(table)
return nil, nil
end
Wait(0)
until run == false
end
function StartRay2()
local run = true
local pedcoord = GetEntityCoords(PlayerPedId())
2024-11-26 15:45:17 -08:00
lib.requestModel('bkr_prop_coke_press_01aa', 30000)
local table = CreateObject('bkr_prop_coke_press_01aa', pedcoord.x, pedcoord.y, pedcoord.z+1, heading, false, false)
repeat
local hit, entityHit, endCoords, surfaceNormal, matHash = lib.raycast.cam(511, 4, 10)
if not created then
created = true
lib.showTextUI([[[E] To Place
[DEL] To Cancel
[<-] To Move Left
[->] To Move Right]])
else
SetEntityCoords(table, endCoords.x, endCoords.y, endCoords.z+1)
SetEntityHeading(table, heading)
SetEntityCollision(table, false, false)
SetEntityAlpha(table, 100)
end
if IsControlPressed(0, 174) then
heading = heading - 2
end
if IsControlPressed(0, 175) then
heading = heading + 2
end
if IsControlPressed(0, 38) then
lib.hideTextUI()
run = false
DeleteObject(table)
created = false
return endCoords, heading
end
if IsControlPressed(0, 178) then
lib.hideTextUI()
run = false
created = false
DeleteObject(table)
return nil, nil
end
Wait(0)
until run == false
end
2024-11-11 20:22:48 -08:00
CreateThread(function()
2025-01-13 22:44:37 -08:00
LoadModel('prop_plant_01b')
LoadModel('prop_plant_01a')
LoadModel('prop_cactus_03')
LoadModel('prop_weed_01')
TriggerEvent('weed:init')
2024-11-11 20:22:48 -08:00
TriggerEvent('heroin:init')
TriggerEvent('coke:init')
TriggerEvent('Mescaline:init')
2025-07-15 02:21:34 -07:00
ps.requestModel(GetHashKey('mushroom'))
2024-11-11 20:22:48 -08:00
TriggerEvent('shrooms:init')
end)
2025-07-01 03:09:46 -07:00
ps.registerCallback('md-drugs:client:uncuff', function(data)
if not progressbar(data, 4000, 'uncuff') then return end
return true
end)
RegisterCommand('DrugRep', function()
if not Config.TierSystem then return end
2025-07-01 03:09:46 -07:00
local rep = ps.callback('md-drugs:server:GetRep', false)
lib.registerContext({
id = 'DrugRep',
title = 'Drug Reputation',
options = {
{icon = "fa-solid fa-face-flushed", title = 'Cocaine: '..rep.coke},
{icon = "fa-solid fa-syringe", title = 'Heroin: '..rep.heroin},
{icon = "fa-solid fa-vial", title = 'LSD: '..rep.lsd},
{icon = "fa-solid fa-plug", title = 'Dealer: '..rep.dealerrep},
{icon = "fa-solid fa-money-bill", title = 'Corner Selling: ' .. rep.cornerselling.rep, description = 'Rank: ' .. rep.cornerselling.label }
}
})
lib.showContext('DrugRep')
2024-12-12 15:26:48 -08:00
end, false)
2025-06-30 23:24:57 -07:00
function handleGang(gang)
if gang == nil or gang == '' or gang == "" then return true end
if ps.getGangName() == gang or gang == 1 then return true end
return false
end