【qb-core】オリジナルアイテムを追加したい!!!!!!!人へ。
こんにちわん。
なんか...元日に地震がきて焦りましたね...
...というわけで切り替えて、「オリジナルアイテム」を追加しよう!の回です。
多分7分で終わります。7分。
- アイテム画像の作成
フリー画像サイトから100 x 100の画像を作成しましょう!
画像はqb-inventory > html > imagesに挿入してください。
- qb-core > items.lua の編集
これはできる...よね?
['アイテム名ローマ字'] = {['name'] = 'アイテム名ローマ字', ['label'] = '表記名', ['weight'] = 重さ(数字で), ['type'] = 'item', ['image'] = '画像.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = '説明'},
以下例
['anpan'] = {['name'] = 'anpan', ['label'] = 'アンパン名', ['weight'] = 100, ['type'] = 'item', ['image'] = 'anpan.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'おいしいアンパンだぜぇ~!'},
- qb-smallresources > config.lua の編集
これはゲージの回復量を設定するための編集です。
食べ物の場合はConsumeablesEat、飲み物はConsumeablesDrinkに挿入してください。
["アイテム名"] = math.random(35, 54),
math.randomはランダム値を返すので(上記だと35~54の間でランダム)、その分空腹度ゲージが上がります。
math.randomはよく使われてるので意味を知っておくだけでもいいと思います。
- qb-smallresources > consumables.lua の編集
これは使用した際にアイテムが減るように設定するための編集です。
QBCore.Functions.CreateUseableItem("アイテム名", function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if Player.Functions.RemoveItem(item.name, 1, item.slot) then
TriggerClientEvent("consumables:client:Eat", source, item.name)
end
end)
コメント
コメントを投稿