'LinKin Posted February 12, 2014 Posted February 12, 2014 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.
DNL291 Posted February 12, 2014 Posted February 12, 2014 addEventHandler("onPlayerJoin", root, function () addEventHandler("onPlayerCommand", source, disableLoginCommand) end) function disableLoginCommand(command) if (command == "login") then cancelEvent() end end
'LinKin Posted February 12, 2014 Author Posted February 12, 2014 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.
DNL291 Posted February 12, 2014 Posted February 12, 2014 onPlayerLogin is triggered when a player logs into their account. If you are not logged in, onPlayerLogin isn't triggered.
'LinKin Posted February 12, 2014 Author Posted February 12, 2014 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)
DNL291 Posted February 12, 2014 Posted February 12, 2014 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.
'LinKin Posted February 12, 2014 Author Posted February 12, 2014 I've learnt something new Thank you again
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now