Server Side Exports

Working on this docs! [NOT FINISHED]

At the top of your server file. You will need to call the Framework's exports. This step is very crucial for all the exports to work properly.

Framework = exports["framework"]:getServerFunctions()    

The "framework" will be the folder name the FiveM owner has in its resource. We recommend making this option configurable as not all users will have the default folder called framework.

Framework.getPlayers()

Using this export you will be able to get all the active players with all their character info and print it. here is an exmaple

for _, player in pairs(Framework.getPlayers()) do 
    print(json.encode(player))
end
Framework.getPlayer()

Using this export you can get any player as long as they are in the server and logged in.

RegisterCommand("dob", function(source, args, message)
    local player = Framework.getPlayer(source)
    if(player) then    
        TriggerClientEvent('chatMessage', player.src, player.dob)
    else 
        TriggerClientEvent('chatMessage', source, "You are on in the framework")
    end
end)
Framerwork.getDiscord()

There are two ways you can get someones discord. If they are logged in the framework. Use the Framework.getPlayer() otherwise Framework.getDiscord(). Here is an example

RegisterCommand('discord', function(source, args, message) 
    local player = Framework.getPlayer(source)
    -- If the player isn't online in the framework it will use the native way.
    if(player) then    
        TriggerClientEvent('chatMessage', player.src, player.discord)
    else
        local discord = Framework.getDiscord(source)
        if(discord) then
            TriggerClientEvent('chatMessage', source, discord)
        else     
            TriggerClientEvet('chatMessage', source, "Your discord isnt linked")
        end
    end 
end)
Framework.getSteam()

There are two ways you can get someones discord. If they are logged in the framework. Use the Framework.getPlayer() otherwise Framework.getSteam(). Here is an example:

RegisterCommand('steam', function(source, args, message) 
    local player = Framework.getPlayer(source)
    -- If the player isn't online in the framework it will use the native way.
    if(player) then    
        TriggerClientEvent('chatMessage', player.src, player.steam)
    else
        local steam = Framework.getSteam(source)
        if(steam) then
            TriggerClientEvent('chatMessage', source, steam )
        end
    end 
end)

Framework.checkAdmin()

To check if a user is an admin is very simple. This will also check if they are logged into the framework. here is an exmaple

RegisterCommand('checkadmin', function(source, message, args) 
    if(Framework.checkAdmin(source) then    
        TriggerClientEvent('chatMessage', source, "you are an admin your cool")
    else 
        TriggerClientEvent('chatMessage', source, "You are not an admin")
    end
end)

Framework.extractIdentifier()

Very usful function to extract all a players identifiers. Below a simple way to display someones identifier. Please note this also grabs ips as well.

RegisterCommand("extract", function(source, args, message)
    local everything = Framework.extractIdentifier(source)
    print(json.encode(everything); -- display everything
    print(everything.discord); -- display users discord

end)

Last updated

Was this helpful?