💬 テキストを描く
[!NOTE] 許容される位置: 左、右、上
| Function または Event | 説明 |
|---|---|
| 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) | エクスポートと同じですが、イベントとして実行されます |
テキストを非表示
- Function は現在表示されているテキストを非表示にします
-- Source code for reference
local function hideText()
SendNUIMessage({
action = 'HIDE_TEXT',
})
end
exports('HideText', hideText)
-- Export example
local function examplefunction()
exports['qb-core']:DrawText('This is a test', 'left')
Wait(5000) -- display text for 5 seconds
exports['qb-core']:HideText()
end
-- Client example
local function examplefunction()
TriggerEvent('qb-core:client:DrawText', 'This is a test', 'left')
Wait(5000) -- display text for 5 seconds
TriggerEvent('qb-core:client:HideText')
end
-- Server example
local function examplefunction()
TriggerClientEvent('qb-core:client:DrawText', source, 'This is a test', 'left')
Wait(5000) -- display text for 5 seconds
TriggerClientEvent('qb-core:client:HideText', source)
endテキスト描画
- 画面にテキストを描画するための Function
-- Source code for reference
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)
-- Export example
local function examplefunction()
exports['qb-core']:DrawText('This is a test', 'left')
Wait(5000) -- display text for 5 seconds
exports['qb-core']:HideText()
end
-- Client example
local function examplefunction()
TriggerEvent('qb-core:client:DrawText', 'This is a test', 'left')
Wait(5000) -- display text for 5 seconds
TriggerEvent('qb-core:client:HideText')
end
-- Server example
local function examplefunction()
TriggerClientEvent('qb-core:client:DrawText', source, 'This is a test', 'left')
Wait(5000) -- display text for 5 seconds
TriggerClientEvent('qb-core:client:HideText', source)
endテキストの変更
- Function は現在表示されているテキストを変更する
-- Source code for reference
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)
-- Export example
local function examplefunction()
exports['qb-core']:DrawText('This is a test', 'left')
Wait(5000) -- change text after 5 seconds
exports['qb-core']:ChangeText('This is your changed text', 'left')
Wait(5000) -- display changed text for 5 seconds
exports['qb-core']:HideText()
end
-- Client example
local function examplefunction()
TriggerEvent('qb-core:client:DrawText', 'This is a test', 'left')
Wait(5000) -- change text after 5 seconds
TriggerEvent('qb-core:client:ChangeText', 'This is your changed text', 'left')
Wait(5000) -- display changed text for 5 seconds
TriggerEvent('qb-core:client:HideText')
end
-- Server example
local function examplefunction()
TriggerClientEvent('qb-core:client:ChangeText', source, 'This is your changed text', 'left')
endキーが押された
- キーを押すとアニメーションを表示し、現在表示されているテキストを非表示にするオプション機能
-- Source code for reference
local function keyPressed()
CreateThread(function()
SendNUIMessage({
action = 'KEY_PRESSED',
})
Wait(500)
hideText()
end)
end
exports('KeyPressed', keyPressed)
-- Export example
CreateThread(function()
local textDrawn = false
while true do
Wait(0)
if not textDrawn then
exports['qb-core']:DrawText('This is a test','left')
textDrawn = true
end
if IsControlJustPressed(0, 38) then
exports['qb-core']:KeyPressed()
end
end
end)
-- Client example
CreateThread(function()
local textDrawn = false
while true do
Wait(0)
if not textDrawn then
TriggerEvent('qb-core:client:DrawText', 'This is a test','left')
textDrawn = true
end
if IsControlJustPressed(0, 38) then
TriggerEvent('qb-core:client:KeyPressed')
end
end
end)Last updated on