1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[自分用]QB-Coreドキュメント

Last updated at Posted at 2025-08-16


1章: コアオブジェクト

はじめに

コアオブジェクトは、qb-coreフレームワークの根幹であり、サーバーのゲームプレイメカニクス、プレイヤーデータ、および全体的なリソースインタラクションを管理するための不可欠な機能とユーティリティを提供します。このページでは、コアオブジェクトを効果的に使用するための主要な機能、メソッド、およびベストプラクティスについて説明します。

コアオブジェクトへのアクセス方法

すべてをインポートする必要がない限り、コアオブジェクトのフィルタリング機能を使用することをお勧めします!

スクリプトでコアオブジェクトと対話するには、スクリプトの先頭で次のパターンを使用します。

  • exportsへの繰り返しの呼び出しを避けるために、常にコアオブジェクトをローカル変数にキャッシュしてください。
コアオブジェクトの取得
local QBCore = exports["qb-core"]:GetCoreObject()

qb-coreバージョン1.3.0以降(fxmanifest.luaを確認してください)では、すべてをインポートする代わりに、コアオブジェクトから何を取得するかを決定できます!この変更は、完全なコアをインポートすると不要なオーバーヘッドが多く、各スクリプト内に保存されるメモリ量を削減するために行われました。

必要な機能のみをインポート
-- コアオブジェクトの関数にのみアクセスしたい場合!
local QBCore = exports["qb-core"]:GetCoreObject({"Functions"})

-- これで以下が使用可能になります!
-- QBCore.Functions

-- 関数と共有の両方にアクセスしたい場合!
local QBCore = exports["qb-core"]:GetCoreObject({"Functions", "Shared"})

-- これで以下が使用可能になります!
-- QBCore.Functions
-- QBCore.Shared

エクスポートされた関数

  • qb-coreバージョン1.3.0以降(fxmanifest.luaを確認してください)では、コアオブジェクト内のすべての関数がエクスポートされているため、単一の関数のみが必要な場合はすべてをインポートする必要はありません!これは、さまざまなフレームワークをサポートするスクリプト作成者で、すべてのコア情報が必要ない場合に非常に便利です。必要な関数を呼び出すだけでよくなりました。
単一関数の直接呼び出し
local function getPlayer(source)
    return exports["qb-core"]:GetPlayer(source)
end

コア機能

テーブル名 説明
Functions 一般的なサーバーおよびプレイヤー操作のためのユーティリティ関数のコレクション。
Players 現在接続されているすべてのプレイヤーを含むテーブル。
Shared アイテム、車両、ジョブなどの共有データ。
Config qb-coreの主要な設定テーブル。
Commands カスタムサーバーおよびクライアントコマンドのレジストリ。

使用例

プレイヤーデータへのアクセス

  • コアオブジェクトを使用してプレイヤーのデータを取得できます。
local QBCore = exports["qb-core"]:GetCoreObject()

local function getPlayerJob(source)
    local player = QBCore.Functions.GetPlayer(source)
    if player then
        local job = player.PlayerData.job
        print("Player's job:", job.name)
    end
end

共有データの使用

  • アイテム、車両、ジョブなどの共有データにアクセスします。
local QBCore = exports["qb-core"]:GetCoreObject()

-- 特定のアイテムの詳細を取得
local item = QBCore.Shared.Items["water_bottle"]
print("Item name:", item.name)
print("Item label:", item.label)

コマンドの登録

  • コアオブジェクトを使用すると、サーバーのカスタムコマンドを登録できます。
local QBCore = exports["qb-core"]:GetCoreObject()

QBCore.Commands.Add('greet', 'Send a greeting', {}, false, function(source, args)
    local name = args[1] or 'player'
    TriggerClientEvent('chat:addMessage', source, {
        template = '<div class="chat-message">Hello, {0}!</div>',
        args = { name }
    })
end)

2章: プレイヤーデータ

はじめに

qb-coreプレイヤーデータ オブジェクトは、プレイヤーのキャラクターに関するすべての情報(個人情報、ジョブ、ギャングの所属、メタデータなど)を保存します。これらの値は、qb-coreconfig.lua ファイルで定義されたデフォルト値を使用して初期化されます。

このガイドでは、構造、デフォルト値、およびプレイヤーデータへのアクセスまたは変更方法の概要を説明します。

PlayerDataの構造
QBCore
├── Players
   ├── [source]
       ├── PlayerData
           ├── citizenid: string (一意の識別子)
           ├── cid: number (キャラクターID)
           ├── money: table
              └── { cash: number, bank: number }
           ├── charinfo: table
              ├── firstname: string
              ├── lastname: string
              ├── ...
           ├── job: table
              ├── name: string
              ├── label: string
              ├── payment: number
              ├── onduty: boolean
              ├── isboss: boolean
              └── grade: table
                  ├── name: string
                  └── level: number
           ├── gang: table
              ├── name: string
              ├── label: string
              ├── isboss: boolean
              └── grade: table
                  ├── name: string
                  └── level: number
           ├── metadata: table
              ├── hunger: number
              ├── thirst: number
              ├── stress: number
              ├── isdead: boolean
              └── ...
           ├── position: vector3
           └── items: table (インベントリアイテム)

設定

プレイヤーデータのデフォルト値は、qb-coreconfig.lua ファイルで変更できます。これらのデフォルト値は QBConfig.Player.PlayerDefaults に保存され、プレイヤーが新しいキャラクターを作成したときに何から始めるかを決定します。

プレイヤーオブジェクト関数

サーバーで作成されたすべてのプレイヤーには、特定の関数がアタッチされています。これらの関数は直接呼び出すことができます!

UpdatePlayerData

クライアントとサーバーでプレイヤーデータを更新します。

この関数はイベント QBCore:Player:SetPlayerData をトリガーします。

local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.UpdatePlayerData()

SetJob

プレイヤーのジョブと等級を設定します。

  • job: string
  • grade: number
  • 戻り値: boolean - 成功した場合は true、失敗した場合は false
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetJob("police", 1)

SetGang

プレイヤーのギャングと等級を設定します。

  • gang: string
  • grade: number
  • 戻り値: boolean - 成功した場合は true、失敗した場合は false
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetGang("lostmc", 1)

Notify

プレイヤーに通知を表示します。

  • text: string
  • type: string — error, success, primary, warning
  • length (オプション): number
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.Notify("Hello!", "success", 5000)

HasItem

アイテムを持っているかどうかの確認には、インベントリのエクスポートを使用することをお勧めします!この関数は単にそちらにルーティングするだけです。

  • item: string | table
  • amount: number
  • 戻り値: boolean
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.HasItem("water_bottle", 1)

GetName

プレイヤーのフルキャラクター名を取得します。

  • 戻り値: string
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.GetName()

SetJobDuty

プレイヤーを勤務中/勤務外に設定します。

この関数はイベント QBCore:Server:OnJobUpdateQBCore:Client:OnJobUpdate をトリガーします。また、関数 UpdatePlayerData もトリガーします。

  • duty: boolean
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetJobDuty(true)

SetPlayerData

プレイヤーのデータ値を名前で具体的に設定します。

この関数は関数 UpdatePlayerData もトリガーします。

  • key: string
  • value: string | table
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetPlayerData("position", vector3(-425.3, 1123.6, 325.0))

SetMetaData

プレイヤーのメタデータ値を名前で具体的に設定します。

この関数は関数 UpdatePlayerData もトリガーします。

  • key: string
  • value: string | table | number
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetMetaData("hunger", 80)

GetMetaData

プレイヤーのメタデータ値を名前で具体的に取得します。

  • value: string
  • 戻り値: string | table | number
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.GetMetaData("hunger")

AddRep

評判の値を名前で具体的に追加します。

この関数は関数 UpdatePlayerData もトリガーします。

qb-core/config.lua でさまざまな種類の評判を追加します。

  • rep: string
  • amount: number
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.AddRep("selling", 10)

RemoveRep

評判の値を名前で具体的に減少させます。

この関数は関数 UpdatePlayerData もトリガーします。

qb-core/config.lua でさまざまな種類の評判を追加します。

  • rep: string
  • amount: number
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.RemoveRep("selling", 10)

GetRep

評判の現在の値を名前で具体的に取得します。

  • rep: string
  • 戻り値: number
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.GetRep("selling")

AddMoney

特定の通貨タイプの値を名前で追加します。

この関数は関数 UpdatePlayerData もトリガーします。

  • money: string
  • 戻り値: boolean
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.AddMoney("cash", 1000)

RemoveMoney

特定の通貨タイプの値を名前で減少させます。

この関数は関数 UpdatePlayerData もトリガーします。

  • money: string
  • 戻り値: boolean
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.RemoveMoney("cash", 1000)

SetMoney

特定の通貨タイプの値を名前で設定します。

この関数は関数 UpdatePlayerData もトリガーします。

  • money: string
  • 戻り値: boolean
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetMoney("cash", 1000)

GetMoney

指定された通貨タイプの値を返します。

  • money: string
  • 戻り値: number
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.GetMoney("cash")

Save

プレイヤーの保存をトリガーします。

local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.Save()

Logout

プレイヤーを強制的にマルチキャラクター画面に戻します。

local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.Logout()

AddMethod

AddMethod 関数を使用すると、カスタムメソッド(関数)をプレイヤーオブジェクトに動的に追加できます。これは、モジュール化された再利用可能な方法でプレイヤーの機能を拡張するのに特に役立ちます。

メソッドがすでに存在するかどうかを確認する価値があります!次のチェックを実行することで確認できます。

if Player.Functions.MyMethod then
print("Method already exists!")
end

  • method: string
  • handler: function
local Player = QBCore.Functions.GetCoreObject()
if not Player then return end

Player.Functions.AddMethod("Greet", function()
    print("Hello, " .. Player.Functions.GetName() .. "!")
end)

Player.Functions.Greet()

AddField

AddField 関数を使用すると、カスタムフィールド(変数またはデータ)をプレイヤーオブジェクトに動的に追加できます。これは、デフォルトの PlayerData 構造の一部ではない追加のプレイヤー固有のデータを保存するのに役立ちます。

フィールドがすでに存在するかどうかを確認する価値があります!次のチェックを実行することで確認できます。

if Player.MyField then
print("Field already exists!")
end

  • field: string
  • data: any
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.AddField("Skills", {
    hacking = 1,
    driving = 3,
    shooting = 2
})

3章: 共有データ (Shared)

アイテム

  • qb-core/shared/items.lua にあります。

qb-coreItems テーブルは、サーバーで利用可能なすべてのアイテムを定義します。各アイテムは、その動作、外観、および機能を決定するいくつかのプロパティを持つオブジェクトとして表されます。

プロパティ 説明
name string アイテムのスポーン、付与、または削除に使用される内部名。
label string インベントリに表示される表示名。
weight number アイテムの重量で、インベントリ容量に影響します。
type string アイテムのタイプ(例: itemweapon)。
image string qb-inventory/html/images にあるアイテムの画像ファイル名。
unique boolean アイテムが一意であるか(true)、スタック可能であるか(false)。
useable boolean アイテムが使用可能であるかどうか。使用可能なアイテムとして登録されている必要があります。
shouldClose boolean アイテムを使用するとインベントリが閉じるかどうか(trueまたはfalse)。
description string インベントリに表示されるアイテムの短い説明。

例: 基本的なアイテム定義

QBShared.Items = {
    id_card = {
        name = "id_card", -- 内部名
        label = "IDカード", -- インベントリに表示される表示名
        weight = 0, -- アイテムの重量
        type = "item", -- アイテムのタイプ(例: item, weapon)
        image = "id_card.png", -- アイテムの画像ファイル名
        unique = true, -- アイテムは一意か?
        useable = true, -- アイテムは使用可能か?
        shouldClose = false, -- 使用時にインベントリを閉じるか?
        description = "自分を識別するためのすべての情報を含むカード" -- 説明
    }
}

ジョブ

  • qb-core/shared/jobs.lua にあります。

qb-coreJobs テーブルは、サーバーで利用可能なすべてのジョブを定義します。これには、ランク、給与、および特定の機能が含まれます。これにより、雇用役割、責任、および給与構造を効果的に管理できます。

例: グローバル設定

グローバル設定は、ログイン時にジョブの defaultDuty 設定にデフォルトで勤務状態を設定するか、データベースに最後に保存された状態に基づいて永続化するかを決定します。

QBShared.ForceJobDefaultDutyAtLogin = true -- true: ジョブのdefaultDutyを使用 | false: データベースから最後に保存された勤務状態を使用

ジョブオブジェクトのレイアウト

プロパティ 説明
label string ジョブの表示名。
type string ジョブのタイプ(例: 警察官の場合は leo)。
defaultDuty boolean ログイン時にプレイヤーが自動的に勤務中になるかどうか。
offDutyPay boolean プレイヤーが勤務時間外に給与を受け取るかどうか。
grades table ジョブの等級を定義するテーブル。名前、給与、その他のランク固有の属性が含まれます。

等級テーブルのレイアウト

プロパティ 説明
name string 等級の名前(例: 新兵、警察官)。
payment number この等級の給与。
isboss boolean (オプション) trueの場合、この等級はボスとしてマークされます(例: 署長)。

