BRIDGE

Bridged Frameworks

For frameworks set up in the bridge folder, such as QBCore and ESX (es_extended), this script serves as a direct replacement for their default login scripts. Therefore, you need to remove the following scripts to avoid conflicts.

ESX: esx_identity QBCore: qb-multicharacter

Adding more frameworks

Expanding support for additional frameworks is relatively straightforward! As long as you have a basic understanding of what you're doing, it can be done quite easily.

Overrides

In rat-login, the Override function is utilized to replace existing functions with the ones you define.

function definition
Override(name --[[string]], callback --[[function]])

Here's an example of how an Override function is used to help you understand its implementation:

example
Override(
    "OnOpenLogin", -- name of override
    function(source) -- callback, as you can see it returns the source of the player
        print(("Player %s has opened the login!"):format(GetPlayerName(source))
        -- when a player opens the login it will print the above.
        -- this could be used to expand your logging!
    end
)

Server

Client

Argument Functions

These functions require no parameters.

Character Data Layout / charData

charData layout
{
    firstName : string,
    lastName : string,
    dateofbirth : string,
    nationality : string,
    gender : number
}

Example

In this example we'll use a framework called rat

Override(
    "OnSelect", -- name if override
    function(source, identifier, cleanup) -- callback
        -- code inside callback here
        
        -- lets try login using our rat framework!
        if Rat.Player.Login(source, identifier) then
            -- if the login was successful then we don't need the menu anymore!
            cleanup() -- call cleanup to close the menu
        else
            -- oops the login didn't work, something went wrong!
            -- but all good, we won't close the login and just post an error!
            error(
                ("%s failed to login with identifier %s"):format(
                    GetPlayerName(source),
                    identifier
                )
            )
        end
    end
)

Bridged Skin Scripts

For external third-party skin scripts, you are required to register a callback function inside the bridge/skin.lua file. Below is an example code snippet.

function definition
RegisterSkinAddon(name --[[string]], callback --[[function]])

Now, let's say we want to add support for a skin script called rat-skin. It could look something like this:

bridge/skin.lua
RegisterSkinAddon(
    "rat", --[[define a name]]
    function(ped, skin) --[[define callback]]
        -- ped is the entity you are trying to apply the skin too
        -- skin is the table retrieved from the database
        
        -- if our skin script uses exports, lets call it!
        exports["rat-skin"]:ApplySkinToPed(ped, skin)

        -- if our skin script uses events, that's easy too!
        TriggerEvent("rat-skin:ApplySkinToPed", ped, skin)
    end
)

Now that we've defined the function, all we need to do is let the script know we want to use it! Inside the config.lua file, find the line Config.SkinScript and set it as follows:

config.lua
Config.SkinScript = "rat"

Notice how the name we've set inside the config.lua file matches what we defined in bridge/skin.lua.

Last updated