This is a client export that will change the currently displayed message at the specified position (listed below)
exports['qb-core']:HideText()
This will hide the text display
exports['qb-core']:KeyPressed()
This is useful if you want to change the background and hide the text on keypress (if not handled correctly users will have to renter the zone to display)
-- Source code for referencelocalfunctionhideText()SendNUIMessage({ action ='HIDE_TEXT', })endexports('HideText', hideText)-- Export examplelocalfunctionexamplefunction() exports['qb-core']:DrawText('This is a test', 'left')Wait(5000) -- display text for 5 seconds exports['qb-core']:HideText()end-- Client examplelocalfunctionexamplefunction()TriggerEvent('qb-core:client:DrawText', 'This is a test', 'left')Wait(5000) -- display text for 5 secondsTriggerEvent('qb-core:client:HideText')end-- Server examplelocalfunctionexamplefunction()TriggerClientEvent('qb-core:client:DrawText', source, 'This is a test', 'left')Wait(5000) -- display text for 5 secondsTriggerClientEvent('qb-core:client:HideText', source)end
DrawText
Function to draw the text on the screen
-- Source code for referencelocalfunctiondrawText(text,position)ifnottype(position) =="string" then position ="left" endSendNUIMessage({ action ='DRAW_TEXT', data = { text = text, position = position } })endexports('DrawText', drawText)-- Export examplelocalfunctionexamplefunction() exports['qb-core']:DrawText('This is a test', 'left')Wait(5000) -- display text for 5 seconds exports['qb-core']:HideText()end-- Client examplelocalfunctionexamplefunction()TriggerEvent('qb-core:client:DrawText', 'This is a test', 'left')Wait(5000) -- display text for 5 secondsTriggerEvent('qb-core:client:HideText')end-- Server examplelocalfunctionexamplefunction()TriggerClientEvent('qb-core:client:DrawText', source, 'This is a test', 'left')Wait(5000) -- display text for 5 secondsTriggerClientEvent('qb-core:client:HideText', source)end
ChangeText
Function to change the currently displayed text
-- Source code for referencelocalfunctionchangeText(text,position)ifnottype(position) =="string" then position ="left" endSendNUIMessage({ action ='CHANGE_TEXT', data = { text = text, position = position } })endexports('ChangeText', changeText)-- Export examplelocalfunctionexamplefunction() 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 examplelocalfunctionexamplefunction()TriggerEvent('qb-core:client:DrawText', 'This is a test', 'left')Wait(5000) -- change text after 5 secondsTriggerEvent('qb-core:client:ChangeText', 'This is your changed text', 'left')Wait(5000) -- display changed text for 5 secondsTriggerEvent('qb-core:client:HideText')end-- Server examplelocalfunctionexamplefunction()TriggerClientEvent('qb-core:client:ChangeText', source, 'This is your changed text', 'left')end
KeyPressed
Optional function that is used for displaying an animation on key press then hides the currently displayed text
-- Source code for referencelocalfunctionkeyPressed()CreateThread(function()SendNUIMessage({ action ='KEY_PRESSED', })Wait(500)hideText()end)endexports('KeyPressed', keyPressed)-- Export exampleCreateThread(function()local textDrawn =falsewhiletruedoWait(0)ifnot textDrawn then exports['qb-core']:DrawText('This is a test','left') textDrawn =trueendifIsControlJustPressed(0, 38) then exports['qb-core']:KeyPressed()endendend)-- Client exampleCreateThread(function()local textDrawn =falsewhiletruedoWait(0)ifnot textDrawn thenTriggerEvent('qb-core:client:DrawText', 'This is a test','left') textDrawn =trueendifIsControlJustPressed(0, 38) thenTriggerEvent('qb-core:client:KeyPressed')endendend)