1: Optimization: -- Radar While Driving
Code
Citizen.CreateThread(function()
while true do
Citizen.Wait(100)
local player = PlayerPedId()
local vehicle = GetVehiclePedIsIn(player, false)
local vehicleIsOn = GetIsVehicleEngineRunning(vehicle)
if IsPedInAnyVehicle(player, false) and vehicleIsOn then
DisplayRadar(true)
else
DisplayRadar(false)
end
end
end)
Alles anzeigen
2: Enable PVP
Code
Code kommt bei qb-spawn client.lua lines 155-156 underneath RegisterNUICallback('spawnplayer', function(data)
SetCanAttackFriendly(PlayerPedId(), true, false)
NetworkSetFriendlyFireOption(true)
3: Free optimization
4: Distance optimization
Code
Ersetze:
local playercoords = GetEntityCoords(PlayerPedId())
local vehiclecoords = GetEntityCoords(vehicle)
if GetDistanceBetweenCoords(playercoords.x, playercoords.y, playercoords.z, vehiclecoords.x, vehiclecoords.y, vehiclecoords.z, true) < 5 then
-- CHANGE TO:
if #(playercoords - vehiclecoords) < 5 then
^^^ You can find a ton more examples of this scattered throughout #community-framework
Alles anzeigen
5: FXMANIFEST -- Resource Metadata
Code
-- Do not use fx_version 'adamant' it's depreciated
fx_version 'cerulean'
games { 'rdr3', 'gta5' }
author 'Jon Doe'
description 'Example resource'
version '1.0.0'
-- What to run
client_scripts {
'client.lua',
'client_two.lua'
}
server_script 'server.lua'
-- Extra data can be used as well
my_data 'one' { two = 42 }
my_data 'three' { four = 69 }
-- due to Lua syntax, the following works too:
my_data('nine')({ninety = "nein"})
Alles anzeigen
6: Small resources
Code
Citizen.CreateThread(function()
while true do
if not IsAimCamActive() or not IsFirstPersonAimCamActive() then
HideHudComponentThisFrame(14)
HideHudComponentThisFrame(1)
HideHudComponentThisFrame(2)
HideHudComponentThisFrame(3)
HideHudComponentThisFrame(4)
HideHudComponentThisFrame(7)
HideHudComponentThisFrame(9)
HideHudComponentThisFrame(13)
HideHudComponentThisFrame(17)
HideHudComponentThisFrame(19)
HideHudComponentThisFrame(20)
HideHudComponentThisFrame(21)
HideHudComponentThisFrame(22)
DisplayAmmoThisFrame(true)
end
Citizen.Wait(0)
end
end)
Alles anzeigen
7: QB liveryfix
Code
QB-CUSTOMS/client/main.lua / line 804
elseif v.modtype == "liveries" then
if v.modid ~= -1 then
if v.liverytype == "mod" then
SetVehicleMod(veh, 48, v.modid, false)
elseif v.liverytype == "livery" then
SetVehicleLivery(veh, v.modid)
end
end
Change to this
elseif v.modtype == "liveries" then
SetVehicleMod(veh, 48, v.modid, false)
SetVehicleLivery(veh, v.modid)
Alles anzeigen
8: QB weaponlicnese
Code
qb-shops/main.lua Change line 40
if dist < 1 then
DrawText3Ds(loc["x"], loc["y"], loc["z"] + 0.15, '~g~E~w~ - Open shop')
if IsControlJustPressed(0, Config.Keys["E"]) then
if Config.Locations[shop]["products"] == Config.Products["weapons"] then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
local ShopItems = {}
ShopItems.label = Config.Locations[shop]["label"]
ShopItems.items = Config.Locations[shop]["products"]
ShopItems.slots = 30
TriggerServerEvent("inventory:server:OpenInventory", "shop", "Itemshop_"..shop, ShopItems)
else
QBCore.Functions.Notify("You don\'t have weapon license on you", "error")
end
end, "weaponlicense")
else
local ShopItems = {}
ShopItems.label = Config.Locations[shop]["label"]
ShopItems.items = Config.Locations[shop]["products"]
ShopItems.slots = 30
TriggerServerEvent("inventory:server:OpenInventory", "shop", "Itemshop_"..shop, ShopItems)
end
end
end
Alles anzeigen
Code
qb-core/shared.lua
["weplicense"] = {
["name"] = "weplicense",
["label"] = "Weapon License",
["weight"] = 0,
["type"] = "item",
["image"] = "weapon_license.png",
["unique"] = true,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Weapon License and what weapon you allowed to use"
},
qb-core/server/player.lua
PlayerData.metadata["licences"] = PlayerData.metadata["licences"] ~= nil and PlayerData.metadata["licences"] or {
["driver"] = true,
["weapon"] = false,
["business"] = false
}
Alles anzeigen
Code
police/server/main.lua
QBCore.Commands.Add("giveweplicense", "Give weapon license", {{name="id", help="Player ID"}, {name="type", help="License Type"}}, true, function(source, args)
local Player = QBCore.Functions.GetPlayer(source)
local playerId = tonumber(args[1])
local OtherPlayer = HCCore.Functions.GetPlayer(playerId)
local LicenseType = tonumber(args[2])
local licenses = {
["driver"] = OtherPlayer.PlayerData.metadata["licences"]["driver"],
["weapon"] = true,
["business"] = OtherPlayer.PlayerData.metadata["licences"]["business"]
}
if LicenseType == 1 then
LicenseType = "1"
elseif LicenseType == 2 then
LicenseType = "2"
elseif LicenseType == 3 then
LicenseType = "3"
elseif LicenseType == 4 then
LicenseType = "1/2"
elseif LicenseType == 5 then
LicenseType = "1/2/3"
end
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.grade.level == 6 or Player.PlayerData.job.grade.level == 7 then
if OtherPlayer ~= nil then
local licenseinfo = {
citizenid = OtherPlayer.PlayerData.citizenid,
firstname = OtherPlayer.PlayerData.charinfo.firstname,
lastname = OtherPlayer.PlayerData.charinfo.lastname,
type = LicenseType,
}
OtherPlayer.Functions.AddItem("weplicense", 1, false, licenseinfo)
OtherPlayer.Functions.SetMetaData("licences", licenses)
TriggerClientEvent('inventory:client:ItemBox', OtherPlayer.PlayerData.source, QBCore.Shared.Items["weplicense"], "add")
else
TriggerClientEvent("QBCore:Notify", source, "This person is not present..", "error")
end
else
TriggerClientEvent("QBCore:Notify", source, "You have no rights..", "error")
end
end)
Alles anzeigen
Code
police/client/main.lua
RegisterNetEvent("police:client:showWeaponLicense")
AddEventHandler("police:client:showWeaponLicense", function(sourceId, data)
local sourcePos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(sourceId)), false)
local pos = GetEntityCoords(pedId, false)
if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, sourcePos.x, sourcePos.y, sourcePos.z, true) < 2.0) then
TriggerEvent('chat:addMessage', {
template = '<div class="chat-message advert"><div class="chat-message-body"><strong>{0}:</strong><br><br> <strong>Citizen-ID:</strong> {1} <br><strong>First Name:</strong> {2} <br><strong>Last Name:</strong> {3} <br><strong>Type:</strong> {4} </div></div>',
args = {'Weapon License', data.citizenid, data.firstname, data.lastname, data.type}
})
end
end)
Example
/giveweplicense [ID] [LicenseType]
Example: /giveweplicense 1 4
Alles anzeigen
Kommentare
Neu erstellte Kommentare unterliegen der Moderation und werden erst sichtbar, wenn sie durch einen Moderator geprüft und freigeschaltet wurden.
Neu erstellte Kommentare unterliegen der Moderation und werden erst sichtbar, wenn sie durch einen Moderator geprüft und freigeschaltet wurden.