Server
Buzz
---This function handles the publishing of a buzz.
---@param data table { message: string, attachment: string (link) } Data of the buzz.
---@param citizenid string Citizen id of the player or use 'SYSTEM' for script based buzz.
---@param fullName string Full name of the player.
exports['snappy-phone']:publishBuzz(data, citizenid, fullName)
Example
exports['snappy-phone']:publishBuzz({
message = 'Found something precious!',
attachment = 'https://static0.gamerantimages.com/wordpress/wp-content/uploads/2023/01/lara-croft-treasure-rise-of-the-tomb-raider.jpg'
}, 'SYSTEM', 'Lara Croft')
Crypto
---It returns a table with the balance and the crypto name.
---If the player doesn't have any crypto data, it will return false and a message.
---@param citizenid string Character identifier of the player to get the data from.
---@param cryptoName string Crypto name to get the data from.
---@return {status: boolean, msg: string, data?: {balance: number, cryptoName: string}} response Returns a table with the status, message and data.
exports['snappy-phone']:getCrypto(citizenid, cryptoName)
---It returns a table with all the crypto data.
---If the player doesn't have any crypto data, it will return false and a message.
---@param citizenid string Citizen ID of the player to get the data from.
---@return {status: boolean, msg: string, data?: table} response Returns a table with the status, message and data.
exports['snappy-phone']:getCryptoData(citizenid)
---It returns a table with the status and message.
---If the player doesn't have any crypto data, it will return false and a message.
---@param citizenid string Citizen ID of the player to add the crypto to.
---@param cryptoName string Crypto name to add the crypto to.
---@param balance number Balance to add to the crypto.
---@param description? string Description of the action.
---@return {status: boolean, msg: string} response Returns a table with the status and message.
exports['snappy-phone']:addCrypto(citizenid, cryptoName, balance, description)
---It returns a table with the status and message.
---If the player doesn't have any crypto data, it will return false and a message.
---@param citizenid string Citizen ID of the player to remove the crypto from.
---@param cryptoName string Crypto name to remove the crypto from.
---@param balance number Balance to remove from the crypto.
---@param description? string Description of the action.
---@return {status: boolean, msg: string} response Returns a table with the status and message.
exports['snappy-phone']:removeCrypto(citizenid, cryptoName, balance, description)
Messages
---Export which can be used to send messages
---@param data { senderCitizenId: string, targetCitizenId: string, senderPhoneNumber: string, targetPhoneNumber: string, messageData: { message: string | { x: number, y: number, z: number }, type: 'message' | 'location' } }
---@return { status: boolean, msg: string, data?: any }
exports['snappy-phone']:sendPhoneMessage(data)
-- Note: The senderPhoneNumber should exist on someone's character
Contact
---Share contact of self or other person
---@param source Player source from whom you want to initiate contact send request
---@param data (optional) { type = 'personal', -- 'personal', 'other' number = 'OTHER_NUMBER', -- only if type = 'other' name = 'OTHER_NAME' -- only if type = 'other' }
TriggerEvent('phone:client:sharePhoneNumber', source, data)
Notifications
local data = {
icon = 'user', --https://fontawesome.com/search?o=r&m=free
title = 'DEMO TITLE',
description = 'Testing the description',
duration = 5000, -- 5000 ms : 5 secs
}
local isChecked = lib.callback.await('phone:client:receiveConfirmationPopup', source, data)
if isChecked then
-- pressed check
else
-- pressed cross
end
local data = {
icon = 'user', --https://fontawesome.com/search?o=r&m=free
title = 'DEMO TITLE',
description = 'Testing the description',
duration = 5000, -- 5000 ms : 5 secs
}
TriggerClientEvent('phone:client:notification', source, data)
-- Sends a custom email from a given sender to one or more recipients.
---@param data {sender?: string; subject?: string; body?: string, recipients: {source?: number; identifier?: string}[]}: A table containing sender subject, body, and recipients.
---@return {status: boolean; msg: string}: A status message indicating success or failure.
exports['snappy-phone']:sendCustomMail(data)
-- Sends a custom email from a given sender to one or more recipients.
---@param data {sender?: string; subject?: string; body?: string, recipients: {source?: number; identifier?: string}[]}: A table containing sender subject, body, and recipients.
TriggerEvent('snappy-phone:server:sendCustomMail', data)
Phone
---Export which returns playerData
---@param phoneNumber string
---@return playerData
exports['snappy-phone']:getPlayerByPhoneNumber(phoneNumber)
---Export which returns if player has app installed or not
---@param source number
---@param appName string
---@return boolean true / false
exports['snappy-phone']:hasAppInstalled(source, appName)
Party
---Send notification to all the party members using phone's popup.
---@param partyId number Party id of the player's joined party.
---@param data table Same as Notifications data.
---@return table status Status of the function.
exports['snappy-phone']:sendPartyNotification(partyId, data)
---Returns the party id of the player's party.
---To retrieve the party data use the getPartyById(partyId) function.
---@param citizenid string Citizen id of the player.
---@return false|number partyId Party id of the player's joined party. False if the player is not in a party.
exports['snappy-phone']:getPlayerPartyId(citizenid)
---Returns the player's party if the player is in a party.
---@param partyId number Party id of the player's joined party.
---@return nil|table party Player's party. False if the player is not in a party.
exports['snappy-phone']:getPartyById(partyId)
---Returns the list of all the members that are inside the party.
---@param partyId number Party id of the player's joined party.
---@return false|table members List of all the members that are inside the party.
exports['snappy-phone']:getPartyMembers(partyId)
---Returns the citizen id of the party leader.
---@param partyId number Party id of the player's joined party.
---@return false|string citizenid Citizen id of the party leader.
exports['snappy-phone']:getPartyLeader(partyId)
--Returns if the citizenid is the leader of the party.
---@param partyId number Party id to check.
---@param citizenid string Citizen id to check.
---@return boolean isLeader True if the citizenid is the leader of the party, otherwise false.
exports['snappy-phone']:isPartyLeader(partyId, citizenid)
---Returns the number of players that are inside the party.
---@param partyId number Party id of the player's joined party.
---@return false|number size Number of players that are inside the party.
exports['snappy-phone']:getPartySize(partyId)
---Returns the party's current job.
---@param partyId number Party id of the player's joined party.
---@return string|table job Party's current job.
exports['snappy-phone']:getPartyJob(partyId)
---Returns the party's type (legal, illegal).
---@param partyId number Party id of the player's joined party.
---@return string|table type Party's type.
exports['snappy-phone']:getPartyType(partyId)
---This function will check if all the party members have access to illegal party.
---@param partyId number Party id of the player's joined party.
---@return boolean toggle Returns true if all the party members have access to illegal party.
exports['snappy-phone']:hasPartyShadowMod(partyId)
---Returns if you can join party or no
---@param job string Job Name
---@return boolean canJoin Can join the job if limit not reached
exports['snappy-phone']:canJoinParty(job)
---Set the party's current job to the newly passed job.
---@param partyId number Party id of the player's joined party.
---@param job string Job name.
---@return table status Status of the function.
exports['snappy-phone']:setPartyJob(partyId, job)
---Set the party's current tasks to the newly passed tasks.
---@param partyId number Party id of the player's joined party.
---@param tasks table List of all the tasks that the party need to complete.
---@return table status Status of the function.
exports['snappy-phone']:updatePartyTasks(partyId, tasks)
---Create a party for the player.
---@param source number Source of the player.
---@param partyName string Name of the party.
---@return table result Result table. This table will contain the status, msg.
exports['snappy-phone']:createParty(source, partyName)
---Disband the party. This action will only work if the sourceCitizenId is the leader of the party.
---@param src number|nil Source of the player that is trying to disband the party.
---@param partyId number Party id of the player's joined party.
---@param sourceCitizenId string Citizen id of the player that is trying to disband the party.
---@return table result Result table. This table will contain the status and msg fields which will tell us if the party was disbanded or not.
exports['snappy-phone']:disbandParty(src, partyId, sourceCitizenId)
---Register a job as party job for server.
---@param data table { name: job name, icon: icon to display in party app, size: max parties for this job, type: 'legal', 'illegal' }
---@return boolean
local data = {
name = 'Fishing',
icon = 'fas fa-fish', -- https://fontawesome.com/search?o=r&m=free
size = 3, -- -1 is unlimited
type = 'legal'
}
exports['snappy-phone']:registerJob(data)
RegisterNetEvent('phone:server:resumePendingJobs', function(playerSrc, data)
local source = playerSrc -- gives player current source
local citizenid = data.citizenid -- gives player character identifier
local partyId = data.partyId -- gives last partyid
local currentJob = data.currentJob -- gives last job name
-- This is to reassign the job tasks when player crashes/exits while doing job and returns
end)
RegisterNetEvent('phone:server:disbandParty', function(playerSrc, partyId)
-- Do something here for the job when party is disbanned
end)
RegisterNetEvent('phone:server:leftParty', function(playerSrc, data)
local source = playerSrc
local partyId = data.partyId
local currentJob = data.currentJob
-- Do something here for the player when they leave the party before completing the job
end)
Last updated