DarkRP
The DarkRP compatibility library provides essential functions for maintaining compatibility
lia.darkrp.isEmpty(position, entitiesToIgnore)
Purpose
Determine whether a position is free of solid contents, players, NPCs, or props.
When Called
Before spawning DarkRP-style shipments or entities to ensure the destination is clear.
Parameters
Vector position World position to test.
table entitiesToIgnore optional Optional list of entities that should be excluded from the collision check.
Returns
boolean true when the spot contains no blocking contents or entities; otherwise false.
Example Usage
local spawnPos = ent:GetPos() + Vector(0, 0, 16)
if lia.darkrp.isEmpty(spawnPos) then
lia.darkrp.createEntity("Ammo Crate", {ent = "item_ammo_crate", model = "models/Items/ammocrate_smg1.mdl"})
end
lia.darkrp.findEmptyPos(startPos, entitiesToIgnore, maxDistance, searchStep, checkArea)
Purpose
Locate the nearest empty position around a starting point within a search radius.
When Called
Selecting safe fallback positions for DarkRP-style shipments or NPC spawns.
Parameters
Vector startPos Origin position to test first.
table entitiesToIgnore optional Optional list of entities to ignore while searching.
number maxDistance Maximum distance to search away from the origin.
number searchStep Increment used when expanding the search radius.
Vector checkArea Additional offset tested to ensure enough clearance (for hull height, etc.).
Returns
Vector First empty position discovered; if none found, returns startPos.
Example Usage
local spawnPos = lia.darkrp.findEmptyPos(requestPos, nil, 256, 16, Vector(0, 0, 32))
npc:SetPos(spawnPos)
lia.darkrp.notify(client, notifyType, duration, message)
Purpose
Provide a DarkRP-compatible wrapper for Lilia's localized notify system.
When Called
From DarkRP addons or compatibility code that expects DarkRP.notify to exist.
Parameters
Player client Recipient of the notification.
number notifyType Unused legacy parameter kept for API parity.
number duration Unused legacy parameter kept for API parity.
string message Localization key or message to pass to Lilia's notifier.
Example Usage
lia.darkrp.notify(ply, NOTIFY_GENERIC, 4, "You received a paycheck.")
lia.darkrp.textWrap(text, fontName, maxLineWidth)
Purpose
Wrap long text to a maximum line width based on the active surface font metrics.
When Called
Preparing DarkRP-compatible messages for HUD or chat rendering without overflow.
Parameters
string text Message to wrap.
string fontName Name of the font to measure.
number maxLineWidth Maximum pixel width allowed per line before inserting a newline.
Returns
string Wrapped text with newline characters inserted.
Example Usage
local wrapped = lia.darkrp.textWrap("A very long notice message...", "DermaDefault", 240)
chat.AddText(color_white, wrapped)
lia.darkrp.formatMoney(amount)
Purpose
Format a currency amount using Lilia's currency system while matching DarkRP's API.
When Called
Anywhere DarkRP.formatMoney is expected by compatibility layers or addons.
Parameters
number amount Currency amount to format.
Returns
string Localized and formatted currency string.
Example Usage
local paycheck = DarkRP.formatMoney(500)
chat.AddText(L("paydayReceived", paycheck))
lia.darkrp.createEntity(name, data)
Purpose
Register a DarkRP entity definition as a Lilia item for compatibility.
When Called
While converting DarkRP shipments or entities into Lilia items at load time.
Parameters
string name Display name for the item.
table data Supported fields: cmd, ent, model, desc, price, category.
Example Usage
lia.darkrp.createEntity("Ammo Crate", {
ent = "item_ammo_crate",
model = "models/Items/ammocrate_smg1.mdl",
price = 750,
category = "Supplies"
})