Controls

From this section, you can determine player controls for none resources.

Types


Player

Field
Type
Description
Required

source

number

Server id of the player

userId

number

Unique id of the player

key

string

Unique identifier of the player

fullname

string

Fullname of the player's character

phoneNumber

string

Phone number of the player's character

Server Exports


RegisterPlayer

Registers the player to the system after the player's character is loaded.

Parameters

RemovePlayer

Removes the player from the system after the player changes a character.

Parameters

  • playerId: number (Player's server id / source)

NewCharacter

Controls new character creation.

Parameters

Examples


RegisterNetEvent("selection:characterLoaded", function(pData)
    exports["no-base"]:RegisterPlayer({
        source = source,
        userId = pData.id,
        key = pData.identifier,
        fullname = pData.firstname .. " " .. pData.lastname,
        phoneNumber = pData.phoneNumber
    })
end)

RegisterNetEvent("selection:characterUnloaded", function(pData)
    exports["no-base"]:RemovePlayer(source)
end)

RegisterNetEvent("selection:newCharacter", function(pData)
    exports["no-base"]:NewCharacter({
        source = source,
        userId = pData.id,
        key = pData.identifier,
        fullname = pData.firstname .. " " .. pData.lastname,
        phoneNumber = pData.phoneNumber
    })
end)

-- Restart Handler
AddEventHandler("onResourceStart", function(resName)
    if resName ~= "no-base" then return end
    Wait(250)
    
    local players = GetLoadedCharacters()

    for _, pData in pairs(players) do
        exports["no-base"]:RegisterPlayer({
            source = pData.source,
            userId = pData.id,
            key = pData.identifier,
            fullname = pData.firstname .. " " .. pData.lastname,
            phoneNumber = pData.phoneNumber
        })
    end
end)

Last updated