Server exportları

SIM

SIM kartlar, GhostNet kartı ve Anon itibarı için server export'ları.

İki SIM yuvasının, SIM kartların ve GhostNet kartının nasıl çalıştığı SIM kartlar sayfasında açıklanır.

#SIM kartlar

Yazma export'ları Config.Sim.Enabled = true gerektirir. SIM kartlar kapalıyken GetSimOwner, GetPlayerFromNumber ve GetSimsByIdentifier yine telefon kaydından yanıt verir, SearchSims ise boş liste döndürür.

Bir SIM, kartın seri numarası olan ICCID ile belirtilir. Bunu IssueSim'den ve sorgulardan alırsın.

RegisterSim, TransferSim, BlockSim, UnblockSim ve ReissueSim isteğe bağlı son bir actor argümanı alır: SIM'in geçmişinde görünecek bir ad, örneğin 'police'. Verilmezse resource'unun adı kullanılır.

#GetSimOwner

Bir numaranın kime ait olduğunu döndürür.

Şu adla da kullanılabilir: GetSimByNumber

lua---@class SimRecord
---@field iccid string
---@field number string
---@field kind 'physical'|'esim'
---@field status 'active'|'blocked'|'lost'|'inactive'
---@field registered boolean
---@field owner { identifier: string, firstname: string, lastname: string, dob: string }|nil nil on a prepaid SIM
---@field boughtAt integer unix seconds
---@field boughtBy { identifier: string, name: string }|nil
---@field shop { id: integer, name: string }|nil
---@field insertedBy string|nil identifier of whose phone it is in now

---@param number string
---@return SimRecord|nil sim
exports['fx-phone']:GetSimOwner(number)
lualocal sim = exports['fx-phone']:GetSimOwner('5551234')
if sim and sim.owner then print(sim.owner.firstname, sim.owner.lastname) end

#GetPlayerFromNumber

Bir numaranın arkasındaki karakteri döndürür: kayıtlı sahibi ya da SIM'i telefonunda taşıyan kişi.

Şu adla da kullanılabilir: GetNumberOwner

lua---@param number string
---@return string|nil identifier
exports['fx-phone']:GetPlayerFromNumber(number)
lualocal identifier = exports['fx-phone']:GetPlayerFromNumber('5551234')
  • Birine ödünç verilmiş kayıtlı bir SIM yine sahibini döndürür. Bir numaranın şu anda kimin telefonunda çaldığını bulmak için GetSourceFromNumber ya da GetIdentifierFromNumber kullan: bkz. Oyuncular ve numaralar.

#GetSimsByIdentifier

Bir karakterin bütün SIM'lerini döndürür.

lua---@param identifier string
---@return SimRecord[] sims
exports['fx-phone']:GetSimsByIdentifier(identifier)
lualocal sims = exports['fx-phone']:GetSimsByIdentifier(citizenid)

#SearchSims

SIM arar.

lua---@param filter? { number?: string, name?: string, identifier?: string, status?: string, limit?: integer }
---@return SimRecord[] sims at most 50 rows
exports['fx-phone']:SearchSims(filter)
lualocal found = exports['fx-phone']:SearchSims({ name = 'Kaya', status = 'active' })
  • number ve name, değerin bir kısmıyla da eşleşir.

#IssueSim

Bir SIM oluşturur.

lua---@class IssueSimOptions
---@field identifier? string the owner; required for a registered SIM and for an eSIM
---@field registered? boolean true (default): the owner's name is on it. false: prepaid
---@field kind? 'physical'|'esim' default 'physical'
---@field number? string a free number is picked when left out
---@field shopName? string kept in the SIM's record
---@field boughtBy? string identifier of the buyer, kept in the SIM's record

