Jump to content

Disable logging in.


'LinKin

Recommended Posts

Posted

Hello,

I want to allow players to login just via the login panel. So that if they click 'play as guest', it doesn't allow them to login later in-game.

I've not done any login-panel yet, but I've seen some scripts from the community and they use a function called logIn(acc, pass).

But, if I do cancelEvent() in onPlayerLogin, that function will not trigger (cause the event is cancelled)

So, how can I remove or change the /login command ?

Thanks.

Posted
addEventHandler("onPlayerJoin", root, 
function () 
    addEventHandler("onPlayerCommand", source, disableLoginCommand) 
end) 
  
function disableLoginCommand(command) 
    if (command == "login") then 
        cancelEvent() 
    end 
end 

Posted

Worked, thank you.

Btw: Why does the event onPlayerLogin triggers whenever a player joins the server? I don't have any autologin script or stuff like that.

Posted

onPlayerLogin is triggered when a player logs into their account. If you are not logged in, onPlayerLogin isn't triggered.

Posted

Oh,

I just noticed that the event you called was onPlayerJoin. Sorry my bad, I thought it was onPlayerLogin.

But now, is it mandatory to add the event onPlayerCommand inside onPlayerLogin event?

Why not simply;

addEventHandler("onPlayerCommand", root,

function(cmd)

if cmd == 'login' etc...

end)

Posted

Yes, you can also use it.

I attached the onPlayerCommand event to the player that joined the server, because in this case, you can enable that command to the player again.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...