Skip to content

Commit

Permalink
Second round of conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage committed Mar 31, 2022
1 parent f5bb0dd commit ee64ceb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
9 changes: 5 additions & 4 deletions client/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ end
local function SetWeaponSeries()
for k, v in pairs(Config.Items.items) do
if k < 6 then
Config.Items.items[k].info.serie = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))
Config.Items.items[k].info.serie = tostring(exports['qbr-core']:RandomInt(2) .. exports['qbr-core']:RandomStr(3) .. exports['qbr-core']:RandomInt(1) .. exports['qbr-core']:RandomStr(2) .. exports['qbr-core']:RandomInt(3) .. exports['qbr-core']:RandomStr(4))
end
end
end
Expand Down Expand Up @@ -211,15 +211,16 @@ CreateThread(function()
Citizen.InvokeNative(0x9CB1A1623062F402, StationBlip, v.label)
-- Citizen.ReturnResultAnyway()
end

for k,v in pairs(QBCore.Shared.Weapons) do
local sharedItems = exports['qbr-core']:GetItems()
local sharedWeapons = exports['qbr-core']:GetWeapons()
for k,v in pairs(sharedWeapons) do
local weaponName = v.name
local weaponLabel = v.label
local weaponHash = GetHashKey(v.name)
local weaponAmmo, weaponAmmoLabel = nil, 'unknown'
if v.ammotype then
weaponAmmo = v.ammotype:lower()
weaponAmmoLabel = QBCore.Shared.Items[weaponAmmo].label
weaponAmmoLabel = sharedItems[weaponAmmo].label
end

print(weaponHash, weaponName, weaponLabel, weaponAmmo, weaponAmmoLabel)
Expand Down
37 changes: 19 additions & 18 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local Casings = {}
local BloodDrops = {}
local FingerDrops = {}
local Objects = {}

local sharedItems = exports['qbr-core']:GetItems()

-- Functions
local function UpdateBlips()
Expand Down Expand Up @@ -107,7 +107,7 @@ local function DnaHash(s)
end

-- Commands
QBCore.Commands.Add("pobject", Lang:t("commands.place_object"), {{name = "type",help = Lang:t("info.poobject_object")}}, true, function(source, args)
exports['qbr-core']:AddCommand("pobject", Lang:t("commands.place_object"), {{name = "type",help = Lang:t("info.poobject_object")}}, true, function(source, args)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
local type = args[1]:lower()
Expand All @@ -130,7 +130,7 @@ QBCore.Commands.Add("pobject", Lang:t("commands.place_object"), {{name = "type",
end
end)

QBCore.Commands.Add("cuff", Lang:t("commands.cuff_player"), {}, false, function(source, args)
exports['qbr-core']:AddCommand("cuff", Lang:t("commands.cuff_player"), {}, false, function(source, args)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
Expand All @@ -140,18 +140,18 @@ QBCore.Commands.Add("cuff", Lang:t("commands.cuff_player"), {}, false, function(
end
end)

QBCore.Commands.Add("escort", Lang:t("commands.escort"), {}, false, function(source, args)
exports['qbr-core']:AddCommand("escort", Lang:t("commands.escort"), {}, false, function(source, args)
local src = source
TriggerClientEvent("police:client:EscortPlayer", src)
end)

QBCore.Commands.Add("callsign", Lang:t("commands.callsign"), {{name = "name", help = Lang:t('info.callsign_name')}}, false, function(source, args)
exports['qbr-core']:AddCommand("callsign", Lang:t("commands.callsign"), {{name = "name", help = Lang:t('info.callsign_name')}}, false, function(source, args)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
Player.Functions.SetMetaData("callsign", table.concat(args, " "))
end)

QBCore.Commands.Add("clearcasings", Lang:t("commands.clear_casign"), {}, false, function(source)
exports['qbr-core']:AddCommand("clearcasings", Lang:t("commands.clear_casign"), {}, false, function(source)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
Expand All @@ -161,7 +161,7 @@ QBCore.Commands.Add("clearcasings", Lang:t("commands.clear_casign"), {}, false,
end
end)

QBCore.Commands.Add("jail", Lang:t("commands.jail_player"), {{name = "id", help = Lang:t('info.player_id')}, {name = "time", help = Lang:t('info.jail_time')}}, true, function(source, args)
exports['qbr-core']:AddCommand("jail", Lang:t("commands.jail_player"), {{name = "id", help = Lang:t('info.player_id')}, {name = "time", help = Lang:t('info.jail_time')}}, true, function(source, args)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
Expand All @@ -177,7 +177,7 @@ QBCore.Commands.Add("jail", Lang:t("commands.jail_player"), {{name = "id", help
end
end)

QBCore.Commands.Add("unjail", Lang:t("commands.unjail_player"), {{name = "id", help = Lang:t('info.player_id')}}, true, function(source, args)
exports['qbr-core']:AddCommand("unjail", Lang:t("commands.unjail_player"), {{name = "id", help = Lang:t('info.player_id')}}, true, function(source, args)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
Expand All @@ -188,7 +188,7 @@ QBCore.Commands.Add("unjail", Lang:t("commands.unjail_player"), {{name = "id", h
end
end)

QBCore.Commands.Add("clearblood", Lang:t("commands.clearblood"), {}, false, function(source)
exports['qbr-core']:AddCommand("clearblood", Lang:t("commands.clearblood"), {}, false, function(source)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
Expand All @@ -198,7 +198,7 @@ QBCore.Commands.Add("clearblood", Lang:t("commands.clearblood"), {}, false, func
end
end)

QBCore.Commands.Add("seizecash", Lang:t("commands.seizecash"), {}, false, function(source)
exports['qbr-core']:AddCommand("seizecash", Lang:t("commands.seizecash"), {}, false, function(source)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
Expand All @@ -208,7 +208,7 @@ QBCore.Commands.Add("seizecash", Lang:t("commands.seizecash"), {}, false, functi
end
end)

QBCore.Commands.Add("sc", Lang:t("commands.softcuff"), {}, false, function(source)
exports['qbr-core']:AddCommand("sc", Lang:t("commands.softcuff"), {}, false, function(source)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
Expand All @@ -218,7 +218,7 @@ QBCore.Commands.Add("sc", Lang:t("commands.softcuff"), {}, false, function(sourc
end
end)

QBCore.Commands.Add("takedna", Lang:t("commands.takedna"), {{name = "id", help = Lang:t('info.player_id')}}, true, function(source, args)
exports['qbr-core']:AddCommand("takedna", Lang:t("commands.takedna"), {{name = "id", help = Lang:t('info.player_id')}}, true, function(source, args)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
local OtherPlayer = exports['qbr-core']:GetPlayer(tonumber(args[1]))
Expand All @@ -230,7 +230,7 @@ QBCore.Commands.Add("takedna", Lang:t("commands.takedna"), {{name = "id", help =
dnalabel = DnaHash(OtherPlayer.PlayerData.citizenid)
}
if Player.Functions.AddItem("evidence_satchel", 1, false, info) then
TriggerClientEvent("inventory:client:ItemBox", src, QBCore.Shared.Items["evidence_satchel"], "add")
TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add")
end
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("error.have_evidence_bag"), "error")
Expand Down Expand Up @@ -485,7 +485,7 @@ RegisterNetEvent('police:server:SeizeCash', function(playerId)
local info = { cash = moneyAmount }
SearchedPlayer.Functions.RemoveMoney("cash", moneyAmount, "police-cash-seized")
Player.Functions.AddItem("moneybag", 1, false, info)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["moneybag"], "add")
TriggerClientEvent('inventory:client:ItemBox', src, sharedItems["moneybag"], "add")
TriggerClientEvent('QBCore:Notify', SearchedPlayer.PlayerData.source, Lang:t("info.cash_confiscated"))
end
end)
Expand Down Expand Up @@ -554,7 +554,7 @@ RegisterNetEvent('evidence:server:AddBlooddropToInventory', function(bloodId, bl
local Player = exports['qbr-core']:GetPlayer(src)
if Player.Functions.RemoveItem("satchel", 1) then
if Player.Functions.AddItem("evidence_satchel", 1, false, bloodInfo) then
TriggerClientEvent("inventory:client:ItemBox", src, QBCore.Shared.Items["evidence_satchel"], "add")
TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add")
TriggerClientEvent("evidence:client:RemoveBlooddrop", -1, bloodId)
BloodDrops[bloodId] = nil
end
Expand All @@ -568,7 +568,7 @@ RegisterNetEvent('evidence:server:AddFingerprintToInventory', function(fingerId,
local Player = exports['qbr-core']:GetPlayer(src)
if Player.Functions.RemoveItem("satchel", 1) then
if Player.Functions.AddItem("evidence_satchel", 1, false, fingerInfo) then
TriggerClientEvent("inventory:client:ItemBox", src, QBCore.Shared.Items["evidence_satchel"], "add")
TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add")
TriggerClientEvent("evidence:client:RemoveFingerprint", -1, fingerId)
FingerDrops[fingerId] = nil
end
Expand All @@ -581,7 +581,8 @@ RegisterNetEvent('evidence:server:CreateCasing', function(weapon, coords)
local src = source
local Player = exports['qbr-core']:GetPlayer(src)
local casingId = CreateCasingId()
local weaponInfo = QBCore.Shared.Weapons[weapon]
local sharedWeapons = exports['qbr-core']:GetWeapons()
local weaponInfo = sharedWeapons[weapon]
local serieNumber = nil
if weaponInfo then
local weaponItem = Player.Functions.GetItemByName(weaponInfo["name"])
Expand Down Expand Up @@ -619,7 +620,7 @@ RegisterNetEvent('evidence:server:AddCasingToInventory', function(casingId, casi
local Player = exports['qbr-core']:GetPlayer(src)
if Player.Functions.RemoveItem("satchel", 1) then
if Player.Functions.AddItem("evidence_satchel", 1, false, casingInfo) then
TriggerClientEvent("inventory:client:ItemBox", src, QBCore.Shared.Items["evidence_satchel"], "add")
TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add")
TriggerClientEvent("evidence:client:RemoveCasing", -1, casingId)
Casings[casingId] = nil
end
Expand Down

0 comments on commit ee64ceb

Please sign in to comment.