---@param opts IssueSimOptions
---@return { iccid: string, number: string, metadata: table }|nil sim
---@return string|nil err
exports['fx-phone']:IssueSim(opts)
lualocal sim, err = exports['fx-phone']:IssueSim({ identifier = citizenid, registered = true, kind = 'physical' })
if sim then exports.ox_inventory:AddItem(source, 'sim_card', 1, sim.metadata) end
  • Fiziksel SIM yalnızca bir kayıttır: item'ı oyuncuya, üzerinde sim.metadata ile senin script'in verir. Metadata ICCID'yi ve numarayı, Config.Sim.ItemText = true olduğunda da item'ın etiketini ve açıklamasını taşır.
  • eSIM item gerektirmez ve sahibinin telefonundaki boş bir yuvada hemen açılır. İki yuva da doluysa eSIM oluşturulur ama kapalı kalır.
  • Hatalar: disabled (SIM kartlar kapalı), denied (ön ödemeli SIM'ler Config.Sim.AllowUnregistered ile kapalı), invalid (gereken yerde identifier yok), exists (numara alınmış).
  • fx-phone:server:simIssued server event'ini tetikler. Bkz. Server event'leri.

#RegisterSim

Ön ödemeli bir SIM'i bir karakterin adına kaydeder.

lua---@param iccid string
---@param identifier string
---@param actor? string
---@return boolean ok
---@return string|nil err
exports['fx-phone']:RegisterSim(iccid, identifier, actor)
lualocal ok, err = exports['fx-phone']:RegisterSim(iccid, citizenid)
  • Karakterin zaten Config.Sim.MaxPerPlayer kadar SIM'i varsa limit döner.

#TransferSim

Kayıtlı bir SIM'i başka bir karaktere taşır.

lua---@param iccid string
---@param identifier string the new owner
---@param actor? string
---@return boolean ok
---@return string|nil err
exports['fx-phone']:TransferSim(iccid, identifier, actor)
luaexports['fx-phone']:TransferSim(iccid, newCitizenid)

#BlockSim

Bir SIM'i engeller. SIM telefonda kalır ama hizmet vermez; yalnızca acil durum numaraları çalışır.

lua---@param iccid string
---@param reason? string
---@param actor? string
---@return boolean ok
---@return string|nil err
exports['fx-phone']:BlockSim(iccid, reason, actor)
luaexports['fx-phone']:BlockSim(iccid, 'Unpaid bills')
  • SIM zaten engelliyse true, kayıp bir SIM için false, 'invalid' döndürür.
  • fx-phone:server:simBlocked server event'ini tetikler.

#UnblockSim

Bir engeli kaldırır.

lua---@param iccid string
---@param actor? string
---@return boolean ok
---@return string|nil err
exports['fx-phone']:UnblockSim(iccid, actor)
luaexports['fx-phone']:UnblockSim(iccid)

#ReissueSim

Kayıp bir kartın yerine yenisini çıkarır. Eski kart çalışmayı bırakır ve aynı numarayla yeni bir fiziksel kart oluşturulur.

lua---@param iccid string
---@param actor? string
---@return { iccid: string, number: string, metadata: table }|nil sim
---@return string|nil err
exports['fx-phone']:ReissueSim(iccid, actor)
lualocal sim = exports['fx-phone']:ReissueSim(iccid)
if sim then exports.ox_inventory:AddItem(source, 'sim_card', 1, sim.metadata) end
  • Yalnızca kayıtlı SIM'ler için (değilse not_owner). Yeni item'ı oyuncuya vermek sana kalmış.

#useSimCard

Bir SIM kart, GhostNet kartı ya da powerbank item'ı kullanıldığında ox_inventory'nin çağırdığı item hook'u. Kendi script'lerinden çağırma; item tanımında adını ver.

lua---@param event string ox_inventory item event; only 'usingItem' is handled
---@param item table the ox_inventory item definition
---@param inventory table the player's ox_inventory inventory
---@param slot integer
---@return false|nil keep false keeps ox_inventory from consuming the item
exports['fx-phone']:useSimCard(event, item, inventory, slot)
lua['sim_card'] = { label = 'SIM Card', weight = 10, stack = false, server = { export = 'fx-phone.useSimCard' } },
  • Item'ı telefon kendisi kaldırır ya da tutar; bu yüzden export usingItem için her zaman false döner. Item tanımlarının tamamı Item kurulumu sayfasındadır.

#GhostNet kartı

#HasSecondSim

Bir oyuncunun GhostNet kartının şu anda çalışıp çalışmadığını döndürür: telefonda takılı, açık ve süresi dolmamış olmalı.

lua---@param src integer
---@return boolean active
exports['fx-phone']:HasSecondSim(src)
luaif not exports['fx-phone']:HasSecondSim(source) then return end

#GetSecondSim

Hangi yuvada olursa olsun bir oyuncunun telefonundaki GhostNet kartını döndürür.

lua---@param src integer
---@return { type: 'ghost', slot: integer, line: string, carrier: string, enabled: boolean, status: string, active: boolean, activatedAt: integer, expiresAt: integer }|nil sim
exports['fx-phone']:GetSecondSim(src)
lualocal sim = exports['fx-phone']:GetSecondSim(source)

#GiveSecondSim

Item olmadan bir oyuncunun telefonuna GhostNet kartı takar.

lua---@param src integer
---@param days? number default Config.SecondSim.Days
---@return boolean given
exports['fx-phone']:GiveSecondSim(src, days)
luaexports['fx-phone']:GiveSecondSim(source, 7)
  • Kart boş bir SIM yuvasına takılır. İki yuva da başka kartlarla doluysa hiçbir şey verilmez ve false döner.
  • Telefonda zaten bir GhostNet kartı varsa ne olacağına Config.SecondSim.Stack karar verir.
  • Config.SecondSim kapalıysa false döndürür.

#Anon

#GetAnonProfile

Bir oyuncunun Anon kimliğini döndürür.

lua---@param src integer
---@return { handle: string, xp: integer, cracks: integer, rank: integer, title: string, nextXp: integer|nil, nextTitle: string|nil, floorXp: integer }|nil profile nil when the player has not picked a handle
exports['fx-phone']:GetAnonProfile(src)
lualocal profile = exports['fx-phone']:GetAnonProfile(source)

#AddAnonXp

Bir oyuncuya Anon XP'si verir; örneğin tamamlanmış bir işin ödülü olarak.

lua---@param src integer
---@param xp number
---@return boolean added false when the player has no handle yet
exports['fx-phone']:AddAnonXp(src, xp)
luaexports['fx-phone']:AddAnonXp(source, 15)

Bkz. Anon.