> For the complete documentation index, see [llms.txt](https://docs.gkshop.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gkshop.org/gksphone-v2/exports-and-events/server-exports.md).

# Server Exports

## Messages

### SendMessage

```lua
--- Sends a message from any number to another number
--- @param fromNumber string Sender phone number
--- @param toNumber string Receiver phone number
--- @param message string|table|vector2 Message content, table with coords {x,y}, or vector2 for GPS
--- @return table { status = boolean, messageId = number|nil, error = string|nil }
exports["gksphone"]:SendMessage("101-11111", "101-22222", "Hello!")
```

### SendSystemMessage

```lua
--- Sends a system/virtual message to a player
--- @param targetPhoneNumber string Receiver phone number
--- @param message string|table|vector2 Message content, table with coords {x,y}, or vector2 for GPS
--- @param senderNumber string Sender number/name (e.g. "Delivery", "LSCustom", "Police")
--- @return table { status = boolean, messageId = number|nil, error = string|nil }
local result = exports["gksphone"]:SendSystemMessage("101-22222", "Test Message", "Delivery")
-- result = { status = true, messageId = 12345 }
-- Error: { status = false, error = "Missing parameters" }
```

### BroadcastSystemMessage

```lua
--- Broadcasts a system message to all online players
--- @param message string|table Message content
--- @param senderNumber string Sender number/name
--- @return table { status = boolean, sentCount = number }
exports["gksphone"]:BroadcastSystemMessage("Hello!", "Police")
```

## Calls

### CreateCall <a href="#createcall" id="createcall"></a>

```lua
local data = {
    number = "5551234",  -- Phone number (required if no job/company)
    job = "police",
    hideNumber = false   --  Anonymous / hidden caller ID
}

exports['gksphone']:CreateCall(source, data)
-- returns false, "invalid_source" | "invalid_data" (job checks run on client)
```

### IsInCall

```lua
local inCall, callId, call = exports['gksphone']:IsInCall(source)
-- returns true, 5000, callData
```

### GetCall

```lua
local call = exports['gksphone']:GetCall(callId)
-- returns
{
    callerSource = 1,
    callerPhone = '1111',
    callerPhoneUniq = 'GKS11111',
    calltype = 'calling',  -- calling or vidmeet
    time = 0, -- The os.time() when the call started
    status = true,
    is_anonymous = true,
    isJob = false,
    receivers = {} -- {receiverSource = 2, receiverPhone, receiverPhoneUniq, is_accepts}
}
```

## EndCall

```lua
exports['gksphone']:EndCall(source)
```

## Mail

### Send Mail

```lua
local src = source or -1
local MailData = {
  sender = 'GKSHOP',
  image = '/html/img/icons/mail.png',
  subject = "GKSPHONE",
  message = 'TEST',
  buttons = {   --- If you don't want it to be a button, please remove it.
        {
            label = "Accept",
            type = "client_event",
            event = "myresource:client:accept",
            data = { id = 123 },
            color = "green",
            clearOnClick = true
        },
        {
            label = "Reject",
            type = "server_event",
            event = "myresource:server:reject",
            data = { id = 123 },
            color = "red",
            clearOnClick = false
        }
  },
  attachments = {
    "https://example.com/photo1.png",
    "https://example.com/photo2.png"
  }
}
exports["gksphone"]:SendNewMail(src, MailData)
```

### Send Offline Mail

```lua
-- citizenID => QB Citizen Id
local xPlayer = QBCore.Functions.GetPlayer(source)
local citizenID = xPlayer.PlayerData.citizenid
local MailData = {
  sender = 'GKSHOP',
  image = '/html/img/icons/mail.png',
  subject = "GKSPHONE",
  message = 'TEST',
  buttons = {   --- If you don't want it to be a button, please remove it.
        {
            label = "Accept",
            type = "client_event",
            event = "myresource:client:accept",
            data = { id = 123 },
            color = "green"
        },
        {
            label = "Reject",
            type = "server_event",
            event = "myresource:server:reject",
            data = { id = 123 },
            color = "red",
            clearOnClick = false
        }
  },
  attachments = {
    "https://example.com/photo1.png",
    "https://example.com/photo2.png"
  }
}
exports["gksphone"]:SendNewMailOffline(citizenID, MailData)
```

## Billing

### New Billing

```lua
-- src => Player's ID
-- label => Billing description
-- society => By which job the billingwas created
-- senderBilling => Who is the person sending the billing?
-- senderID => ESX Identifier of the billing originator
-- amount => Billing price
local src = source
local label = "Excessive Speed"
local society = "police"
local senderBilling = "GKSHOP XENKNIGHT"  -- Player Name
local senderID = "char1:4b110a7811" -- xPlayer.identifier
local amount = 500
exports["gksphone"]:NewBilling(src, label, society, senderBilling, senderID, amount)
```

### Is Unpaid Bill

To inquire if the player has any outstanding bills

```lua
local xPlayer = QBCore.Functions.GetPlayer(source)
local citizenID = xPlayer.PlayerData.citizenid
local isBills = exports["gksphone"]:IsUnpaidBillsbyCid(citizenID)
print(isBills) -- true or false
```

## **Misc**

### **Send Notification**

```lua
-- src => Player's ID
local src = source
local NotifData = {
    title = "Notification header", -- Notification header
    message = "Notification Message", -- Notification content message
    icon    = '/html/img/icons/messages.png', -- Icon of the notification
    duration = 5000, -- specify how many seconds,
    type = "success", -- the home screen will also appear on the notification side.
    buttonactive = false, -- Activate if you want to use the button function
    button = {
       buttonEvent = "gksphone:client:Test", -- event name to use if the button approves
       buttonData = "test", -- If you want to transfer any data in the button
    }
}
exports["gksphone"]:sendNotification(src, NotifData)
```

### New Number

```lua
local src = source -- player id
local phoneID = uniqID or nil
local NewNumber = "555555" -- example
local newNumber = exports["gksphone"]:NewNumber(src, phoneID, NewNumber)
print(newNumber) -- true/false
```

### Change Number

Change phone number

```lua
local phoneID = "GKSXXXXXXX" -- Phone Uniq ID
local oldNumber = "5555"
local newNumber = "2222"
local updateContacts = true -- Whether to update contacts with the new number
local changeNumber = exports["gksphone"]:ChangeNumber(phoneID, oldNumber, newNumber, updateContacts)
print(changeNumber) -- true or false
```

### Emergency Alert

```lua
local title = "Emergency Alert"
local message = "Test Alert"
exports["gksphone"]:EmergencyAlert(title, message)
```

## Services

### Send Report

```lua
local src = source
local ped = GetPlayerPed(src)

local reportMessage = "Dispatch Message"
local reportPhoto = "Image Link" or nil
local job = "police" -- job code 
local anonymous = false -- or true
local playerCoords = GetEntityCoords(ped)
local streedZone = "Street name" or "Unknown"
local sendDispatch = exports["gksphone"]:SendReport(src, reportMessage, reportPhoto, job, anonymous, playerCoords, streedZone)
print(sendDispatch) -- true/false
```

### Job Status Change

The job in the Dispatch section is for opening and closing

```lua
local job = "police" -- job code
local status = true -- true or false
exports["gksphone"]:JobStatusChange(job, status)
```

### Job Status

```lua
local job = "police" -- job code
local jobStatus = exports["gksphone"]:IsJobStatus(job)
print(jobStatus) -- true or false
```

## Bank App

### Bank History Save

```lua
local src = source
local type = 1 -- 1 (-) or 2 (+)
local amount = 500
local description = "Bank History Desc"

local historySave = exports["gksphone"]:BankSaveHistory(src, type, amount, description)
print(historySave) -- true/false
```

## Custom App

### Add Custom App

```lua
local appData = {
	name = "mdt", --- A unique name
	icons = "/html/img/icons/mdt.png",  -- logo url
	description = ""  -- App description that will appear in the app store
        appurl = "https://cfx-nui-gksphone-app/ui/index.html",  -- custom app url
	url = "/customapp",   -- do not touch this part
	blockedjobs = {},
	allowjob = {},
	signal = true,
	show = true,
	labelLangs = {   -- App name by languages
		af = "MDT",
		ar = "MDT",
		cs = "MDT",
		de = "MDT",
		en = "MDT",
		es = "MDT",
		fr = "MDT",
		id = "MDT",
		nl = "MDT",
		["pt-PT"] = "MDT",
		ro = "MDT",
		sv = "MDT",
		th = "MDT",
		tr = "MDT",
		uk = "MDT",
		["zh-TW"] = "MDT"
	}
}
exports["gksphone"]:AddCustomApp(appData)
```

## Cypto

### Add Crypto

```lua
local src = source
local coinid = "bitcoin" -- config.lua check
local amount = 5
local phoneUniqID = "GKS111111" -- phone uniq id
local addCrypto = exports["gksphone"]:stockMarketAdd(src, coinid, amount, phoneUniqID)
print(addCrypto) -- true or false
```

### Remove Crypto

```lua
local src = source
local coinid = "bitcoin" -- config.lua check
local amount = 5
local phoneUniqID = "GKS111111" -- phone uniq id
local addCrypto = exports["gksphone"]:stockMarketRemove(src, coinid, amount, phoneUniqID)
print(addCrypto) -- true or false
```

## Live Stream

### Add Cheer

<pre class="language-lua"><code class="lang-lua"><strong>local src = source
</strong><strong>local amount = 5000
</strong><strong>local addCheer = exports["gksphone"]:AddLiveStreamCheer(src, amount)
</strong>print(addCheer) -- true or false
</code></pre>

### Add Coin

<pre class="language-lua"><code class="lang-lua"><strong>local src = source
</strong><strong>local amount = 5000
</strong><strong>local addCoin = exports["gksphone"]:AddLiveStreamCoin(src, amount)
</strong>print(addCoin) -- true or false
</code></pre>

## Social Media

### Toggle Verified

```lua
local app = 'squawk' -- 'squawk' or 'snapgram'
local username = '...' -- username in the app
local verified = 1 -- 0 = none / 1 = blue / 2 = yellow(only squawk)
local res = exports["gksphone"]:ToggleVerified(app, username, verified)
print(res) -- true or false
```

## Heavy Jammer

### heavyJammerByPhone

```lua
local phoneUniqueId = "GKS2026AAAAA" -- The unique identifier of the phone
local status = true -- true to enable jammer, false to disable
local message = "Test" -- Custom message displayed on the jammed phone
exports['gksphone']:heavyJammerByPhone(phoneUniqueId, status, message)

--- @return boolean Returns true if successful, false if phoneUniqueId is nil
```

### heavyJammerByPhones

Jam or unjam multiple phones at once.

```lua
-- Jam multiple phones
local phoneIds = {"PHONE_001", "PHONE_002", "PHONE_003"}
local count = exports['gksphone']:heavyJammerByPhones(phoneIds, true, "Signal blocked by authorities")
print(count .. " phones jammed")

-- Unjam all phones in the list
exports['gksphone']:heavyJammerByPhones(phoneIds, false, "")
```

### isPhoneJammed

Check if a specific phone is currently jammed.

```lua
-- phoneUniqueId (The unique identifier of the phone)
local isJammed = exports['gksphone']:isPhoneJammed("ABC123XYZ")
-- return boolean|nil
if isJammed == nil then
    print("Invalid phone ID")
elseif isJammed then
    print("Phone is currently jammed")
else
    print("Phone has normal signal")
end
```

### getJammedPhones

Get a list of all currently jammed phones.

```lua
local jammedPhones = exports['gksphone']:getJammedPhones()
--[[ Return table |  { phoneUniqueId = { status, message, jammedAt }, ... }
{
    ["PHONE_ID_1"] = {
        status = true,           -- Always true for jammed phones
        message = "...",         -- The jammer message
        jammedAt = 1704067200    -- Unix timestamp when jammed
    },
    ["PHONE_ID_2"] = { ... }
}
]] --
for phoneId, data in pairs(jammedPhones) do
    local duration = os.time() - data.jammedAt
    print(string.format(
        "Phone: %s | Message: %s | Jammed for: %d seconds",
        phoneId,
        data.message,
        duration
    ))
end
```

### clearAllJammers

```lua
local cleared = exports['gksphone']:clearAllJammers()
-- return number | Count of jammers that were cleared
print(cleared .. " phones have been unjammed")
```

## Map / GPS

### AddMapLocation

<pre class="language-lua"><code class="lang-lua">-- Add location to specific player
<strong>exports['gksphone']:AddMapLocation(playerSource, {
</strong>    id = 'business_247_1',
    position = { x = 25.7, y = -1346.7 },
    name = '24/7 Store',
    description = 'Open Now',
    icon = 'https://...',
    category = 'business'
})

-- Add location to all players (source = -1)
exports['gksphone']:AddMapLocation(-1, { id = 'event_party', position = { x = 100, y = 200 }, name = 'Party' })
</code></pre>

### RemoveMapLocation

```lua
exports['gksphone']:RemoveMapLocation(playerSource, 'business_247_1')
exports['gksphone']:RemoveMapLocation(-1, 'event_party')
```

### UpdateMapLocation

```lua
exports['gksphone']:UpdateMapLocation(playerSource, 'vehicle_123', { position = { x = 150, y = -300 } })
```

## Phone Data Exports

### GetPhoneBySource

Find phone number with Source

```lua
local src = source
local phoneNumber = exports["gksphone"]:GetPhoneBySource(src)
print(phoneNumber)

-- OR

local xPlayer = QBCore.Functions.GetPlayer(source)
local phoneNumber = xPlayer.PlayerData.charinfo.phone
print(phoneNumber)
```

### GetSourceByPhone

Finding a source by phone number

```lua
local phoneNumber = number
local source = exports["gksphone"]:GetSourceByPhone(phoneNumber)
print(source)

-- OR

local phoneNumber = number
local xPlayer = QBCore.Functions.GetPlayerByPhone(phoneNumber)
local source = xPlayer.PlayerData.source
print(source)
```

### GetPhoneDataBySource

Access the data of the phone used with the Source number

```lua
local src = source
local phoneData = exports["gksphone"]:GetPhoneDataBySource(src)
print(json.encode(phoneData))
```

### GetPhoneDataByNumber

Accessing the phone's data with the phone number

```lua
local phoneNumber = number
local phoneData = exports["gksphone"]:GetPhoneDataByNumber(phoneNumber)
print(json.encode(phoneData))
```

### GetPhoneDataBySetupOwner

Accessing all phone data of the player

```lua
local xPlayer = QBCore.Functions.GetPlayer(source)
local citizenID = xPlayer.PlayerData.citizenid
local phoneData = exports["gksphone"]:GetPhoneDataBySetupOwner(citizenID)
print(json.encode(phoneData))
```

### GetPhoneDataByPhoneUniqID

Access phone data with the phone's UniqID

```lua
local phoneUniqID = id
local phoneData = exports["gksphone"]:GetPhoneDataByPhoneUniqID(phoneUniqID)
print(json.encode(phoneData))
```

### GetPhoneDataByCitizenID

Access phone data with the user's ID (You will access the data of the last phone the user opened)

```lua
local xPlayer = QBCore.Functions.GetPlayer(source)
local citizenID = xPlayer.PlayerData.citizenid
local phoneData = exports["gksphone"]:GetPhoneDataByCitizenID(citizenID)
print(json.encode(phoneData))
```

### GetPhoneLangBySource

The language the user chooses on the phone

```lua
local src = source
local PhoneLang = exports["gksphone"]:GetPhoneLangBySource(src)
print(PhoneLang)
```
