Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check if a server is a reserved server?

Asked by
spynaz 30
8 years ago

How do I check if the current server is a reserved server? I know that I can use the LocalPlayerArrivedFromTeleport event however that allows you to check only on the client but I'm looking for a way to figure this out on the server-side.

0
use the event and relay it to a server script lukeb50 631 — 8y
0
yea I was thinking of that too but I was just wondering if there is another, more efficient way to do it spynaz 30 — 8y

1 answer

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
8 years ago

The DataModel (also known as the lua globals "game" or "Game") thankfully has two values you can use for managing reservations: VIPServerId and VIPServerOwnerId.

Under own testing, i found that when a server is not a reserved one (and therefore above values don't get affected), said values default to a blank string and 0 respectively.

Meaning:

print(game.VIPServerId) print(game.VIPServerOwnerId) (Semicolon is not necessary for Lua)

Returns:

--blank
0

Thus, if you wanted to check whether or not a server was VIP...

--This works on server and can work on client if game.Loaded is removed
game.Loaded:connect(function() --Fires when game loads for the first time. Just to make sure VIPServerId is processed, but this might not be needed after all.
    if game.VIPServerId ~= "" then --We must add a string comparison, because string value holders cannot be nil
        print("This server is a VIP server managed by user id " .. game.VIPServerOwnerId)
    else
        print("This server is a run-of-the-mill public server")
    end
end)
Ad

Answer this question