Custom Framework - Server
Framework check
At the top of the file, add a check for Config.Framework. If it's not set to your framework, return to prevent it from loading.
if Config.Framework ~= "your-framework" then
return
endFramework functions
You need to implement the following functions for the racing script to work with your framework.
IsAdmin
Check if a player is an admin.
---@return boolean
function IsAdmin(source)
return IsPlayerAceAllowed(source, "command.lbracing_admin") == 1
endGetIdentifier
Get a player's identifier. If you use multicharacter, make sure to return the identifier of the current character.
---@param source number
---@return string?
function GetIdentifier(source)
---@diagnostic disable-next-line: param-type-mismatch
return GetPlayerIdentifierByType(source, "license")
endGetSourceFromIdentifier
Get a source from an identifier.
---@param identifier string
---@return number?
function GetSourceFromIdentifier(identifier)
local players = GetPlayers()
for i = 1, #players do
if GetPlayerIdentifierByType(players[i], "license") == identifier then
---@diagnostic disable-next-line: return-type-mismatch
return players[i]
end
end
endGetCharacterName
Get the first and last name of a character.
---@param source number
---@return string firstName
---@return string lastName
function GetCharacterName(source)
return GetPlayerName(source), tostring(source)
endDoesPlayerOwnVehicle
Check if a player owns a vehicle.
---@param source number
---@param plate string
---@param vehicle number
---@return boolean
function DoesPlayerOwnVehicle(source, plate, vehicle)
return true
endCreateUsableItem (optional)
Create a usable item, with a handler.
---@param item string
---@param cb function
function CreateUsableItem(item, cb)
-- ESX.RegisterUsableItem(item, cb)
endMoney functions
GetMoney
Get the player's current bank balance.
---@param source number
---@return number
function GetMoney(source)
return 0
endRemoveMoney
Remove money from a player's bank balance.
---@param source number
---@param amount number
---@return boolean
function RemoveMoney(source, amount)
return true
endRemoveMoneyOffline
Remove money from an offline character's bank balance.
---@param identifier string
---@param amount number
---@return boolean
function RemoveMoneyOffline(identifier, amount)
return true
endAddMoney
Add money to a player's bank balance.
---@param source number
---@param amount number
---@return boolean
function AddMoney(source, amount)
return true
endAddMoneyOffline
Add money to an offline character's bank balance.
---@param identifier string
---@param amount number
---@return boolean
function AddMoneyOffline(identifier, amount)
return true
endEvents
Player loaded
Trigger the lb-racing:playerLoaded event when a character has loaded.
---@param source number
---@param playerData { identifier: string }
AddEventHandler("yourFramework:playerLoaded", function(source, playerData)
TriggerEvent("lb-racing:playerLoaded", source, playerData.identifier)
end)Player unloaded
Trigger the lb-racing:playerUnloaded event when a character unloads.
AddEventHandler("yourFramework:playerUnloaded", function(source)
local identifier = GetIdentifier(source)
if identifier then
TriggerEvent("lb-racing:playerUnloaded", source, identifier)
end
end)