• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ How to make a server open to some characters?

Sleet

Member
Joined
Sep 3, 2016
Messages
107
Solutions
2
Reaction score
7
I want to start a "closed alpha" test phase in my server. Just like the test servers of Tibia.

I want to make only the characters that are 'whitelisted' able to enter the server. I do not want, however, to make people not able to create accounts, characters, and etc.

How do I make this?
 
What exact problem do you have? When noone is able to create a new account or character then you have full control over who's gonna log in, no?

Other than that there are a million possibilities, from modyfing the game server to setting up a VPN tunnel.

Can't really think of a concept for your server's alpha stage without knowing the exact setup/scenario.

Edit
----

I've just seen that you don't want to disable your account creation. Then a few options come to mind:
- new field in the database
- new group that includes testers, not not sure if there's a flag for not allowing login
- adding an option to config.lua where you can specify an array of testers and modify source accordingly
- ban everyone by default and unban those who may play, and change the message you get when logging in
Soo quite some work probably, unless it's possible with groups.
 
Last edited:
For fast working product just do it in already existing OnLogin Lua func.

If you want to keep it for long time consider creating the system in engine source (C++) and add xml/lua player name list to read.
 
I'm trying to make the code with no success.

Here it is:

Lua:
function onLogin()
    if getPlayerAccountType() == ACCOUNT_TYPE_GOD then
        return true
    elseif getPlayerAccountType() ~= ACCOUNT_TYPE_GOD then
        if getPlayerStorageValue(989898) ~= 1 then
            doPlayerPopupFYI("message1")
        elseif getPlayerStorageValue(989898) == 1 then
            doPlayerPopupFYI("message2")
        end
    end
    return true
end

No error messages appear, but the normal player enters the server and no FYI box appears.

What am I doing wrong?

PS: I don't know how to make the player logout. I think it is by using the RemoveCreature function, but I don't know how to use it as well.
 
Last edited:
Maybe you have not registered your new onLogin? Use the old one (Default path: data/creaturescripts/scripts/login.lua) and add it there.

Also you need to refer to some player id. You should get the player cid in function argument. Then you should call the methods from that cid and finally logout the player

In tfs 1.2 its done that way:
local player = Player(cid)
player:remove()
 
Maybe you have not registered your new onLogin? Use the old one (Default path: data/creaturescripts/scripts/login.lua) and add it there.

Also you need to refer to some player id. You should get the player cid in function argument. Then you should call the methods from that cid and finally logout the player

In tfs 1.2 its done that way:
local player = Player(cid)
player:remove()

Where do I register it? In creaturescripts.lua? Because if so, I have already done that...

Here, I edited the code and it looks like this now:


Lua:
function onLogin()
local player = Player(cid)
    if player:getAccountType() == ACCOUNT_TYPE_GOD then
        return true
    elseif player:getAccountType() ~= ACCOUNT_TYPE_GOD then
        if player:getStorageValue(989898) ~= 1 then
            player:popupFYI("message1")
        elseif player:getStorageValue(989898) == 1 then
            player:popupFYI("message2")
        end
    end

    return true
end

However, it gives me this error when logging in with the character:

Screenshot

And I can't enter the game, it stays on this screen:

Screenshot








EDIT:







Ok, I managed to register the event *properly*, dumb me was doing it the wrong way.
Now I need to know how to make a player log out, how can I do that?

Here's the latest script:

Lua:
function onLogin(cid)
    local player = Player(cid)
    if player:getAccountType() == 6 then
        return true
    else
        if player:getStorageValue(989898) ~= 1 then
            player:popupFYI("message 1")
            return true
        end
    end
end
 
Last edited:
I have no idea on what tfs version you are working on, but if the methods cid:method() work for you I can assume you are on some 1.x

As I said, the working solution for 1.2 player dc is
Lua:
local player = Player(cid)
player:remove()
 
Thanks to all of you guys. However, I managed to find a solution even better than my first idea. If the player walks away from the spawn tile, he will get teleported back to this tile and will receiva a message. Thanks, guys.
 
Back
Top