Steam Required to join

I have been searching forever and cant seem to find my answer. I have seen a lot of other servers where you have to have steam running in the background and i would like to have that same feature for my server. I have already tried the set steam_webApiKey “” but i am still able to connect to my server without steam running in the background.

1 Like

Great you asked me in that other topic. Yes, there is an option out there.

AddEventHandler('playerConnecting', function(name, err)
    local steam = false

    for k,v in pairs(GetPlayerIdentifiers(source)) do
        if v:find("steam:") then    
            steam = true
        end
    end
    if not steam then
        err("Steam is required to join the server!")
        CancelEvent()
        return
    end
end)

where would i put this?

1 Like

Server file. Pretty much anywhere if its defined as server_script.

so server.cfg? or just in any resource that has server.lua? sorry im a noob and dont know a lot about this stuff

server.lua, find this file anywhere in your scripts and just put it somewhere on the bottom.

okay let me test it out. give me a second

okay wait i am confusing my self. So i am in my resource folder and all i have to do is find a resource with server.lua?

Yup, if you’re using ESX, then find es_extended>server>main.lua or something, in any file you should have server sub-directory. There should be server script by any name.

okay i am just going to do it in my Area-of-Partol>server.lua

Okay it worked and it does not let me join without steam running. But when i do have steam running this happens when i try and join

What is showing in the server console?

this

I’ve edited script, I’m an idiot.

AddEventHandler('playerConnecting', function(name, err)
    local steam = false

    for k,v in pairs(GetPlayerIdentifiers(source)) do
        if v:find("steam:") then    
            steam = true
        end
    end
    if not steam then
        err("Steam is required to join the server!")
        CancelEvent()
        return
    end
end)

this will work

1 Like

lol… like this?

Yes, for 100%

now its back to normal. i can join without steam open :frowning:

Then Steam is logged in. That’s the point. In any case, you can retrieve steam identifier from player.

This is the script’s server.lua that i put the code in and this is what the console is saying

Replace these weird ‘ with normal ’