例: 基本的なジョブ定義

この例では、単一の等級を持つ無職のジョブを定義します。

QBShared.Jobs = {
    unemployed = {
        label = "一般市民", -- 表示名
        defaultDuty = true, -- ログイン時に自動的に勤務中
        offDutyPay = false, -- 勤務時間外は給与なし
        grades = {
            { name = "フリーランサー", payment = 10 } -- 給与付きの単一等級
        }
    }
}

例: 高度なジョブ定義

この例では、複数の等級を持つ警察のジョブを定義します。各等級には特定の属性があります。

QBShared.Jobs = {
    police = {
        label = "法執行機関", -- 表示名
        type = "leo", -- ジョブタイプ(例: 法執行機関)
        defaultDuty = true, -- ログイン時に自動的に勤務中
        offDutyPay = false, -- 勤務時間外は給与なし
        grades = {
            { name = "新兵",    payment = 50 },  -- ランク1: 新兵、給与$50
            { name = "警察官",    payment = 75 },  -- ランク2: 警察官、給与$75
            { name = "巡査部長",   payment = 100 }, -- ランク3: 巡査部長、給与$100
            { name = "警部補", payment = 125 }, -- ランク4: 警部補、給与$125
            { name = "署長",      isboss = true, payment = 150 }, -- ランク5: 署長、ボスとしてマーク、給与$150
        }
    }
}

ギャング

  • qb-core/shared/gangs.lua にあります。

qb-coreGangs テーブルは、サーバーで利用可能なすべてのギャングを定義します。これには、ランク、給与、および特定の機能が含まれます。これにより、メンバーの役割、責任、および給与構造を効果的に管理できます。


ギャングオブジェクトのレイアウト

プロパティ 説明
label string ギャングの表示名
grades table ギャングの等級を定義するテーブル。名前やその他のランク固有の属性が含まれます。

等級テーブルのレイアウト

プロパティ 説明
name string 等級の名前(例: 新兵、執行者)。
isboss boolean (オプション) trueの場合、この等級はボスとしてマークされます(例: ボス)。

例: 基本的なギャング定義

この例では、単一の等級を持つ無所属のギャングを定義します。

QBShared.Gangs = {
    none = {
        label = "ギャングなし", -- 表示名
        grades = {
            { name = "無所属" } -- 単一等級
        }
    }
}

例: 高度なギャング定義

この例では、複数の等級を持つロストMCギャングを定義します。各等級には特定の属性があります。

QBShared.Gangs = {
    lostmc = {
        label = "ロストMC", -- 表示名
        grades = {
            { name = "新兵" }, -- ランク1
            { name = "執行者" }, -- ランク2
            { name = "ショットコーラー" }, -- ランク3
            { name = "ボス", isboss = true }, -- ランク4、ボスとしてマーク
        },
    },
}

車両

所有のために車両をデータベースに保存したい場合、共有車両テーブルで定義されている必要があります!

  • qb-core/shared/vehicles.lua にあります。

qb-coreVehicles テーブルは、サーバーで利用可能なすべての車両を定義します。これには、プロパティとカテゴリが含まれます。このテーブルを使用すると、各車両の特定の属性を設定して、ゲーム内での動作を制御できます。

プロパティ 説明
model string 車両のスポーンコード(ゲーム内のモデル名と一致する必要があります)。
name string プレイヤーに表示される車両の表示名。
brand string 車両のブランドまたはメーカー(例: "Maxwell"、"Karin")。
price number ゲーム内通貨での車両の価格。
category string 車両のカテゴリ(例: "compacts"、"sports")。GetVehicleClass を使用してください。
type string 車両のタイプ(例: "automobile"、"bike")。Vehicle Types を参照してください。
shop `string table`
QBShared.Vehicles = {
    {
        model = "asbo",        -- これは車両のスポーンコードと一致する必要があります
        name = "Asbo",         -- これは車両の表示名です
        brand = "Maxwell",     -- これは車両のブランドです
        price = 4000,          -- 車両の販売価格
        category = "compacts", -- 車両のカテゴリ。GetVehicleClass() オプションに従ってください https://docs.fivem.net/natives/?_0x29439776AAA00A62
        type = "automobile",   -- 車両タイプ。こちらを参照してください https://docs.fivem.net/natives/?_0x6AE51D4B & こちら https://docs.fivem.net/natives/?_0xA273060E
        shop = "pdm",          -- 単一のショップ、または複数のショップを指定できます。例: {"shopname1","shopname2","shopname3"}
    }
}

QBShared.Vehicles テーブルは、車両のモデルで自動的にインデックス付けされます!したがって、QBCore.Shared.Vehicles[model] を介してそのプロパティにアクセスできます。

また、キーとして車両のハッシュを格納する QBShared.VehicleHashes というテーブルも作成します!

車両のハッシュのみで作業する必要がある場合があるため、以下の例に従って検索できます。

local vehicleHash = 12345

local vehicleData = QBShared.VehicleHashes[vehicleHash]
if vehicleData then
    print("一致するモデルが見つかりました: "..vehicleData.model)
    print(json.encode(vehicleData))
end

-- または

for model, vehicleData in pairs(QBCore.Shared.Vehicles) do
    if vehicleData.hash == vehicleHash then
        print("一致するモデルが見つかりました: "..model)
        print(json.encode(vehicleData))
        break
    end
end

武器

武器はアイテムとして使用するために shared/items.lua にも追加されます!このテーブルは、武器のハッシュを介して武器情報を検索するためだけのものであり、GetCurrentPedWeapon または武器のハッシュを返す同様のネイティブ関数を介して返されます。

  • qb-core/shared/weapons.lua にあります。

qb-coreWeapons テーブルは、サーバーで利用可能なすべての武器を定義します。これには、武器の名前、ラベル、タイプ、弾薬タイプ、および死亡通知のダメージ理由などの属性が含まれます。このテーブルを使用すると、プレイヤーがアクセスできる武器を管理およびカスタマイズできます。

武器オブジェクトのレイアウト

プロパティ 説明
name string 武器の内部スポーン名(例: weapon_pistol)。
label string プレイヤーに表示される武器の表示名。
weapontype string 武器のタイプ(例: "Pistol"、"Shotgun"、"Rifle")。
ammotype string 武器が使用する弾薬のタイプ(例: AMMO_PISTOLAMMO_SHOTGUN)。
damagereason string 死亡通知に表示される、死因を説明するためのカスタマイズ可能なメッセージ。
QBShared.Weapons = {
    [`weapon_pistol`] = { -- 武器のハッシュ(コンパイル時のJenkinsハッシュを使用)
        name = "weapon_pistol", -- 武器の内部スポーン名(例: weapon_pistol)
        label = "ワルサーP99", -- プレイヤーに表示される武器の表示名
        weapontype = "ピストル", -- 武器のタイプ(例: "Pistol"、"Shotgun"、"Rifle")
        ammotype = "AMMO_PISTOL", -- 武器が使用する弾薬のタイプ(例: AMMO_PISTOL、AMMO_SHOTGUN)
        damageReason = "ピストルで撃たれた / 爆破された / 撃ち抜かれた / 弾を食らった" -- 死亡通知に表示される、死因を説明するためのカスタマイズ可能なメッセージ
    }
}

4章: 共有エクスポート

| 関数またはイベント | スコープ | 説明 | 戻り値 |
|:---|:---:|:---:|
| exports["qb-core"]:AddItem(itemName, item) | サーバー | アイテム名とアイテムオブジェクトを受け入れます - QBCore.Shared.Itemsに新しいエントリを追加します | boolean, string |
| exports["qb-core"]:AddJob(jobName, job) | サーバー | ジョブ名とジョブオブジェクトを受け入れます - QBCore.Shared.Jobsに新しいエントリを追加します | boolean, string |
| exports["qb-core"]:AddGang(gangName, gang) | サーバー | ギャング名とギャングオブジェクトを受け入れます - QBCore.Shared.Gangsに新しいエントリを追加します | boolean, string |
| exports["qb-core"]:AddItems(items) | サーバー | テーブルまたは配列を受け入れます - テーブルをループし、QBCore.Shared.Itemsに新しいエントリを追加します | boolean, string, errorItem |
| exports["qb-core"]:AddJobs(jobs) | サーバー | テーブルまたは配列を受け入れます - テーブルをループし、QBCore.Shared.Jobsに新しいエントリを追加します | boolean, string, errorItem |
| exports["qb-core"]:AddGangs(gangs) | サーバー | テーブルまたは配列を受け入れます - テーブルをループし、QBCore.Shared.Gangsに新しいエントリを追加します | boolean, string, errorItem |
| QBCore.Functions.AddItem(itemName, item) | サーバー | アイテム名とアイテムオブジェクトを受け入れます - QBCore.Shared.Itemsに新しいエントリを追加します | boolean, string |
| QBCore.Functions.AddJob(jobName, Job) | サーバー | ジョブ名とジョブオブジェクトを受け入れます - QBCore.Shared.Jobsに新しいエントリを追加します | boolean, string |
| QBCore.Functions.AddGang(gangName, Gang) | サーバー | ギャング名とギャングオブジェクトを受け入れます - QBCore.Shared.Gangsに新しいエントリを追加します | boolean, string |
| QBCore.Functions.AddItems(items) | サーバー | テーブルまたは配列を受け入れます - テーブルをループし、QBCore.Shared.Itemsに新しいエントリを追加します | boolean, string, errorItem |
| QBCore.Functions.AddJobs(jobs) | サーバー | テーブルまたは配列を受け入れます - テーブルをループし、QBCore.Shared.Jobsに新しいエントリを追加します | boolean, string, errorItem |
| QBCore.Functions.AddGangs(gangs) | サーバー | テーブルまたは配列を受け入れます - テーブルをループし、QBCore.Shared.Gangsに新しいエントリを追加します | boolean, string, errorItem |

ジョブのインポート

  • このメソッドを使用すると、任意のリソースがジョブデータをコアの共有ファイルに挿入できます。つまり、リソースを作成し、ロード時にそれらのジョブを使用可能にすることができます。これは、以下に示すいずれかの方法で実現できます。関数を利用するにはコアをインポートする必要がありますが、エクスポートを使用する場合は必要ありません。

これらの使用を試みる前に、3章: 共有データの構造を読み、学習してください。

コアオブジェクトが必要な場合は、これらの使用時にこのコードをリソースのクライアント側ファイルに追加する必要があります!

RegisterNetEvent("QBCore:Client:UpdateObject", function()
	QBCore = exports["qb-core"]:GetCoreObject()
end)

コアオブジェクトが必要な場合は、これらの使用時にこのコードをリソースのサーバー側ファイルに追加する必要があります!

RegisterNetEvent("QBCore:Server:UpdateObject", function()
	if source ~= "" then return false end
	QBCore = exports["qb-core"]:GetCoreObject()
end)

QBCore.Functions.AddJob

QBCore.Functions.AddJob(jobName --[[string]], job --[[table]])

-- 例
QBCore.Functions.AddJob("unemployed", {
    label = "Civilian",
    defaultDuty = true,
    offDutyPay = false,
    grades = {
        ["0"] = {
            name = "Freelancer",
            payment = 10
        }
    }
})

exports["qb-core"]:AddJob

exports["qb-core"]:AddJob(jobName --[[string]], job --[[table]])

-- 例
exports["qb-core"]:AddJob("unemployed", {
    label = "Civilian",
    defaultDuty = true,
    offDutyPay = false,
    grades = {
        ["0"] = {
            name = "Freelancer",
            payment = 10
        }
    }
})

QBCore.Functions.AddJobs

QBCore.Functions.AddJobs(jobs --[[table]])

