Client exportları
Diyaloglar ve seçiciler
Oyuncuya soru soran ya da telefon ekranında bir şey seçmesini sağlayan client export'ları.
Bunların her biri, kapalıysa telefonu açar.
#DoPhoneConfirmation
Telefonda evet / hayır sorusu gösterir ve yanıtı geri verir.
lua---@param title string up to 60 characters
---@param text string up to 300 characters
---@param icon? string icon name
---@param cb? fun(accepted: boolean)
---@return boolean|nil accepted the answer without `cb`; nil with `cb`
exports['fx-phone']:DoPhoneConfirmation(title, text, icon, cb)
luaif exports['fx-phone']:DoPhoneConfirmation('Sell vehicle', 'Sell your Sultan?', 'car') then
TriggerServerEvent('my-dealer:sell')
end
cbolmadan export yanıtı bekler; bu yüzden bir thread'den ya da bir event handler'dan çağır.cbile hemen döner vecb(accepted)'ı daha sonra çağırır.- 60 saniye içinde yanıt gelmezse
falsesayılır. - Telefon yüklenmemişse ya da oyuncunun telefon item'ı yoksa
falsedöndürür (vecb(false)'ı çağırır). - Birden fazla onay sorusu art arda gösterilir.
#ShowComponent
Bir seçici açar ve oyuncunun seçtiğini geri verir.
lua---@class ComponentOptions
---@field type 'contact'|'gallery'|'camera'|'gif'|'emoji'|'color'
---@field title? string heading, up to 60 characters
---@field multiple? boolean lets the player pick several
---@field max? number most items with `multiple`, 1 to 20
---@param opts ComponentOptions
---@param cb? fun(result: any)
---@return any|nil result the choice without `cb`; nil with `cb`, on cancel, or after 120 seconds
exports['fx-phone']:ShowComponent(opts, cb)
lualocal contact = exports['fx-phone']:ShowComponent({ type = 'contact' })
if contact then print(contact.number) end
type |
Oyuncunun seçtiği | Sonuç |
|---|---|---|
contact |
Bir kişi | { id, number, firstname, lastname, avatar } |
gallery |
Bir fotoğraf ya da video | { id, url, thumbnail, kind } |
camera |
Yeni bir fotoğraf çeker | { id, url, thumbnail, kind } |
gif |
Bir GIF | { id, url, preview, width, height } |
emoji |
Bir emoji | emojinin kendisi |
color |
Bir renk | '#RRGGBB' |
- Bilinmeyen bir
typeiçin ya da telefon açılamadığındanildöndürür. multiple = trueolduğunda sonuç bir listedir.
#SetPopUp
Kendi düğmelerinle bir popup gösterir.
lua---@class PopUpButton
---@field title string up to 40 characters (`label` is accepted too)
---@field style? string 'cancel' or 'destructive' (`color = 'red'` also gives a destructive button)
---@field icon? string icon name
---@field cb? function called when pressed (`onPress` is accepted too)
---@param data { title: string, description?: string, buttons?: PopUpButton[] }
---@return string|nil id
exports['fx-phone']:SetPopUp(data)
luaexports['fx-phone']:SetPopUp({
title = 'Tow request', description = 'A player needs a tow at Pillbox.',
buttons = { { title = 'Accept', cb = function() acceptTow() end }, { title = 'Ignore', style = 'cancel' } },
})
title60,description300 karakterde kesilir. En fazla 8 düğme.datatablo değilse ya da telefon açılamazsanildöndürür.
#SetContextMenu
Bir işlem menüsü gösterir.
lua---@param data { title?: string, buttons?: PopUpButton[] }
---@return string|nil id
exports['fx-phone']:SetContextMenu(data)
luaexports['fx-phone']:SetContextMenu({
title = 'Vehicle',
buttons = { { title = 'Lock', icon = 'lock', cb = function() lockVehicle() end } },
})
- Düğme biçimi ve sınırlar
SetPopUpile aynıdır.