Skip to content

Commit

Permalink
feat(client) blip + ped spawner
Browse files Browse the repository at this point in the history
  • Loading branch information
NietThijmen committed Mar 31, 2023
1 parent 7b2c61f commit abc9d9f
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 34 deletions.
27 changes: 27 additions & 0 deletions client/blip.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local blip = nil

function GenerateBlip(data)
blip = AddBlipForCoord(data.Coords.x, data.Coords.y, data.Coords.z)
SetBlipSprite(blip, data.SpriteId)
SetBlipDisplay(blip, 4)
SetBlipScale(blip, data.Scale)
SetBlipColour(blip, data.Color)
SetBlipAsShortRange(blip, data.ShortRange)
SetBlipAlpha(blip, data.Alpha)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(data.Name)
EndTextCommandSetBlipName(blip)
end

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
if blip ~= nil then
RemoveBlip(blip)
end
end
end)

CreateThread(function()
if not Config.blip.enabled then return end
GenerateBlip(Config.blip)
end)
29 changes: 29 additions & 0 deletions client/ped.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CreateThread(function()
if not Config.ped.enabled then return end

RequestModel(joaat(Config.ped.model))
while not HasModelLoaded(joaat(Config.ped.model)) do
Wait(100)
end

local ped = CreatePed(4, joaat(Config.ped.model), Config.ped.coords, 0.0, false, false)
SetBlockingOfNonTemporaryEvents(ped, true)
SetPedDiesWhenInjured(ped, false)
SetPedCanPlayAmbientAnims(ped, true)
SetPedCanRagdollFromPlayerImpact(ped, false)
SetEntityInvincible(ped, true)
FreezeEntityPosition(ped, true)
SetEntityHeading(ped, Config.ped.coords.w)

-- Change to your target, ox_target should work because of the compatibility layer
exports['qb-target']:AddTargetEntity(ped, {
options = {
{
event = "mtc-cityhall:client:open",
icon = "fas fa-id-card",
label = Config.ped.label,
}
},
distance = 2.5
})
end)
77 changes: 43 additions & 34 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,52 @@ QBCore = exports['qb-core']:GetCoreObject()

Config = {}

-- Jobs for hire
Config.jobs = {
{
job = "police",
label = "LSPD",
salary = 100,
},
{
job = 'ambulance',
label = "EMS",
salary = -1,
}
-- Ped spawner
Config.ped = {
enabled = true,
model = "a_m_m_indian_01",
coords = vector4(-266.88833618164, -961.62231445313, 30.227128982544, 210.22946166992),
label = "Open cityhall"
}

-- Items for purchase
Config.items = {
{
item = "id_card",
label = "ID Card",
price = 100,
},
{
item = "driver_license",
label = "Driver License",
price = 100,
}
Config.blip = {
enabled = true,
Name = "Cityhall",
SpriteId = 487,
Color = 2,
Scale = 1.3,
ShortRange = true,
Alpha = 255,
Coords = vector3(-266.88833618164, -961.62231445313, 31.227128982544)
}

-- Jobs for hire
Config.jobs = {{
job = "police",
label = "LSPD",
salary = 100
}, {
job = 'ambulance',
label = "EMS",
salary = -1
}}

-- Items for purchase
Config.items = {{
item = "id_card",
label = "ID Card",
price = 100
}, {
item = "driver_license",
label = "Driver License",
price = 100
}}

-- Items shown in the information tab
Config.licenseItems = {
{
item = 'id_card',
label = 'ID Card',
},
{
item = 'driver_license',
label = 'Driver License',
}
}
Config.licenseItems = {{
item = 'id_card',
label = 'ID Card'
}, {
item = 'driver_license',
label = 'Driver License'
}}
2 changes: 2 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ client_scripts {
'client/nui.lua',
'client/callbacks.lua',
'client/client.lua',
'client/ped.lua',
'client/blip.lua'
}

server_scripts {
Expand Down

0 comments on commit abc9d9f

Please sign in to comment.