-- 例
QBCore.Functions.AddJobs({
    ["unemployed"] = {
        label = "Civilian",
        defaultDuty = true,
        offDutyPay = false,
        grades = {
            ["0"] = {
                name = "Freelancer",
                payment = 10
        }
    },
    ["trucker"] = {
	label = "Trucker",
	defaultDuty = true,
	offDutyPay = false,
	grades = {
            ["0"] = {
                name = "Driver",
                payment = 50
        }
    }
})

exports["qb-core"]:AddJobs

exports["qb-core"]:AddJobs(jobs --[[table]])

-- 例
exports["qb-core"]:AddJobs({
    ["unemployed"] = {
        label = "Civilian",
        defaultDuty = true,
        offDutyPay = false,
        grades = {
            ["0"] = {
                name = "Freelancer",
                payment = 10
        }
    },
    ["trucker"] = {
	label = "Trucker",
	defaultDuty = true,
	offDutyPay = false,
	grades = {
            ["0"] = {
                name = "Driver",
                payment = 50
        }
    }
})

ギャングのインポート

  • このメソッドを使用すると、任意のリソースがギャングデータをコアの共有ファイルに挿入できます。つまり、リソースを作成し、ロード時にそれらのギャングを使用可能にすることができます。これは、以下に示すいずれかの方法で実現できます。関数を利用するにはコアをインポートする必要がありますが、エクスポートを使用する場合は必要ありません。

QBCore.Functions.AddGang

QBCore.Functions.AddGang("azteca", {
    label = "Azteca",
    grades = {
        ["0"] = {
            name = "Recruit"
        }
    }
})

exports["qb-core"]:AddGang

exports["qb-core"]:AddGang("azteca", {
    label = "Azteca",
    grades = {
        ["0"] = {
            name = "Recruit"
        }
    }
})

QBCore.Functions.AddGangs

QBCore.Functions.AddGangs({
    ["lostmc"] = {
        label = "Lost MC",
        grades = {
            ["0"] = {
                name = "Recruit"
            }
        }
    },
    ["ballas"] = {
        label = "Ballas",
        grades = {
            ["0"] = {
                name = "Recruit"
            }
        }
    }
})

exports["qb-core"]:AddGangs

exports["qb-core"]:AddGangs({
    ["lostmc"] = {
        label = "Lost MC",
        grades = {
            ["0"] = {
                name = "Recruit"
            }
        }
    },
    ["ballas"] = {
        label = "Ballas",
        grades = {
            ["0"] = {
                name = "Recruit"
            }
        }
    }
})

アイテムのインポート

  • このメソッドを使用すると、任意のリソースがアイテムデータをコアの共有ファイルに挿入できます。つまり、リソースを作成し、ロード時にそれらのアイテムを使用可能にすることができます。これは、以下に示すいずれかの方法で実現できます。関数を利用するにはコアをインポートする必要がありますが、エクスポートを使用する場合は必要ありません。

QBCore.Functions.AddItem

QBCore.Functions.AddItem("water_bottle", {
    name = "water_bottle",
    label = "Bottle of Water",
    weight = 10,
    type = "item",
    image = "water_bottle.png",
    unique = false,
    useable = true,
    shouldClose = true,
    combinable = nil,
    description = "For all the thirsty out there"
})

exports["qb-core"]:AddItem

exports["qb-core"]:AddItem("water_bottle", {
    name = "water_bottle",
    label = "Bottle of Water",
    weight = 10,
    type = "item",
    image = "water_bottle.png",
    unique = false,
    useable = true,
    shouldClose = true,
    combinable = nil,
    description = "For all the thirsty out there"
})

QBCore.Functions.AddItems

QBCore.Functions.AddItems({
    ["water_bottle"] = {
        name = "water_bottle",
        label = "Bottle of Water",
        weight = 10,
        type = "item",
        image = "water_bottle.png",
        unique = false,
        useable = true,
        shouldClose = true,
        combinable = nil,
        description = "For all the thirsty out there"
    },
    ["sandwich"] = {
        name = "sandwich",
        label = "Sandwich",
        weight = 10,
        type = "item",
        image = "sandwich.png",
        unique = false,
        useable = true,
        shouldClose = true,
        combinable = nil,
        description = "Nice bread for your stomach"
    }
})

exports["qb-core"]:AddItems

exports["qb-core"]:AddItems({
    ["water_bottle"] = {
        name = "water_bottle",
        label = "Bottle of Water",
        weight = 10,
        type = "item",
        image = "water_bottle.png",
        unique = false,
        useable = true,
        shouldClose = true,
        combinable = nil,
        description = "For all the thirsty out there"
    },
    ["sandwich"] = {
        name = "sandwich",
        label = "Sandwich",
        weight = 10,
        type = "item",
        image = "sandwich.png",
        unique = false,
        useable = true,
        shouldClose = true,
        combinable = nil,
        description = "Nice bread for your stomach"
    }
})

5章: DrawText

受け入れられる位置: Left, Right, Top

関数またはイベント 説明
exports["qb-core"]:DrawText('message','position') 指定された位置にメッセージを描画するクライアントエクスポートです。
exports["qb-core"]:ChangeText('message','position') 指定された位置に現在表示されているメッセージを変更するクライアントエクスポートです。
exports["qb-core"]:HideText() テキスト表示を非表示にします。
exports["qb-core"]:KeyPressed() キーを押したときに背景を変更し、テキストを非表示にする場合に便利です。
TriggerClientEvent('qb-core:client:DrawText', source, message, position) エクスポートと同じですが、イベントとして。
TriggerClientEvent('qb-core:client:ChangeText', source, message, position) エクスポートと同じですが、イベントとして。
TriggerClientEvent('qb-core:client:HideText', source) エクスポートと同じですが、イベントとして。
TriggerClientEvent('qb-core:client:KeyPressed', source) エクスポートと同じですが、イベントとして。

HideText

  • 現在表示されているテキストを非表示にする関数
-- 参照用のソースコード
local function hideText()
    SendNUIMessage({
        action = 'HIDE_TEXT',
    })
end
exports("HideText", hideText)

-- エクスポートの例
local function examplefunction()
    exports["qb-core"]:DrawText("これはテストです", "left")
    Wait(5000) -- 5秒間テキストを表示
    exports["qb-core"]:HideText()
end

-- クライアントの例
local function examplefunction()
    TriggerEvent('qb-core:client:DrawText', "これはテストです", "left")
    Wait(5000) -- 5秒間テキストを表示
    TriggerEvent('qb-core:client:HideText')
end

-- サーバーの例
local function examplefunction(source)
    TriggerClientEvent('qb-core:client:DrawText', source, "これはテストです", "left")
    Wait(5000) -- 5秒間テキストを表示
    TriggerClientEvent('qb-core:client:HideText', source)
end

DrawText

  • 画面にテキストを描画する関数
-- 参照用のソースコード
local function drawText(text, position)
    if not type(position) == "string" then position = "left" end
    SendNUIMessage({
        action = 'DRAW_TEXT',
        data = {
            text = text,
            position = position
        }
    })
end
exports("DrawText", drawText)

-- エクスポートの例
local function examplefunction()
    exports["qb-core"]:DrawText("これはテストです", "left")
    Wait(5000) -- 5秒間テキストを表示
    exports["qb-core"]:HideText()
end

-- クライアントの例
local function examplefunction()
    TriggerEvent('qb-core:client:DrawText', "これはテストです", "left")
    Wait(5000) -- 5秒間テキストを表示
    TriggerEvent('qb-core:client:HideText')
end

-- サーバーの例
local function examplefunction(source)
    TriggerClientEvent('qb-core:client:DrawText', source, "これはテストです", "left")
    Wait(5000) -- 5秒間テキストを表示
    TriggerClientEvent('qb-core:client:HideText', source)
end

ChangeText

  • 現在表示されているテキストを変更する関数
-- 参照用のソースコード
local function changeText(text, position)
    if not type(position) == "string" then position = "left" end
    SendNUIMessage({
        action = 'CHANGE_TEXT',
        data = {
            text = text,
            position = position
        }
    })
end
exports("ChangeText", changeText)

-- エクスポートの例
local function examplefunction()
    exports["qb-core"]:DrawText("これはテストです", "left")
    Wait(5000) -- 5秒後にテキストを変更
    exports["qb-core"]:ChangeText("これは変更されたテキストです", "left")
    Wait(5000) -- 変更されたテキストを5秒間表示
    exports["qb-core"]:HideText()
end

-- クライアントの例
local function examplefunction()
    TriggerEvent('qb-core:client:DrawText', "これはテストです", "left")
    Wait(5000) -- 5秒後にテキストを変更
    TriggerEvent('qb-core:client:ChangeText', "これは変更されたテキストです", "left")
    Wait(5000) -- 変更されたテキストを5秒間表示
    TriggerEvent('qb-core:client:HideText')
end

-- サーバーの例
local function examplefunction(source)
    TriggerClientEvent('qb-core:client:ChangeText', source, "これは変更されたテキストです", "left")
end

KeyPressed

  • キーを押したときにアニメーションを表示し、現在表示されているテキストを非表示にするオプション関数
-- 参照用のソースコード
local function keyPressed()
    CreateThread(function()
        SendNUIMessage({
            action = 'KEY_PRESSED',
        })
        Wait(500)
        hideText()
    end)
end
exports("KeyPressed", keyPressed)

-- エクスポートの例
CreateThread(function()
    local textDrawn = false
    while true do
        Wait(0)
        if not textDrawn then
            exports["qb-core"]:DrawText("これはテストです","left")
            textDrawn = true
        end
        if IsControlJustPressed(0, 38) then
            exports["qb-core"]:KeyPressed()
        end
    end
end)

-- クライアントの例
CreateThread(function()
    local textDrawn = false
    while true do
        Wait(0)
        if not textDrawn then
            TriggerEvent('qb-core:client:DrawText', "これはテストです","left")
            textDrawn = true
        end
        if IsControlJustPressed(0, 38) then
            TriggerEvent('qb-core:client:KeyPressed')
        end
    end
end)

6章: クライアントイベントリファレンス

QBCore:Client:OnPlayerLoaded

  • キャラクター選択後にプレイヤーがロードされるのを処理します。

このイベントは、プレイヤーがサーバーに正常にロードされたことを示すため、コードをトリガーするイベントハンドラーとして使用できます!

RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
    print('私はクライアントで、あなたのサーバーにロードされました!')
end)

QBCore:Client:OnPlayerUnload

  • キャラクター選択のためにプレイヤーがログアウトするのを処理します。

このイベントは、プレイヤーがサーバーから正常にアンロードまたはログアウトしたことを示すため、コードをトリガーするイベントハンドラーとして使用できます!

RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
    print('私はクライアントで、あなたのサーバーからログアウトしました!')
end)

QBCore:Client:PvpHasToggled

プレイヤーロード時、このイベントは、PVPを有効にするか無効にするかをqb-coreの設定を確認した後にトリガーされます。

RegisterNetEvent('QBCore:Client:PvpHasToggled', function(pvp_state)
    print('PVPモードは '..tostring(pvp_state)..' に設定されました!')
end)

QBCore:Command:SpawnVehicle

引数 必須 デフォルト
vehicle model string はい なし

クライアントの例

-- /spawnveh adder
RegisterCommand('spawnveh', function(_, args)
    local vehicle = QBCore.Shared.Trim(args[1])
    TriggerEvent('QBCore:Command:SpawnVehicle', vehicle)
end, false)

サーバーの例

-- /spawnveh adder
RegisterCommand('spawnveh', function(source, args)
    local vehicle = QBCore.Shared.Trim(args[1])
    TriggerClientEvent('QBCore:Command:SpawnVehicle', source, vehicle)
end, false)

QBCore:Command:DeleteVehicle

引数 必須 デフォルト
なし なし いいえ なし

クライアントの例

RegisterCommand('deleteveh', function(_, args)
    TriggerEvent('QBCore:Command:DeleteVehicle')
end, false)

サーバーの例

RegisterCommand('deleteveh', function(source, args)
    TriggerClientEvent('QBCore:Command:DeleteVehicle', source)
end, false)

QBCore:Player:SetPlayerData

このイベントは、プレイヤーのデータが変更されたことを示すため、コードをトリガーするイベントハンドラーとして使用できます!

RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
    PlayerData = val
    print(QBCore.Debug(PlayerData))
end)

QBCore:Notify

引数 必須 デフォルト
message string | table はい 'Placeholder'
type string はい 'primary'
length number はい 5000

クライアントの例

-- /testnotify This is my message, primary, 5000
RegisterCommand('testnotify', function(_, args)
    local message = QBCore.Shared.SplitStr(table.concat(args, ' '), ",")
    local text = message[1]
    local type = QBCore.Shared.Trim(message[2])
    local length = tonumber(message[3])
    TriggerEvent('QBCore:Notify', text, type, length)
end, false)

サーバーの例

-- /testnotify This is my message, primary, 5000
RegisterCommand('testnotify', function(source, args)
    local message = QBCore.Shared.SplitStr(table.concat(args, ' '), ",")
    local text = message[1]
    local type = QBCore.Shared.Trim(message[2])
    local length = tonumber(message[3])
    TriggerClientEvent('QBCore:Notify', source, text, type, length)
end, false)

QBCore:Client:UseItem

引数 必須 デフォルト
item name string はい なし

クライアントの例(インベントリにアイテムがある必要があります)

-- /useitem sandwich 1
RegisterCommand('useitem', function(_, args)
    local item = {
        name = args[1],
        amount = tonumber(args[2])
    }
    TriggerEvent('QBCore:Client:UseItem', item)
end, false)

サーバーの例(インベントリにアイテムがある必要があります)

-- /useitem sandwich 1
RegisterCommand('useitem', function(source, args)
    local item = {
        name = args[1],
        amount = tonumber(args[2])
    }
    TriggerClientEvent('QBCore:Client:UseItem', source, item)
end, false)

QBCore:Command:ShowMe3D

引数 必須 デフォルト
player id number はい なし
message string はい なし

クライアントの例

-- /3dtext This is my message
RegisterCommand('3dtext', function(_, args)
    local message = table.concat(args, ' ')
    TriggerEvent('QBCore:Command:ShowMe3D', PlayerId(), message)
end, false)

サーバーの例

-- /3dtext This is my message
RegisterCommand('3dtext', function(source, args)
    local message = table.concat(args, ' ')
    TriggerClientEvent('QBCore:Command:ShowMe3D', source, message)
end, false)

QBCore:Client:UpdateObject

このイベントは、4章: 共有エクスポートを使用する際にハンドラーとして使用する必要があります。これは、リソース内のコアオブジェクトを更新するためです。

RegisterNetEvent('QBCore:Client:UpdateObject', function()
    QBCore = exports["qb-core"]:GetCoreObject()
end)

7章: クライアント関数リファレンス

QBCore.Functions.GetPlayerData

  • フレームワークで最もよく使われる関数です。この関数は、現在のソースのプレイヤーデータを返します。クライアント側で使用されるため、自動的にクライアントまたはプレイヤーになります。末尾に「.」(ピリオド)で始まる修飾子を付けて使用できます。
function QBCore.Functions.GetPlayerData(cb)
    if not cb then return QBCore.PlayerData end
    cb(QBCore.PlayerData)
end

-- 例

local Player = QBCore.Functions.GetPlayerData()
print(QBCore.Debug(Player))

-- または

local Player = QBCore.Functions.GetPlayerData()
local jobName = Player.job.name
print(jobName)

QBCore.Functions.GetCoords

  • この関数は、ネイティブのGetEntityCoordsと非常によく似た動作をしますが、ヘディングも返します。
function QBCore.Functions.GetCoords(entity)
    return vector4(GetEntityCoords(entity), GetEntityHeading(entity))
end

-- 例

local coords = QBCore.Functions.GetCoords(PlayerPedId())
print(coords)

QBCore.Functions.HasItem

  • プレイヤーが特定のアイテムを持っているかどうかを返します。
function QBCore.Functions.HasItem(item)
    local p = promise.new()
    QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
        p:resolve(result)
    end, item)
    return Citizen.Await(p)
