Client exportları

Özel uygulamalar

Bir uygulamayı kaydeden, sayfasıyla konuşan ve simgesini yöneten client export'ları.

Sayfa tarafı dahil uygulama geliştirme rehberinin tamamı Özel uygulamalara genel bakış sayfasındadır.

#AddCustomApp

Bu oyuncunun telefonuna bir uygulama ekler. Uygulama, resource'unun bir iframe'de gösterilen web sayfasıdır.

lua---@class CustomAppDefinition
---@field identifier string app id: letters, digits, `_` and `-`, at most 40 characters (`appId` and `id` are accepted too)
---@field name string name under the icon, up to 40 characters (`label` is accepted too)
---@field ui string path of the page: '<resource>/<file>' or a path inside your resource
---@field icon? string path or link of the icon
---@field description? string up to 500 characters, shown in the App Store
---@field developer? string up to 60 characters; your resource name by default
---@field defaultApp? boolean true: already installed. false: the player installs it from the App Store (`defaultInstalled` is accepted too)
---@field size? number size shown in the App Store
---@field images? string[] screenshots for the App Store
---@field price? number App Store price, 0 or more
---@field category? string App Store category, 'other' by default
---@field jobs? string[] jobs that may use the app
---@field landscape? boolean the app supports landscape
---@field keepOpen? boolean
---@field fixBlur? boolean

---@param def CustomAppDefinition
---@return boolean ok
---@return string|nil err
exports['fx-phone']:AddCustomApp(def)
lualocal ok, err = exports['fx-phone']:AddCustomApp({
    identifier = 'garage', name = 'Garage', ui = 'my-garage/html/index.html', icon = 'my-garage/html/icon.png', defaultApp = true,
})
  • Hatalar: invalid (tablo değil), invalid_id, invalid_ui, reserved_id (id yerleşik bir uygulamaya ait).
  • Aynı id ile yeniden çağırmak uygulamayı değiştirir.
  • Uygulama, resource'un durduğunda kaldırılır.
  • Telefon yeniden yüklendiğinde uygulamayı tekrar kaydet: fx-phone:client:phoneLoaded client event'ini dinle. Bkz. Client event'leri.

#RemoveCustomApp

Eklediğin bir uygulamayı kaldırır.

lua---@param id string
---@return boolean ok
---@return string|nil err 'not_found'
exports['fx-phone']:RemoveCustomApp(id)
luaexports['fx-phone']:RemoveCustomApp('garage')

#SendCustomAppMessage

Uygulamanın sayfasına veri gönderir.

Şu adla da kullanılabilir: SendCustomNUIMessage

lua---@param id string
---@param data any
---@return boolean ok
---@return string|nil err 'not_found' when the app is not registered
exports['fx-phone']:SendCustomAppMessage(id, data)
luaexports['fx-phone']:SendCustomAppMessage('garage', { action = 'vehicles', list = vehicles })
  • Sayfa bunu window.addEventListener('message', ...) ile alır. Bkz. Uygulama API'si.

#SetInputFocus

Telefona, uygulamandaki bir metin alanının odakta olduğunu bildirir; böylece yazarken karakter hareket etmez.

lua---@param focused boolean
exports['fx-phone']:SetInputFocus(focused)
luaexports['fx-phone']:SetInputFocus(true)
  • Yalnızca Config.WalkWhileOpen = true olduğunda önemlidir.

#ToggleFocusKeepInput

Telefon odaktayken oyun girdisinin aktif kalıp kalmayacağını ayarlar. Ters değerle çağrılmış SetInputFocus'tur.

lua---@param keepInput? boolean default true
exports['fx-phone']:ToggleFocusKeepInput(keepInput)
luaexports['fx-phone']:ToggleFocusKeepInput(false)

#SetAppBadge

Bir uygulama simgesindeki sayı rozetini ayarlar.

lua---@param id string
---@param count number 0 to 999; 0 clears the badge
---@return boolean ok
exports['fx-phone']:SetAppBadge(id, count)
luaexports['fx-phone']:SetAppBadge('garage', 2)

#SetAppInstalled

Bu oyuncu için bir uygulamayı yükler ya da kaldırır.

lua---@param id string
---@param installed boolean
---@return boolean ok false only when `id` is not a string
exports['fx-phone']:SetAppInstalled(id, installed)
luaexports['fx-phone']:SetAppInstalled('garage', true)
  • Değişiklik arka planda server'a gönderilir; true isteğin gönderildiği anlamına gelir, uygulandığı anlamına gelmez.

#SetAppHidden

Bir uygulama simgesini kaldırmadan Ana Ekran'da gizler.

lua---@param id string
---@param isHidden boolean
---@return boolean ok
exports['fx-phone']:SetAppHidden(id, isHidden)
luaexports['fx-phone']:SetAppHidden('garage', true)