'LinKin Posted February 12, 2014 Share 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. Link to comment
DNL291 Posted February 12, 2014 Share Posted February 12, 2014 addEventHandler("onPlayerJoin", root, function () addEventHandler("onPlayerCommand", source, disableLoginCommand) end) function disableLoginCommand(command) if (command == "login") then cancelEvent() end end Link to comment
'LinKin Posted February 12, 2014 Author Share 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. Link to comment
DNL291 Posted February 12, 2014 Share Posted February 12, 2014 onPlayerLogin is triggered when a player logs into their account. If you are not logged in, onPlayerLogin isn't triggered. Link to comment
'LinKin Posted February 12, 2014 Author Share 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) Link to comment
DNL291 Posted February 12, 2014 Share 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. Link to comment
'LinKin Posted February 12, 2014 Author Share Posted February 12, 2014 I've learnt something new Thank you again Link to comment
Bonsai Posted February 12, 2014 Share Posted February 12, 2014 Wow, I could also need this. Thanks Link to comment
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