end

-- 例

local hasItem = QBCore.Functions.HasItem("my_cool_item")
print(hasItem)

QBCore.Functions.Notify

引数 必須 デフォルト
message string | table はい 'Placeholder'
type string はい 'primary'
length number はい 5000
function QBCore.Functions.Notify(text, textype, length)
    if type(text) == "table" then
        local ttext = text.text or 'Placeholder'
        local caption = text.caption or 'Placeholder'
        local ttype = textype or 'primary'
        local length = length or 5000
        SendNUIMessage({
            type = ttype,
            length = length,
            text = ttext,
            caption = caption
        })
    else
        local ttype = textype or 'primary'
        local length = length or 5000
        SendNUIMessage({
            type = ttype,
            length = length,
            text = text
        })
    end
end

-- 例

QBCore.Functions.Notify('これはテストです', 'success', 5000)

QBCore.Functions.Notify({text = 'テスト', caption = 'テストキャプション'}, 'police', 5000)

QBCore.Functions.TriggerCallback

  • クライアントからサーバーを呼び出し、値を受け取るために使用される関数です。
function QBCore.Functions.TriggerCallback(name, cb, ...)
    QBCore.ServerCallbacks[name] = cb
    TriggerServerEvent('QBCore:Server:TriggerCallback', name, ...)
end

-- 例

QBCore.Functions.TriggerCallback('callbackName', function(result)
    print('CreateCallBackからこれを取得しました -->  '..result)
end, 'my_parameter_name')

QBCore.Functions.Progressbar

  • プログレスバーエクスポートのラッパーです。
function QBCore.Functions.Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
    exports['progressbar']:Progress({
        name = name:lower(),
        duration = duration,
        label = label,
        useWhileDead = useWhileDead,
        canCancel = canCancel,
        controlDisables = disableControls,
        animation = animation,
        prop = prop,
        propTwo = propTwo,
    }, function(cancelled)
        if not cancelled then
            if onFinish then
                onFinish()
            end
        else
            if onCancel then
                onCancel()
            end
        end
    end)
end

-- 呼び出し可能な利用可能なパラメータ

local Action = {
    name = "",
    duration = 0,
    label = "",
    useWhileDead = false,
    canCancel = true,
    disarm = true,
    controlDisables = {
        disableMovement = false,
        disableCarMovement = false,
        disableMouse = false,
        disableCombat = false,
    },
    animation = {
        animDict = nil,
        anim = nil,
        flags = 0,
        task = nil,
    },
    prop = {
        model = nil,
        bone = nil,
        coords = { x = 0.0, y = 0.0, z = 0.0 },
        rotation = { x = 0.0, y = 0.0, z = 0.0 },
    },
    propTwo = {
        model = nil,
        bone = nil,
        coords = { x = 0.0, y = 0.0, z = 0.0 },
        rotation = { x = 0.0, y = 0.0, z = 0.0 },
    },
}

-- 例

QBCore.Functions.Progressbar('Changeme', 'プレイヤーが見るもの', 1500, false, true, {
    disableMovement = true,
    disableCarMovement = true,
    disableMouse = false,
    disableCombat = true
    }, {}, {}, {}, function ()
        -- このコードはプログレスバーが正常に完了した場合に実行されます
    end, function ()
        -- このコードはプログレスバーがキャンセルされた場合に実行されます
end)

QBCore.Functions.GetVehicles

  • 車両ゲームプールを返します(下位互換性のため) - 使用する価値はありません。
function QBCore.Functions.GetVehicles()
    return GetGamePool('CVehicle')
end

-- 例

local vehicles = QBCore.Functions.GetVehicles()
print(QBCore.Debug(vehicles))

-- または -- 推奨される方法

local vehicles = GetGamePool('CVehicle')
print(QBCore.Debug(vehicles))

QBCore.Functions.GetCoreObject

  • アクセスするためのコアオブジェクトを返します。
exports('GetCoreObject', function()
    return QBCore
end)

-- 例

local QBCore = exports["qb-core"]:GetCoreObject()

-- または -- 他のファイルより先にロードされる単一のファイルでコアを呼び出します

QBCore = exports["qb-core"]:GetCoreObject()

QBCore.Functions.GetPlayers

  • OneSyncスコープ内のアクティブなプレイヤーを返します(下位互換性のため) - 使用する価値はありません。
function QBCore.Functions.GetPlayers()
    return GetActivePlayers()
end

-- 例

local players = QBCore.Functions.GetPlayers()
print(QBCore.Debug(players))

-- または -- 推奨される方法

local players = GetActivePlayers()
print(QBCore.Debug(players))

QBCore.Functions.GetPeds

  • モデルハッシュでフィルタリングされたpedゲームプールを返します。
function QBCore.Functions.GetPeds(ignoreList -- [[table]])
    local pedPool = GetGamePool('CPed')
    local ignoreList = ignoreList or {}
    local peds = {}
    for i = 1, #pedPool, 1 do
        local found = false
        for j=1, #ignoreList, 1 do
            if ignoreList[j] == pedPool[i] then
                found = true
            end
        end
        if not found then
            peds[#peds+1] = pedPool[i]
        end
    end
    return peds
end

-- 例

local peds = QBCore.Functions.GetPeds({`mp_m_freemode_01`})
print(QBCore.Debug(peds))

QBCore.Functions.GetClosestPed

  • フィルタリング後、プレイヤーに最も近いpedを返します。
function QBCore.Functions.GetClosestPed(coords, ignoreList)
    local ped = PlayerPedId()
    if coords then
        coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
    else
        coords = GetEntityCoords(ped)
    end
    local ignoreList = ignoreList or {}
    local peds = QBCore.Functions.GetPeds(ignoreList)
    local closestDistance = -1
    local closestPed = -1
    for i = 1, #peds, 1 do
        local pedCoords = GetEntityCoords(peds[i])
        local distance = #(pedCoords - coords)

        if closestDistance == -1 or closestDistance > distance then
            closestPed = peds[i]
            closestDistance = distance
        end
    end
    return closestPed, closestDistance
end

-- 例

local coords = GetEntityCoords(PlayerPedId())
local closestPed, distance = QBCore.Functions.GetClosestPed(coords)
print(closestPed, distance)

QBCore.Functions.GetClosestVehicle

  • プレイヤーに最も近い車両を返します。
function QBCore.Functions.GetClosestVehicle(coords)
    local ped = PlayerPedId()
    local vehicles = GetGamePool('CVehicle')
    local closestDistance = -1
    local closestVehicle = -1
    if coords then
        coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
    else
        coords = GetEntityCoords(ped)
    end
    for i = 1, #vehicles, 1 do
        local vehicleCoords = GetEntityCoords(vehicles[i])
        local distance = #(vehicleCoords - coords)

        if closestDistance == -1 or closestDistance > distance then
            closestVehicle = vehicles[i]
            closestDistance = distance
        end
    end
    return closestVehicle, closestDistance
end

-- 例

local coords = GetEntityCoords(PlayerPedId())
local closestVehicle, distance = QBCore.Functions.GetClosestVehicle(coords)
print(closestVehicle, distance)

QBCore.Functions.GetClosestObject

  • プレイヤーに最も近いオブジェクトを返します。
function QBCore.Functions.GetClosestObject(coords)
    local ped = PlayerPedId()
    local objects = GetGamePool('CObject')
    local closestDistance = -1
    local closestObject = -1
    if coords then
        coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
    else
        coords = GetEntityCoords(ped)
    end
    for i = 1, #objects, 1 do
        local objectCoords = GetEntityCoords(objects[i])
        local distance = #(objectCoords - coords)
        if closestDistance == -1 or closestDistance > distance then
            closestObject = objects[i]
            closestDistance = distance
        end
    end
    return closestObject, closestDistance
end

-- 例

local coords = GetEntityCoords(PlayerPedId())
local closestObject, distance = QBCore.Functions.GetClosestObject(coords)
print(closestObject, distance)

QBCore.Functions.GetClosestPlayer

  • クライアントに最も近いプレイヤーを返します。
function QBCore.Functions.GetClosestPlayer(coords)
    local ped = PlayerPedId()
    if coords then
        coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
    else
        coords = GetEntityCoords(ped)
    end
    local closestPlayers = QBCore.Functions.GetPlayersFromCoords(coords)
    local closestDistance = -1
    local closestPlayer = -1
    for i = 1, #closestPlayers, 1 do
        if closestPlayers[i] ~= PlayerId() and closestPlayers[i] ~= -1 then
            local pos = GetEntityCoords(GetPlayerPed(closestPlayers[i]))
            local distance = #(pos - coords)

            if closestDistance == -1 or closestDistance > distance then
                closestPlayer = closestPlayers[i]
                closestDistance = distance
            end
        end
    end
    return closestPlayer, closestDistance
end

-- 例

local coords = GetEntityCoords(PlayerPedId())
local closestPlayer, distance = QBCore.Functions.GetClosestPlayer(coords)
print(closestPlayer, distance)

QBCore.Functions.GetPlayersFromCoords

  • 特定の座標の半径内にいるすべてのプレイヤーを返します。
function QBCore.Functions.GetPlayersFromCoords(coords, distance)
    local players = QBCore.Functions.GetPlayers()
    local ped = PlayerPedId()
    if coords then
        coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
    else
        coords = GetEntityCoords(ped)
    end
    local distance = distance or 5
    local closePlayers = {}
    for _, player in pairs(players) do
        local target = GetPlayerPed(player)
        local targetCoords = GetEntityCoords(target)
        local targetdistance = #(targetCoords - coords)
        if targetdistance <= distance then
            closePlayers[#closePlayers + 1] = player
        end
    end
    return closePlayers
end

-- 例

local coords = GetEntityCoords(PlayerPedId())
local radius = 5.0
local closestPlayers = QBCore.Functions.GetPlayersFromCoords(coords, radius)
print(QBCore.Debug(closestPlayers))

QBCore.Functions.SpawnVehicle

  • 車両をスポーンさせます。
function QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked)
    local model = GetHashKey(model)
    local ped = PlayerPedId()
    if coords then
        coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
    else
        coords = GetEntityCoords(ped)
    end
    local isnetworked = isnetworked or true
    if not IsModelInCdimage(model) then
        return
    end
    RequestModel(model)
    while not HasModelLoaded(model) do
        Wait(10)
    end
    local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, isnetworked, false)
    local netid = NetworkGetNetworkIdFromEntity(veh)
    SetVehicleHasBeenOwnedByPlayer(veh, true)
    SetNetworkIdCanMigrate(netid, true)
    SetVehicleNeedsToBeHotwired(veh, false)
    SetVehRadioStation(veh, 'OFF')
    SetModelAsNoLongerNeeded(model)
    if cb then
        cb(veh)
    end
end

-- 例

local coords = QBCore.Functions.GetCoords(PlayerPedId())
QBCore.Functions.SpawnVehicle('adder', function(veh)
    SetVehicleNumberPlateText(veh, 'TEST')
    SetEntityHeading(veh, coords.w)
    exports['LegacyFuel']:SetFuel(veh, 100.0)
    TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1)
    TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(veh))
    SetVehicleEngineOn(veh, true, true)
end, coords, true)

QBCore.Functions.DeleteVehicle

  • クライアントを介して特定の車両を削除します - 使用する価値はありません。
function QBCore.Functions.DeleteVehicle(vehicle)
    SetEntityAsMissionEntity(vehicle, true, true)
    DeleteVehicle(vehicle)
end

-- 例

