Multiple keymasters

Hello folks. I wanted to ask whether you can use multiple keymasters on one server. I’m fairly new to this and unfortunately have no idea, so thanks for the help.

Only one license key can be used per server. Why would you need to use multiple?

I can answer the question as to why. My co-owner just bought a vehicle for our server but now has to transfer it to me so we can use it in our server. If you could link additional keys, co-owners/co-directors and/or dev members of the server could have their own assets for the community and if that person decides to leave and go to a new community, they could take the things they purchased with them by cancelling their secondary key for that server.

3 Likes

This would be great. I’m currently having the same issue. It’s putting a hold on everything because neither one of us want to give up all the money we have spent.

I currently have this predicament and im having to ensure people are keeping a copy of purchase to ensure there protection of the asset but being able to use multiple key masters would ensure those that buy the asset have control over it. Unfortunately not everyone is trustworthy in this community and i have see people take assets or money from players and then ban them as soon as the asset is transferred. Its really sad but extremely difficult to find honest and trust worthy people and to add multiple key master uses would just give those that want to share assets in servers that extra peace of mind

this is an interesting thought experiment, I wonder how this would affect a server if someone were to just up and leave, probably wouldn’t be good considering the fact that some of the scripts and assets associated with the community would be removed and could break a lot of things.

I mean yeah but its more safe if it would be like that cause no one could scam anyone

Sorry for the necro post, but I’ve been working on a way to do it with a script. However, even though the native exists to set convars, it doesn’t like to set the sv_licenseKey as a convar to load the other assets.

It would be nice to not have to transfer assets to another person, and if that person decided to close the server, they’ve basically gotten themselves a butt-load of free assets.

I’m not saying it’s short sighted of cfx to allow multiple keys, but it would make it easier.

For anyone that’s interested, I’ll link a copy of the code.

-- loader.lua
local keys = {
    PRIMARY_CFX_KEY = {"resource1", "resource2"},
    SECONDARY_CFX_KEY = {"secondary_resource1", "secondary_resource2"},
    TERTIARY_CFX_KEY = {"tertiary_resource1", "tertiary_resource2"},
    -- Add more keys and resources as needed
}

-- Function to load resources with a specified key
function loadResourcesWithKey(key, resources)
    SetConvar("sv_licenseKey", key)
    for _, resource in ipairs(resources) do
        ExecuteCommand("ensure " .. resource)
    end
end

-- Load resources for each key
for key, resources in pairs(keys) do
    loadResourcesWithKey(key, resources)
end

You’ll have to load it as a server_script in your fxmanifest.

I’ve tried it, but it doesn’t like it. It’s not spitting out any errors in the console, it just says you lack the prerequisites.

Well enjoy.

(PS) I posted this because I hate finding a topic when I search, but then it either dies, or someone says “Nvm I fixed it” without telling others how. :person_shrugging:

Have you got this to work?

This most likely won’t work because a server key is authenticated at server startup and can’t be “hot swapped” during runtime as far as I recall, that’s a major security liability right there

Try this:
– Table containing keys and their associated resources
local keys = {
PRIMARY_CFX_KEY = {“resource1”, “resource2”},
SECONDARY_CFX_KEY = {“secondary_resource1”, “secondary_resource2”},
TERTIARY_CFX_KEY = {“tertiary_resource1”, “tertiary_resource2”},
– Add more keys and resources as needed
}

– Function to load resources with a specified key
local function loadResourcesWithKey(key, resources)
– Ensure the key and resources are valid
if not key or type(resources) ~= “table” then
print(“^1[ERROR] Invalid key or resources provided.”) – Error message for better logging
return
end

-- Set the server license key (FiveM specific)
SetConvar("sv_licenseKey", key)
print("^2[INFO] License key set to: " .. key) -- ^2 is color code for green in FiveM console

-- Loop through and ensure each resource is loaded (FiveM command)
for _, resource in ipairs(resources) do
    ExecuteCommand("ensure " .. resource)
    print("^3[INFO] Ensuring resource: " .. resource) -- ^3 is yellow for resource loading
end

end

– Iterate over each key and its associated resources
for key, resources in pairs(keys) do
loadResourcesWithKey(key, resources)
end

That’s not going to work, the server key is authenticed at server startup and can’t be swapped while a server is running, that’s just not possible

Second this, would make life a lot more easier and open up to a lot more opportunities to work with other people and not worry about losing everything you paid for if it all hits the fan!