The createCard function is used internally to generate information cards for citizen profiles.
This system allows you to easily adapt and expand the information shown for each citizen by customizing which cards and data fields are generated.
Multiple cards can be created, each with it's own title and custom list of details.
Cards are used to organize profile information into clear sections, such as "Personal Information", "Medical Data" or any other categories relevant to your server.
You can modify which cards are shown and what data they include by adjusting the logic in your data-gathering functions (for example, adding more createCard calls in the card-generation process).
local cards = {}
---@param title string
---@param data table
local function createCard(title, data) -- Do not change this function
table.insert(cards, {
title = title,
data = data
})
end
---@param stateid number
local function getPlayerData(stateid)
local result = MySQL.single.await(
[[
SELECT
JSON_UNQUOTE(JSON_EXTRACT(`charinfo`, '$.birthdate')) AS birthdate,
JSON_UNQUOTE(JSON_EXTRACT(`charinfo`, '$.height')) AS height,
JSON_UNQUOTE(JSON_EXTRACT(`charinfo`, '$.nationality')) AS nationality,
JSON_UNQUOTE(JSON_EXTRACT(`charinfo`, '$.phone')) AS phone,
JSON_UNQUOTE(JSON_EXTRACT(`metadata`, '$.bloodtype')) AS bloodtype,
JSON_UNQUOTE(JSON_EXTRACT(`metadata`, '$.fingerprint')) AS fingerprint
FROM
`players`
WHERE
`citizenid` = ?
]],
{ stateid }
)
if not result then
prints.error('Failed to get player data for stateid %s', stateid)
return
end
local data = {
{ label = 'Phone Number', value = result.phone or 'N/A' },
{ label = 'Date of Birth', value = result.birthdate or 'N/A' },
{ label = 'Height', value = result.height or 'N/A' },
{ label = 'Nationality', value = result.nationality or 'N/A' },
{ label = 'Blood Type', value = result.bloodtype or 'N/A' },
{ label = 'Fingerprint', value = result.fingerprint or 'N/A' }
}
createCard("Personal Information", data)
end
-- Add more createCard calls here to add more cards to citizen profile
---@param stateid number
---@return table
function generateCards(stateid) -- Do not change this function
cards = {}
getPlayerData(stateid)
return cards
end