local ped = PlayerPedId()
local veh = GetVehiclePedIsUsing(ped)
if veh ~= 0 then
    QBCore.Functions.DeleteVehicle(veh)
else
    local pcoords = GetEntityCoords(ped)
    local vehicles = GetGamePool('CVehicle')
    for k, v in pairs(vehicles) do
        if #(pcoords - GetEntityCoords(v)) <= 5.0 then
            QBCore.Functions.DeleteVehicle(v)
        end
    end
end

-- または -- 推奨される方法

local ped = PlayerPedId()
local veh = GetVehiclePedIsUsing(ped)
if veh ~= 0 then
    SetEntityAsMissionEntity(veh, true, true)
    DeleteVehicle(veh)
else
    local pcoords = GetEntityCoords(ped)
    local vehicles = GetGamePool('CVehicle')
    for k, v in pairs(vehicles) do
        if #(pcoords - GetEntityCoords(v)) <= 5.0 then
            SetEntityAsMissionEntity(v, true, true)
            DeleteVehicle(v)
        end
    end
end

QBCore.Functions.GetPlate

  • 特定の車両のプレートテキストから空白をトリミングしたものを返します。
function QBCore.Functions.GetPlate(vehicle)
    if vehicle == 0 then return end
    return QBCore.Shared.Trim(GetVehicleNumberPlateText(vehicle))
end

-- 例

local vehicle = GetVehiclePedIsUsing(PlayerPedId())
local plate = QBCore.Functions.GetPlate(vehicle)
print(plate)

QBCore.Functions.GetVehicleProperties

  • 車両のすべてのプロパティを取得します。
function QBCore.Functions.GetVehicleProperties(vehicle)
    if DoesEntityExist(vehicle) then
        local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
        local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
        local extras = {}

        for extraId = 0, 12 do
            if DoesExtraExist(vehicle, extraId) then
                local state = IsVehicleExtraTurnedOn(vehicle, extraId) == 1
                extras[tostring(extraId)] = state
            end
        end

        local modLivery
        if GetVehicleMod(vehicle, 48) == -1 and GetVehicleLivery(vehicle) ~= -1 then
            modLivery = GetVehicleLivery(vehicle)
        else
            modLivery = GetVehicleMod(vehicle, 48)
        end

        return {
            model = GetEntityModel(vehicle),
            plate = QBCore.Functions.GetPlate(vehicle),
            plateIndex = GetVehicleNumberPlateTextIndex(vehicle),
            bodyHealth = QBCore.Shared.Round(GetVehicleBodyHealth(vehicle), 0.1),
            engineHealth = QBCore.Shared.Round(GetVehicleEngineHealth(vehicle), 0.1),
            tankHealth = QBCore.Shared.Round(GetVehiclePetrolTankHealth(vehicle), 0.1),
            fuelLevel = QBCore.Shared.Round(GetVehicleFuelLevel(vehicle), 0.1),
            dirtLevel = QBCore.Shared.Round(GetVehicleDirtLevel(vehicle), 0.1),
            color1 = colorPrimary,
            color2 = colorSecondary,
            pearlescentColor = pearlescentColor,
            interiorColor = GetVehicleInteriorColor(vehicle),
            dashboardColor = GetVehicleDashboardColour(vehicle),
            wheelColor = wheelColor,
            wheels = GetVehicleWheelType(vehicle),
            windowTint = GetVehicleWindowTint(vehicle),
            xenonColor = GetVehicleXenonLightsColour(vehicle),
            neonEnabled = {
                IsVehicleNeonLightEnabled(vehicle, 0),
                IsVehicleNeonLightEnabled(vehicle, 1),
                IsVehicleNeonLightEnabled(vehicle, 2),
                IsVehicleNeonLightEnabled(vehicle, 3)
            },
            neonColor = table.pack(GetVehicleNeonLightsColour(vehicle)),
            extras = extras,
            tyreSmokeColor = table.pack(GetVehicleTyreSmokeColor(vehicle)),
            modSpoilers = GetVehicleMod(vehicle, 0),
            modFrontBumper = GetVehicleMod(vehicle, 1),
            modRearBumper = GetVehicleMod(vehicle, 2),
            modSideSkirt = GetVehicleMod(vehicle, 3),
            modExhaust = GetVehicleMod(vehicle, 4),
            modFrame = GetVehicleMod(vehicle, 5),
            modGrille = GetVehicleMod(vehicle, 6),
            modHood = GetVehicleMod(vehicle, 7),
            modFender = GetVehicleMod(vehicle, 8),
            modRightFender = GetVehicleMod(vehicle, 9),
            modRoof = GetVehicleMod(vehicle, 10),
            modEngine = GetVehicleMod(vehicle, 11),
            modBrakes = GetVehicleMod(vehicle, 12),
            modTransmission = GetVehicleMod(vehicle, 13),
            modHorns = GetVehicleMod(vehicle, 14),
            modSuspension = GetVehicleMod(vehicle, 15),
            modArmor = GetVehicleMod(vehicle, 16),
            modTurbo = IsToggleModOn(vehicle, 18),
            modSmokeEnabled = IsToggleModOn(vehicle, 20),
            modXenon = IsToggleModOn(vehicle, 22),
            modFrontWheels = GetVehicleMod(vehicle, 23),
            modBackWheels = GetVehicleMod(vehicle, 24),
            modCustomTiresF = GetVehicleModVariation(vehicle, 23),
            modCustomTiresR = GetVehicleModVariation(vehicle, 24),
            modPlateHolder = GetVehicleMod(vehicle, 25),
            modVanityPlate = GetVehicleMod(vehicle, 26),
            modTrimA = GetVehicleMod(vehicle, 27),
            modOrnaments = GetVehicleMod(vehicle, 28),
            modDashboard = GetVehicleMod(vehicle, 29),
            modDial = GetVehicleMod(vehicle, 30),
            modDoorSpeaker = GetVehicleMod(vehicle, 31),
            modSeats = GetVehicleMod(vehicle, 32),
            modSteeringWheel = GetVehicleMod(vehicle, 33),
            modShifterLeavers = GetVehicleMod(vehicle, 34),
            modAPlate = GetVehicleMod(vehicle, 35),
            modSpeakers = GetVehicleMod(vehicle, 36),
            modTrunk = GetVehicleMod(vehicle, 37),
            modHydrolic = GetVehicleMod(vehicle, 38),
            modEngineBlock = GetVehicleMod(vehicle, 39),
            modAirFilter = GetVehicleMod(vehicle, 40),
            modStruts = GetVehicleMod(vehicle, 41),
            modArchCover = GetVehicleMod(vehicle, 42),
            modAerials = GetVehicleMod(vehicle, 43),
            modTrimB = GetVehicleMod(vehicle, 44),
            modTank = GetVehicleMod(vehicle, 45),
            modWindows = GetVehicleMod(vehicle, 46),
            modLivery = modLivery,
        }
    else
        return
    end
end

-- 例

local vehicle = GetVehiclePedIsUsing(PlayerPedId())
local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle)
print(QBCore.Debug(vehicleProps))

QBCore.Functions.SetVehicleProperties

  • 車両のすべてのプロパティを設定します。
function QBCore.Functions.SetVehicleProperties(vehicle, props)
    if DoesEntityExist(vehicle) then
        local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
        local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
        SetVehicleModKit(vehicle, 0)
        if props.plate then
            SetVehicleNumberPlateText(vehicle, props.plate)
        end
        if props.plateIndex then
            SetVehicleNumberPlateTextIndex(vehicle, props.plateIndex)
        end
        if props.bodyHealth then
            SetVehicleBodyHealth(vehicle, props.bodyHealth + 0.0)
        end
        if props.engineHealth then
            SetVehicleEngineHealth(vehicle, props.engineHealth + 0.0)
        end
        if props.fuelLevel then
            SetVehicleFuelLevel(vehicle, props.fuelLevel + 0.0)
        end
        if props.dirtLevel then
            SetVehicleDirtLevel(vehicle, props.dirtLevel + 0.0)
        end
        if props.color1 then
            SetVehicleColours(vehicle, props.color1, colorSecondary)
        end
        if props.color2 then
            SetVehicleColours(vehicle, props.color1 or colorPrimary, props.color2)
        end
        if props.pearlescentColor then
            SetVehicleExtraColours(vehicle, props.pearlescentColor, wheelColor)
        end
        if props.interiorColor then
            SetVehicleInteriorColor(vehicle, props.interiorColor)
        end
        if props.dashboardColor then
            SetVehicleDashboardColour(vehicle, props.dashboardColor)
        end
        if props.wheelColor then
            SetVehicleExtraColours(vehicle, props.pearlescentColor or pearlescentColor, props.wheelColor)
        end
        if props.wheels then
            SetVehicleWheelType(vehicle, props.wheels)
        end
        if props.windowTint then
            SetVehicleWindowTint(vehicle, props.windowTint)
        end
        if props.neonEnabled then
            SetVehicleNeonLightEnabled(vehicle, 0, props.neonEnabled[1])
            SetVehicleNeonLightEnabled(vehicle, 1, props.neonEnabled[2])
            SetVehicleNeonLightEnabled(vehicle, 2, props.neonEnabled[3])
            SetVehicleNeonLightEnabled(vehicle, 3, props.neonEnabled[4])
        end
        if props.extras then
            for id, enabled in pairs(props.extras) do
                if enabled then
                    SetVehicleExtra(vehicle, tonumber(id), 0)
                else
                    SetVehicleExtra(vehicle, tonumber(id), 1)
                end
            end
        end
        if props.neonColor then
            SetVehicleNeonLightsColour(vehicle, props.neonColor[1], props.neonColor[2], props.neonColor[3])
        end
        if props.modSmokeEnabled then
            ToggleVehicleMod(vehicle, 20, true)
        end
        if props.tyreSmokeColor then
            SetVehicleTyreSmokeColor(vehicle, props.tyreSmokeColor[1], props.tyreSmokeColor[2], props.tyreSmokeColor[3])
        end
        if props.modSpoilers then
            SetVehicleMod(vehicle, 0, props.modSpoilers, false)
        end
        if props.modFrontBumper then
            SetVehicleMod(vehicle, 1, props.modFrontBumper, false)
        end
        if props.modRearBumper then
            SetVehicleMod(vehicle, 2, props.modRearBumper, false)
        end
        if props.modSideSkirt then
            SetVehicleMod(vehicle, 3, props.modSideSkirt, false)
        end
        if props.modExhaust then
            SetVehicleMod(vehicle, 4, props.modExhaust, false)
        end
        if props.modFrame then
            SetVehicleMod(vehicle, 5, props.modFrame, false)
        end
        if props.modGrille then
            SetVehicleMod(vehicle, 6, props.modGrille, false)
        end
        if props.modHood then
            SetVehicleMod(vehicle, 7, props.modHood, false)
        end
        if props.modFender then
            SetVehicleMod(vehicle, 8, props.modFender, false)
        end
        if props.modRightFender then
            SetVehicleMod(vehicle, 9, props.modRightFender, false)
        end
        if props.modRoof then
            SetVehicleMod(vehicle, 10, props.modRoof, false)
        end
        if props.modEngine then
            SetVehicleMod(vehicle, 11, props.modEngine, false)
        end
        if props.modBrakes then
            SetVehicleMod(vehicle, 12, props.modBrakes, false)
        end
        if props.modTransmission then
            SetVehicleMod(vehicle, 13, props.modTransmission, false)
        end
        if props.modHorns then
            SetVehicleMod(vehicle, 14, props.modHorns, false)
        end
        if props.modSuspension then
            SetVehicleMod(vehicle, 15, props.modSuspension, false)
        end
        if props.modArmor then
            SetVehicleMod(vehicle, 16, props.modArmor, false)
        end
        if props.modTurbo then
            ToggleVehicleMod(vehicle, 18, props.modTurbo)
        end
        if props.modXenon then
            ToggleVehicleMod(vehicle, 22, props.modXenon)
        end
        if props.xenonColor then
            SetVehicleXenonLightsColor(vehicle, props.xenonColor)
        end
        if props.modFrontWheels then
            SetVehicleMod(vehicle, 23, props.modFrontWheels, false)
        end
        if props.modBackWheels then
            SetVehicleMod(vehicle, 24, props.modBackWheels, false)
        end
        if props.modCustomTiresF then
            SetVehicleMod(vehicle, 23, props.modFrontWheels, props.modCustomTiresF)
        end
        if props.modCustomTiresR then
            SetVehicleMod(vehicle, 24, props.modBackWheels, props.modCustomTiresR)
        end
        if props.modPlateHolder then
            SetVehicleMod(vehicle, 25, props.modPlateHolder, false)
        end
        if props.modVanityPlate then
            SetVehicleMod(vehicle, 26, props.modVanityPlate, false)
        end
        if props.modTrimA then
            SetVehicleMod(vehicle, 27, props.modTrimA, false)
        end
        if props.modOrnaments then
            SetVehicleMod(vehicle, 28, props.modOrnaments, false)
        end
        if props.modDashboard then
            SetVehicleMod(vehicle, 29, props.modDashboard, false)
        end
        if props.modDial then
            SetVehicleMod(vehicle, 30, props.modDial, false)
        end
        if props.modDoorSpeaker then
            SetVehicleMod(vehicle, 31, props.modDoorSpeaker, false)
        end
        if props.modSeats then
            SetVehicleMod(vehicle, 32, props.modSeats, false)
        end
        if props.modSteeringWheel then
            SetVehicleMod(vehicle, 33, props.modSteeringWheel, false)
        end
        if props.modShifterLeavers then
            SetVehicleMod(vehicle, 34, props.modShifterLeavers, false)
        end
        if props.modAPlate then
            SetVehicleMod(vehicle, 35, props.modAPlate, false)
        end
        if props.modSpeakers then
            SetVehicleMod(vehicle, 36, props.modSpeakers, false)
        end
        if props.modTrunk then
            SetVehicleMod(vehicle, 37, props.modTrunk, false)
        end
        if props.modHydrolic then
            SetVehicleMod(vehicle, 38, props.modHydrolic, false)
        end
        if props.modEngineBlock then
            SetVehicleMod(vehicle, 39, props.modEngineBlock, false)
        end
        if props.modAirFilter then
            SetVehicleMod(vehicle, 40, props.modAirFilter, false)
        end
        if props.modStruts then
            SetVehicleMod(vehicle, 41, props.modStruts, false)
        end
        if props.modArchCover then
            SetVehicleMod(vehicle, 42, props.modArchCover, false)
        end
        if props.modAerials then
            SetVehicleMod(vehicle, 43, props.modAerials, false)
        end
        if props.modTrimB then
            SetVehicleMod(vehicle, 44, props.modTrimB, false)
        end
        if props.modTank then
            SetVehicleMod(vehicle, 45, props.modTank, false)
        end
        if props.modWindows then
            SetVehicleMod(vehicle, 46, props.modWindows, false)
        end
        if props.modLivery then
            SetVehicleMod(vehicle, 48, props.modLivery, false)
            SetVehicleLivery(vehicle, props.modLivery)
        end
    end
