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', player.src, discord)
        else     
            TriggerClientEvet('chatMessage', source, "Your discord isnt linked")
        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)

Last updated