end

-- 例

local vehicle = GetVehiclePedIsUsing(PlayerPedId())
local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle)
QBCore.Functions.SetVehicleProperties(vehicle, vehicleProps)

8章: サーバーイベントリファレンス

QBCore:Server:CloseServer

  • サーバーが閉じているかどうかを確認するイベントです。
RegisterNetEvent('QBCore:Server:CloseServer', function(reason)
    local src = source
    if QBCore.Functions.HasPermission(src, 'admin') then
        reason = reason or '理由が指定されていません'
        QBCore.Config.Server.Closed = true
        QBCore.Config.Server.ClosedReason = reason
        for k in pairs(QBCore.Players) do
            if not QBCore.Functions.HasPermission(k, QBCore.Config.Server.WhitelistPermission) then
                QBCore.Functions.Kick(k, reason, nil, nil)
            end
        end
    else
        QBCore.Functions.Kick(src, 'これに対する権限がありません。', nil, nil)
    end
end)

QBCore:Server:OpenServer

  • サーバーが開いているかどうかを確認するイベントです。
RegisterNetEvent('QBCore:Server:OpenServer', function()
    local src = source
    if QBCore.Functions.HasPermission(src, 'admin') then
        QBCore.Config.Server.Closed = false
    else
        QBCore.Functions.Kick(src, 'これに対する権限がありません。', nil, nil)
    end
end)

QBCore:UpdatePlayer

  • プレイヤーデータの更新と保存のためのイベントです。
RegisterNetEvent('QBCore:UpdatePlayer', function()
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end
    local newHunger = Player.PlayerData.metadata['hunger'] - QBCore.Config.Player.HungerRate
    local newThirst = Player.PlayerData.metadata['thirst'] - QBCore.Config.Player.ThirstRate
    if newHunger <= 0 then newHunger = 0 end
    if newThirst <= 0 then newThirst = 0 end
    Player.Functions.SetMetaData('thirst', newThirst)
    Player.Functions.SetMetaData('hunger', newHunger)
    TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, newThirst)
    Player.Functions.Save()
end)

QBCore:Server:SetMetaData

  • プレイヤーのメタデータを設定するイベントです。
RegisterNetEvent('QBCore:Server:SetMetaData', function(meta, data)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if meta == 'hunger' or meta == 'thirst' then
        if data > 100 then
            data = 100
        end
    end
    if Player then
        Player.Functions.SetMetaData(meta, data)
    end
    TriggerClientEvent('hud:client:UpdateNeeds', src, Player.PlayerData.metadata['hunger'], Player.PlayerData.metadata['thirst'])
end)

QBCore:ToggleDuty

  • プレイヤーの勤務状況を切り替えるイベントです。
RegisterNetEvent('QBCore:ToggleDuty', function()
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end
    if Player.PlayerData.job.onduty then
        Player.Functions.SetJobDuty(false)
        TriggerClientEvent('QBCore:Notify', src, Lang:t('info.off_duty'))
    else
        Player.Functions.SetJobDuty(true)
        TriggerClientEvent('QBCore:Notify', src, Lang:t('info.on_duty'))
    end
    TriggerClientEvent('QBCore:Client:SetDuty', src, Player.PlayerData.job.onduty)
end)

QBCore:CallCommand

  • チャット外からコマンドをトリガーするイベントです(例:qb-adminmenu)。
RegisterNetEvent('QBCore:CallCommand', function(command, args)
    local src = source
    if not QBCore.Commands.List[command] then return end
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end
    local hasPerm = QBCore.Functions.HasPermission(src, "command."..QBCore.Commands.List[command].name)
    if hasPerm then
        if QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and not args[#QBCore.Commands.List[command].arguments] then
            TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
        else
            QBCore.Commands.List[command].callback(src, args)
        end
    else
        TriggerClientEvent('QBCore:Notify', src, Lang:t('error.no_access'), 'error')
    end
end)

9章: サーバー関数リファレンス

プレイヤーゲッター

QBCore.Functions.GetIdentifier

プレイヤーの特定の識別子を取得します。

  • source: number
  • identifier: string (オプション)
  • return: string
local identifier = QBCore.Functions.GetIdentifier(source, 'license')
print(identifier)

-- または -- qb-coreのconfigの識別子にデフォルト設定されます

local identifier = QBCore.Functions.GetIdentifier(source)
print(identifier)

QBCore.Functions.GetSource

識別子によってプレイヤーのソースを取得します。

  • identifier: string
  • return: number
local identifier = QBCore.Functions.GetIdentifier(source, 'license')
local playerSource = QBCore.Functions.GetSource(identifier)
print(playerSource)

QBCore.Functions.GetPlayer

ソースによってプレイヤーを取得し、そのデータにアクセスします。

  • source: number | string
  • return: table
local Player = QBCore.Functions.GetPlayer(source)
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByCitizenId

市民IDによってプレイヤーを取得し、そのデータにアクセスします(オンラインである必要があります)。

  • citizenid: string
  • return: table
local Player = QBCore.Functions.GetPlayerByCitizenId('ONZ55343')
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByPhone

電話番号によってプレイヤーを取得します(オンラインである必要があります)。

  • number: number
  • return: table
local Player = QBCore.Functions.GetPlayerByPhone(6422738491)
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByAccount

口座番号によってプレイヤーを取得します(オンラインである必要があります)。

  • account: string
  • return: table
local Player = QBCore.Functions.GetPlayerByAccount('US08QBCore2345987612')
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByCharInfo

キャラクター情報によってプレイヤーを取得します(オンラインである必要があります)。

  • property: string
  • value: any
  • return: table
local Player = QBCore.Functions.GetPlayerByCharInfo('firstname', 'Kakarot')
QBCore.Debug(Player)

QBCore.Functions.GetPlayers

サーバー内のすべてのプレイヤーIDを取得します(非推奨のメソッド)。

  • return: table
local Players = QBCore.Functions.GetPlayers()
QBCore.Debug(Players)

QBCore.Functions.GetQBPlayers

サーバー上のすべてのアクティブなプレイヤーのテーブルにアクセスします(上記よりも推奨)。

  • return: table
local Players = QBCore.Functions.GetQBPlayers()
QBCore.Debug(Players)

QBCore.Functions.GetPlayersOnDuty

特定のジョブで勤務中のプレイヤーIDのテーブルとその数を取得します。

  • job: string
  • return: table , number
local Players, Amount = QBCore.Functions.GetPlayersOnDuty('police')
print(QBCore.Debug(Players))
print('現在 '..tostring(Amount)..' 人の警察がオンラインです')

QBCore.Functions.GetDutyCount

特定のジョブで勤務中のプレイヤーの数を取得します。

  • job: string
  • return: number
local amount = QBCore.Functions.GetDutyCount('police')
print('現在 '..tostring(amount)..' 人の警察がオンラインです')

ワールドゲッター

QBCore.Functions.GetCoords

渡されたエンティティの座標を取得します。

  • entity: number
  • return: vector4
local ped = GetPlayerPed(source)
local coords = QBCore.Functions.GetCoords(ped)
print(coords)

QBCore.Functions.GetClosestObject

ワールド内のプレイヤーに最も近いオブジェクトとその距離を取得します。

  • source: string
  • coords: vector3 (オプション)
  • return: number |number
local ped = GetPlayerPed(source)
local location = GetEntityCoords(ped)
local objectHandle, distance = QBCore.Functions.GetClosestObject(source, location)
print('最も近いオブジェクト:', objectHandle, '距離:', distance)

QBCore.Functions.GetClosestVehicle

ワールド内のプレイヤーに最も近い車両とその距離を取得します。

  • source: string
  • coords: vector3 (オプション)
  • return: number |number
local ped = GetPlayerPed(source)
local location = GetEntityCoords(ped)
local vehicle, distance = QBCore.Functions.GetClosestVehicle(source, location)
print('最も近い車両:', vehicle, '距離:', distance)

QBCore.Functions.GetClosestPed

ワールド内のプレイヤーに最も近い歩行者とその距離を取得します。

  • source: string
  • coords: vector3 (オプション)
  • return: number |number
local ped = GetPlayerPed(source)
local coords = GetEntityCoords(ped)
local closestPed, distance = QBCore.Functions.GetClosestPed(source, coords)
print('最も近い歩行者:', closestPed, '距離:', distance)

車両作成

QBCore.Functions.SpawnVehicle

標準のクライアント支援CreateVehicleRPCを使用して、プレイヤーの近くに車両をスポーンさせます。車両が表示されるには、クライアントがスポーン場所の近くにいる必要があります。

  • source: string
  • model: string|number
  • coords: vector3 (オプション)
  • warp: boolean (オプション)
  • return: number
local veh = QBCore.Functions.SpawnVehicle(source, "sultan")
print("スポーンした車両:", veh)

QBCore.Functions.CreateAutomobile

実験的なCREATE_AUTOMOBILEネイティブを使用して車両をスポーンさせます。これは作成にクライアントに依存しません。これはより効率的ですが、すべての車種で機能するわけではありません

  • source: string
  • model: string|number
  • coords: vector3 (オプション)
  • warp: boolean (オプション)
  • return: number
local veh = QBCore.Functions.CreateAutomobile(source, "sultan")
print("作成された自動車:", veh)

QBCore.Functions.CreateVehicle

新しいCreateVehicleServerSetterネイティブを使用して、サーバー上で車両をスポーンさせます。より信頼性が高く、すべての主要な車種をサポートしています。

  • source: string
  • model: string|number
  • vehType: string
  • coords: vector3 (オプション)
  • warp: boolean (オプション)
  • return: number
local veh = QBCore.Functions.CreateVehicle(source, "sultan", "automobile")
print("サーバーセッターで作成された車両:", veh)

ルーティングバケット

QBCore.Functions.GetBucketObjects

フレームワークで使用される内部バケット状態テーブルを返します。

  • return: table, table
local playerBuckets, entityBuckets = QBCore.Functions.GetBucketObjects()
QBCore.Debug(playerBuckets)
QBCore.Debug(entityBuckets)

QBCore.Functions.GetPlayersInBucket

指定されたバケットに割り当てられたプレイヤーIDのリストを返します。

  • bucket: number
  • return: table | boolean
local players = QBCore.Functions.GetPlayersInBucket(3)
if players then
    print("バケット3のプレイヤー:", json.encode(players))
end

QBCore.Functions.GetEntitiesInBucket

指定されたバケットに割り当てられたエンティティID(プレイヤーを除く)のリストを返します。

  • bucket: number
  • return: table | boolean
local entities = QBCore.Functions.GetEntitiesInBucket(3)
if entities then
    print("バケット3のエンティティ:", json.encode(entities))
end

QBCore.Functions.SetEntityBucket

エンティティ(歩行者、車両、小道具など)を指定されたルーティングバケットに割り当てます。

  • entity: number
  • bucket: number
  • return: boolean
local entity = GetVehiclePedIsIn(GetPlayerPed(source), false)
local success = QBCore.Functions.SetEntityBucket(entity, 3)
if success then
    print("エンティティがバケット3に移動しました")
end

QBCore.Functions.SetPlayerBucket

プレイヤーを指定されたルーティングバケットに割り当てます。

  • source: string
  • bucket: number
  • return: boolean
local success = QBCore.Functions.SetPlayerBucket(source, 3)
if success then
    print("プレイヤーがバケット3に移動しました")
end

アイテム

QBCore.Functions.CreateUseableItem

アイテムを「使用可能」として登録し、コールバック関数にバインドします。

  • item: string
  • data: function | table
QBCore.Functions.CreateUseableItem("my_cool_item", function(source, item)
	local Player = QBCore.Functions.GetPlayer(source)
	if not Player.Functions.GetItemByName(item.name) then return end
	-- アイテムがすべきことのコードをここにトリガーします
end)

QBCore.Functions.CanUseItem

指定されたアイテムが使用可能として登録されているかどうかを確認します。

  • item: string
  • return: table | nil
if QBCore.Functions.CanUseItem("my_cool_item") then
    print("my_cool_itemは使用可能なアイテムです")
end

QBCore.Functions.UseItem

プレイヤーでアイテムを使用するようにトリガーします。

  • source: string
  • item: string
local Player = QBCore.Functions.GetPlayer(source)
if not Player.Functions.GetItemByName('my_cool_item') then return end
QBCore.Functions.UseItem(source, 'my_cool_item')

QBCore.Functions.HasItem

プレイヤーが特定のアイテムを持っているかどうかを確認します。

  • source: string
  • items: string | table
  • amount: number (オプション)
  • return: boolean
if QBCore.Functions.HasItem(source, "radio") then
    print("プレイヤーはラジオを持っています")
end

if QBCore.Functions.HasItem(source, { "radio", "id_card" }) then
    print("プレイヤーはラジオとIDの両方を持っています")
end

if QBCore.Functions.HasItem(source, { radio = 1, bandage = 3 }) then
    print("プレイヤーはラジオ1つと包帯3つを持っています")
end

権限

QBCore.Functions.AddPermission

プレイヤーに特定の権限レベルを付与します(セッション中のみ)。

  • source: string
  • permission: string
local Player = QBCore.Functions.GetPlayer(playerId)
if not Player then return end
local permission = 'admin'
QBCore.Functions.AddPermission(Player.PlayerData.source, permission)

QBCore.Functions.RemovePermission

特定の権限レベルまたはプレイヤーのすべての権限を削除します(セッション中のみ)。

  • source: string
  • permission: string (オプション)
local Player = QBCore.Functions.GetPlayer(playerId)
if not Player then return end
local permission = 'admin'
QBCore.Functions.RemovePermission(Player.PlayerData.source, permission)

QBCore.Functions.HasPermission

プレイヤーが特定の権限レベルを持っているかどうかを確認します。

  • source: string
  • permission: string | table
if QBCore.Functions.HasPermission(source, "admin") then
    print("プレイヤーは管理者です")
end

QBCore.Functions.GetPermission

プレイヤーの権限レベルを取得します。

  • source: string
  • return: table
local permissions = QBCore.Functions.GetPermission(source)
QBCore.Debug(permissions)

QBCore.Functions.IsOptIn

プレイヤーがレポートの受信をオプトインしているかどうかを確認します。

  • source: string
  • return: boolean
if QBCore.Functions.IsOptin(source) then
    print("プレイヤーはレポートを受信します")
end

QBCore.Functions.ToggleOptIn

プレイヤーのレポート受信ステータスを切り替えます。

  • source: string
QBCore.Functions.ToggleOptin(source)

コールバック

QBCore.Functions.TriggerClientCallback

サーバーからクライアント側のコールバック関数をトリガーします。プロミスを介した非同期使用と、直接の関数ベースの応答処理の両方をサポートします。

  • name: string
  • source: string
  • cb: function (オプション)
  • ...: any
CreateThread(function()
    local playerData = QBCore.Functions.TriggerClientCallback("resourceName:testCallback", source)
    print(playerData)
end)

-- または

QBCore.Functions.TriggerClientCallback("resourceName:testCallback", source, function(data)
    print("クライアントから受信:", data)
end)

QBCore.Functions.CreateCallback

クライアントからトリガーできる新しいサーバー側コールバックを登録します。

  • name: string
  • cb: function
QBCore.Functions.CreateCallback("resourceName:testCallback", function(source, cb)
    local Player = QBCore.Functions.GetPlayer(source)
    cb(Player)
end)

その他

QBCore.Functions.Notify

特定のプレイヤーに通知をトリガーします。

  • source: string
  • text: string
  • type: string (オプション)
  • length: number (オプション)
QBCore.Functions.Notify(source, '成功しました!', 'success', 5000)

QBCore.Debug

テーブルまたは値のフォーマットされ、色分けされたデバッグ出力を表示します。

  • table: table | any
  • indent: number (オプション)
  • resource: string
local data = {
    name = "John",
    isAdmin = true,
    stats = {
        health = 100,
        stamina = 75,
    }
}

QBCore.Debug(data)

QBCore.ShowError

コンソールに赤色でエラーログを表示します。

  • resource: string
  • message: string
QBCore.ShowError('qb-core', 'エラー!')

QBCore.ShowSuccess

コンソールに緑色で成功/ログメッセージを表示します。

  • resource: string
  • message: string
QBCore.ShowSuccess('qb-core', '成功!')

QBCore.Functions.Kick

サーバーからプレイヤーをキックします。

  • playerId: string
  • reason: string
  • setKickReason: function (オプション)
  • deferrals: table (オプション)
QBCore.Functions.Kick(playerId, "エクスプロイトが検出されました")

10章: コマンドリファレンス

QBCore.Commands.Add

この関数を使用すると、指定したユーザーレベルでコマンドを登録できます。

QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
  • name: string
  • help: string
  • arguments: table
  • argsrequired: boolean
  • callback: function
  • permission: string

例:

local arguments = {
    { name = 'arg 1', help = 'argが何のためのものかについてのヒントを与えます' },
    { name = 'arg 2', help = 'argが何のためのものかについてのヒントを与えます' }
}

local argsRequired = true -- これがtrueの場合、引数を入力しないとコマンドは機能しません

QBCore.Commands.Add('test', 'テストコマンドをトリガーする', arguments, argsRequired, function(source)
    print('おめでとうございます、誰でもトリガーできるテストコマンドを作成しました!')
end, 'user')

QBCore.Commands.Refresh

この関数は、すべてのコマンドの提案を更新します。これは、権限をより高いレベルに設定するときに役立ち、プレイヤーがアクセスできるようになった新しいコマンドを確認できるように提案リストを更新します。

QBCore.Commands.Refresh(source)
  • source: number

例:

RegisterCommand('refreshCommands', function()
    QBCore.Commands.Refresh(source)
    print('すべてのコマンドの提案を更新しました')
end, true)

AdminMenu

/admin - 管理者メニューを開きます

管理者メニューを開きます

権限レベル: admin

/blips - プレイヤーブリップを切り替えます

すべてのプレイヤーのマップにブリップを追加します。プレイヤーの位置を監視するのに役立ちます。

権限レベル: admin

/names - プレイヤー名を切り替えます

頭上にプレイヤー名とIDを表示します

権限レベル: admin

/coords - 現在の座標を表示します

現在の座標をvector3(x, y, z)形式で表示します

権限レベル: admin

/maxmods - 車両を最大改造に設定します

現在の車両に最大のパフォーマンス改造を施します

権限レベル: admin

/noclip - noclipを切り替えます

noclipを切り替えます

権限レベル: admin

/admincar - 現在の車両をガレージに追加します

現在の車両をデータベーステーブルplayer_vehiclesに保存し、ガレージで車両にアクセスできるようにします

権限レベル: admin

/announce [message] - アナウンスを作成します

チャットですべてのプレイヤーに送信されるアナウンスを作成します。

権限レベル: admin

  • message - (必須) 送信するメッセージ
/report [message] - スタッフにレポートを作成します

チャットでスタッフにメッセージを送信し、メッセージをレポートとして保存します

権限レベル: user

  • message - (必須) 送信するメッセージ
/reportr [message] - ユーザーレポートに返信します

指定されたmessageでユーザーレポートに返信します

権限レベル: admin

  • message - (必須) 返信で送信するメッセージ
/reporttoggle - プレイヤーレポートの受信をオプトイン/アウトします

チャットでのプレイヤーレポートの受信をオプトイン/アウトします

権限レベル: admin

/staffchat [message] - スタッフ専用メッセージを送信します

'admin'権限レベルを持つユーザーにのみ表示されるチャットメッセージを送信します

権限レベル: admin

  • message - (必須) 送信するメッセージ
/warn [id] [reason] - プレイヤーに警告します

指定されたidのプレイヤーに、指定されたreasonでメッセージを送信します。また、データベーステーブルplayer_warnsにプレイヤーに対する警告を追加します

権限レベル: admin

  • id - (必須) 警告されるプレイヤーのID
  • reason - (必須) 警告する理由
/checkwarns [id] [opt: number] - 特定のプレイヤーの警告を表示します

指定されたidのプレイヤーに対する既存の警告を確認します。コマンドで警告番号が指定されていない場合は、プレイヤーが受け取った警告の数を表示します。コマンドで警告番号が指定されている場合は、その警告を表示します。

権限レベル: admin

  • id - (必須) 確認するプレイヤーのID
  • number - (オプション) 警告番号 (1, 2, 3, etc...)
/delwarn [id] [number] - プレイヤーから警告を削除します

プレイヤーから警告を削除し、データベースエントリを削除します

権限レベル: admin

  • id - (必須) プレイヤーのID
  • number - (必須) 削除する警告番号 (1, 2, 3 etc...)
/givenuifocus [id] [hasFocus] [hasCursor] - プレイヤーのnuifocus状態を設定します

このコマンドは、指定されたidのプレイヤーのNUIフォーカス状態を設定します。これにより、次のネイティブを手動で設定できます: https://docs.fivem.net/natives/?_0x5B98AE30
プレイヤーがNUIオーバーレイで動けなくなった場合に便利です。

権限レベル: admin

  • id - (必須) プレイヤーのID
  • hasFocus - (必須) [true/false] NUIにフォーカスがあるかどうか
  • hasCursor - (必須) [true/false] NUI使用時にプレイヤーにカーソルがあるかどうか
/setmodel [model] [id] - プレイヤーのpedモデルを変更します

指定されたidのプレイヤーのpedmodelを変更します。

権限レベル: admin

  • model - (必須) 変更するpedモデル
  • id - (必須) pedモデルが変更されるプレイヤーのID
/setspeed [opt: speed] - プレイヤーの歩行速度を設定します

歩行速度をデフォルトと「高速」の間で設定します

権限レベル: admin

  • speed - (オプション) ["fast"] は歩行速度を「高速」に設定します。この引数を空白のままにすると、歩行速度は「通常」に設定されます
/kickall - すべてのプレイヤーをサーバーからキックします

すべてのプレイヤーをサーバーからキックします。

権限レベル: god

/setammo [amount] [opt: weapon] - 武器の弾薬を設定します

手に持っている現在の銃または指定されたweaponの弾薬量を設定します

権限レベル: admin

  • amount - (必須) 設定する弾薬の量
  • weapon - (オプション) 弾薬を設定する武器。空白のままにすると、手に持っている現在の銃の弾薬が設定されます
/vector2 - vector2をクリップボードにコピーします

現在の座標のvector2(x, y)をクリップボードにコピーします。

権限レベル: admin

/vector3 - vector3をクリップボードにコピーします

現在の座標のvector3(x, y, z)をクリップボードにコピーします

権限レベル: admin

/vector4 - vector4をクリップボードにコピーします

現在の座標のvector4(x, y, z, w)をクリップボードにコピーします

権限レベル: admin

/heading - ヘディングをコピーします

現在のヘディング(向いている方向)のヘディングwをクリップボードにコピーします

権限レベル: admin

Core

/tp [id / x] [opt: y] [opt: z]- プレイヤーまたは場所にテレポートします

指定されたidのプレイヤーまたは指定されたx, y, zの場所にテレポートします

権限レベル: admin

  • id or x - (必須) プレイヤーIDまたはx座標
  • y - (オプション) y座標(最初の引数にxを使用する場合は必須)
  • z - (オプション) z座標(最初の引数にxを使用する場合は必須)
/tpm - マークされた場所にテレポートします

マップ上のマークされた場所にテレポートします。

権限レベル: admin

/togglepvp - サーバーでPVPを切り替えます

サーバーでプレイヤー対プレイヤーモードを切り替えます

権限レベル: admin

/addpermission [id] [permission] - プレイヤーに権限を与えます

指定されたidのプレイヤーに、指定されたpermissionレベルを与えます。プレイヤーはオンラインである必要があります。

権限レベル: god

/removepermission [id] [permission] - プレイヤーの権限を削除します

指定されたidのプレイヤーから、指定されたpermissionを削除します。プレイヤーはオンラインである必要があります。

権限レベル: god

/openserver - 誰でもサーバーを開きます

サーバーを開き、誰でも参加できるようにします。

権限レベル: admin

/closeserver [reason] - 権限のない人に対してサーバーを閉じます

適切な権限のない人に対してサーバーを閉じます。キックメッセージにreasonを指定して、現在オンラインで必要な権限のないプレイヤーをキックします。

権限レベル: admin

/car [model] - 車両をスポーンさせます

指定されたmodelタイプの車両をスポーンさせます。

権限レベル: admin

/dv - 車両を削除します

座っている車両を削除するか、現在地から5.0ユニット以内のすべての車両を削除します。

権限レベル: admin

/givemoney [id] [type] [amount] - プレイヤーにお金を与えます

プレイヤーにお金を与えます

権限レベル: admin

  • id - (必須) プレイヤーのid
  • type - (必須) お金のタイプ [cash, bank etc...]
  • amount - (必須) 与える金額
/setmoney [id] [type] [amount] - プレイヤーが持っているお金の額を設定します

プレイヤーが持っているお金の額を設定します。

権限レベル: admin

  • id - (必須) プレイヤーのid
  • type - (必須) お金のタイプ [cash, bank etc...]
  • amount - (必須) 設定する金額
/job - 現在の仕事を表示します

現在の仕事名と等級を表示します

権限レベル: user

/setjob [id] [job] [grade] - プレイヤーの仕事を設定します

指定されたidのプレイヤーに、指定されたgradeで指定されたjobを設定します

権限レベル: admin

  • id - (必須) プレイヤーのid
  • job - (必須) 仕事名
  • grade - (必須) 仕事の等級
/gang - 現在のギャングを表示します

現在のギャング名と等級を表示します

権限レベル: user

/setgang [id] [gang] [grade] - プレイヤーのギャングを設定します

指定されたidのプレイヤーを、指定されたgradeで指定されたgangの一員に設定します

権限レベル: admin

  • id - (必須) プレイヤーのid
  • gang - (必須) ギャング名
  • grade (必須) ギャングの等級
/clearinv [opt: id]- プレイヤーのインベントリをクリアします

指定されたidのプレイヤーのインベントリ、またはidが指定されていない場合は自分のインベントリをクリアします

権限レベル: admin

  • id - (オプション) プレイヤーのID
/ooc [message] - oocチャットコマンド

キャラクター外(ooc)メッセージをチャットに送信します。

権限レベル: user

  • message - (必須) 送信するメッセージ
/me [message] - 頭上にメッセージを表示します

頭上に3Dテキストメッセージを表示します。ロールプレイを向上させるのに役立ちます。

権限レベル: user

  • message - (必須) 表示するメッセージ

Ambulancejob

/911e [message] - EMSにメッセージを送信します

'ambulance'の仕事を持つEMSプレイヤーにメッセージを送信します。

権限レベル: user

  • message - (必須) 送信するメッセージ
/status - 最も近いプレイヤーの状態を確認します

最も近いプレイヤーを見つけて、その健康状態を確認します

権限レベル: user

/heal - 最も近いプレイヤーを回復させます

最も近いプレイヤーを見つけて回復させます

権限レベル: user

/revivep - 最も近いプレイヤーを蘇生させます

最も近いプレイヤーを見つけて蘇生させます

権限レベル: user

/revive - 自分を蘇生させます

自分を全回復させます

権限レベル: admin

/setpain [opt: id] - プレイヤーに痛みレベルを設定します

指定されたidのプレイヤー、またはIDが指定されていない場合は自分自身に痛みレベルを設定します。

権限レベル: admin

/kill [opt: id] - プレイヤーを殺します

指定されたidのプレイヤーを殺すか、IDが指定されていない場合は自分自身を殺します。

権限レベル: admin

  • id - (オプション) プレイヤーID
/aheal [opt: id] - プレイヤーを回復させます

指定されたidのプレイヤーを回復させるか、IDが指定されていない場合は自分自身を回復させます。

権限レベル: admin

  • id - (オプション) プレイヤーID

Police

/911p [message] - 警察にアラートを送信します

このコマンドは、'police'の仕事を持つすべてのプレイヤーにアラートを送信します。アラートには指定されたmessageが含まれ、警察プレイヤーのマップの現在地にブリップが追加されます。

権限レベル: user

  • message - (必須) アラートで送信するメッセージ
/spikestrip - スパイクストリップを設置します

地面にスパイクストリップオブジェクトを設置します。プレイヤーは'police'の仕事を持ち、勤務中である必要があります。

権限レベル: user

/grantlicense [id] [license] - プレイヤーにライセンスを与えます

指定されたidのプレイヤーに、指定されたlicenseタイプのライセンスを与えます。

このコマンドは、Config.LicenseRankで設定された最低等級(デフォルトは等級2以上)を超える'police'の仕事を持つプレイヤーのみが使用できます。

権限レベル: user

  • id - (必須) プレイヤーのID
  • license - (必須) ライセンスタイプ(例:「weapon」または「driver」)
/revokelicense [id] [license] - プレイヤーのライセンスを取り消します

指定されたidのプレイヤーから、指定されたlicenseタイプのライセンスを削除します。

このコマンドは、Config.LicenseRankで設定された最低等級(デフォルトは等級2以上)を超える'police'の仕事を持つプレイヤーのみが使用できます。

権限レベル: user

  • id - (必須) プレイヤーのID
  • license - (必須) ライセンスタイプ(例:「weapon」または「driver」)
/pobject [type] - 警官がオブジェクトをスポーンできるようにします

'police'の仕事を持つプレイヤーがオブジェクトをスポーンできるようにします

権限レベル: user

  • type - (必須) オブジェクトタイプ。利用可能なタイプ:
    • cone - トラフィックコーン
    • barrier - 道路封鎖バリア
    • roadsign - 道路標識
    • tent - 犯罪現場用のガゼボ
    • light - 作業灯
    • delete - オブジェクトを削除
/cuff - 最も近いプレイヤーに手錠をかけます

このコマンドは、最も近いプレイヤーにハードカフをかけます(移動を妨げます)。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/sc - 最も近いプレイヤーにソフトカフをかけます

このコマンドは、最も近いプレイヤーにソフトカフをかけます(移動を許可します)。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/escort - 最も近いプレイヤーを護衛します

このコマンドは、最も近いプレイヤーを護衛します。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/callsign [name] - 警官がコールサインを設定できるようにします

'police'の仕事を持つプレイヤーがコールサインを設定できるようにします。コールサインは、マップ上のプレイヤーのブリップの名前として表示されます。

権限レベル: user

  • name - (必須) 使用するコールサイン
/jail - 最も近いプレイヤーを刑務所に送ります

このコマンドは、最も近いプレイヤーを刑務所に送ります。メニューが開き、警官が収監時間を設定できます。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/unjail [id] - プレイヤーを釈放します

指定されたidのプレイヤーを釈放します

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

  • id - (必須) プレイヤーのID
/clearcasings - エリア内の薬莢をクリアします

現在地から10.0ユニット以内の薬莢をクリアします。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/clearblood - エリア内の血痕をクリアします

現在地から10.0ユニット以内の血痕をクリアします。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/seizecash - 最も近いプレイヤーから現金を没収します

最も近いプレイヤーから現金を没収します。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/cam [id] - 警官が選択した場所からのカメラ映像を見ることができます

'police'の仕事を持つプレイヤーが防犯カメラを見ることができます。防犯カメラの場所は、qb-policejobのconfigファイルで設定できます。Config.SecurityCamerasを参照してください。

権限レベル: user

  • id - (必須) カメラのID
/flagplate [plate] [reason] - スピードカメラがフラグ付きプレートを見つけられるようにします

configで設定できるスピードカメラが、フラグ付きプレートを見つけられるようにします。Config.Radarsを参照してください

権限レベル: user

  • plate - (必須) フラグを立てるプレート
  • reason - (必須) フラグの理由
/unflagplate [plate] - プレートからフラグを削除します

プレートのフラグを削除して、カメラがプレートを検出しないようにします。

権限レベル: user

  • plate - (必須) フラグを解除するプレート
/plateinfo [plate] - プレートの情報を表示します

プレートにフラグが立っているかどうかを表示し、そうであれば理由を示します。

権限レベル: user

  • plate - (必須) 確認するプレート
/depot [price] - 警官が車両を価格で押収できるようにします

'police'の仕事を持つプレイヤーが、指定されたpriceで車両を押収所に送ることができます

権限レベル: user

  • price - (必須) 車両をデポから引き出すために設定された価格
/impound - 価格なしで車両を押収します

価格なしで車両を押収します

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/tow [id] - レッカー車の運転手に500ドルを支払います

指定されたidのプレイヤーに500ドルを支払います。支払いを受けるプレイヤーは'tow'の仕事を持っている必要があります。

権限レベル: user

  • id - (必須) 支払いを受けるプレイヤーのID
/paylawyer [id] - 弁護士に500ドルを支払います

指定されたidのプレイヤーに500ドルを支払います。支払いを受けるプレイヤーは'lawyer'の仕事を持っている必要があります。

権限レベル: user

  • id - (必須) 支払いを受けるプレイヤーのID
/anklet - 最も近いプレイヤーに追跡装置を追加します

最も近いプレイヤーに追跡装置を追加します。

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/ankletlocation [cid] - プレイヤーの場所を表示します

指定されたcidのプレイヤーの場所を表示します

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

  • cid - (必須) 確認するプレイヤーの市民ID
/takedrivinglicense - プレイヤーの運転免許証を取得します

最も近いプレイヤーの運転免許証を取得します

'police'の仕事を持つプレイヤーのみが使用できます

権限レベル: user

/takedna [id] - プレイヤーのDNAを取得します

指定されたidのプレイヤーのDNAを取得します。空の証拠袋が必要です。

権限レベル: user

  • id - (必須) プレイヤーのID

Banking

  • /givecash - プレイヤーに現金を渡します

Cityhall

  • /drivinglicense - 運転免許試験後にプレイヤーに免許を与えます

Binds

  • /binds - カスタムキーバインドを設定できます

Diving

  • /divingsuit - ダイビングスーツを使用します

Doorlock

  • /newdoor - 新しいドアを作成するためのUIを開きます
  • /doordebug - ドアロックのデバッグ

Drugs

  • /newdealer - 場所(家の玄関)に新しいディーラーを作成します
  • /deletedealer - 保存されたディーラーを削除します
  • /dealers - ディーラーに関する情報のリストを表示します
  • /dealergoto - ディーラーにテレポートします

Garbage

  • /cleargarbroutes - ユーザーのゴミ収集ルートを削除します

Hotdogjob

  • /removestand - ホットドッグスタンドを削除します

Housing

  • /decorate - 装飾メニュー/オプションを開きます
  • /createhouse - 場所に家を作成します
  • /addgarage - 場所にガレージを追加します
  • /ring - 場所のドアベルを鳴らします

Hud

  • /cash - 現在の現金残高を表示します
  • /bank - 現在の銀行残高を表示します
  • /dev - 開発者アイコンを表示します

Inventory

  • /resetinv - 隠し場所/トランク/グローブボックスのインベントリをリセットします
  • /rob - 最も近いプレイヤーを強盗します
  • /giveitem - プレイヤーにアイテムを与えます
  • /randomitems - プレイヤーにランダムなアイテムを与えます

Lapraces

  • /cancelrace - 現在のレースをキャンセルします
  • /togglesetup - レース設定のオン/オフを切り替えます

Mechanicjob

  • /setvehiclestatus - 車両の状態を設定します
  • /setmechanic - 誰かに整備士の仕事を与えます
  • /firemechanic - 整備士を解雇します

Multicharacter

  • /logout - 現在のキャラクターからログアウトします
  • /closeNUI - マルチキャラクターNUIを閉じます

Newsjob

  • /newscam - プレイヤーにニュースカメラを与えます
  • /newsmic - プレイヤーにニュースマイクを与えます
  • /newsbmic - プレイヤーにブームマイクを与えます

Phone

  • /setmetadata - プレイヤーのメタデータを設定します
  • /bill - プレイヤーに請求書/請求書を送信します

RadialMenu

  • /getintrunk - トランクに入ります
  • /putintrunk - プレイヤーをトランクに入れます(誘拐)

Smallresources

  • /resetarmor - アーマーをリセットします
  • /resetparachute - パラシュートをリセットします
  • /testwebhook - ログのWebhookが機能しているかどうかをテストします
  • /id - IDを表示します

Streetrace

  • /createrace - ストリートレースを開始します
  • /stoprace - 現在のストリートレースを停止します
  • /quitrace - 現在のストリートレースを終了します
  • /startrace - 現在のストリートレースを開始します

Towjob

  • /npc - NPCからのレッカー車の仕事を切り替えます
  • /tow - 最も近い車両をフラットベッドに載せます(トラックの後ろにある必要があります)

Traphouse

  • /multikeys - 別のプレイヤーにキーを与えます

Vehiclefailure

  • /fix - 現在の車両を修理します

Vehiclekeys

  • /engine - エンジンのオン/オフを切り替えます
  • /givekeys - プレイヤーにキーを与えます
  • /addkeys - そのプレイヤーにキーを追加します
  • /removekeys - プレイヤーからキーを削除します

Vehicleshop

  • /transferVehicle - 車両を誰かに贈与または売却します

Weapons

  • /repairweapon - 武器を修理します
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?