[DMC] Posted October 29, 2010 Share Posted October 29, 2010 I had an question on how to disable /login and make my own login code and yes i know from wiki but i wanna cancel the mta /login event function loginPlayer ( thePlayer, command, username, password ) local account = getAccount ( username, password ) -- Return the account if ( account ~= false ) then -- If the account exists. logIn ( thePlayer, account, password ) -- Log them in. else outputChatBox ( "Wrong username or password!", thePlayer, 255, 255, 0 ) end end addCommandHandler ( "login", loginPlayer ) or is it possible to example my name is dmc and i wanna login to sss it says, error you cant login to a other name so it needs to be dmc, if this is possible without the above stuff please help, tell me Link to comment
dzek (varez) Posted October 29, 2010 Share Posted October 29, 2010 onPlayerLogin should have an argument with account element or account name.. just compare it to source name. if different - cancel event. 6-8 lines of script. anyway players can change their nick after login, until you block it too of course so what is the point? and even if you block changing nick - they can disconnect, change, get back Link to comment
12p Posted October 29, 2010 Share Posted October 29, 2010 anyway players can change their nick after login, until you block it too of course so what is the point? and even if you block changing nick - they can disconnect, change, get back but they can't join with his/her account so they have to disconnect, change and return with loggeable nick Link to comment
[DMC] Posted October 30, 2010 Author Share Posted October 30, 2010 this is what i got function loginPlayer ( thePlayer, command, username, password ) local account = getAccount ( username, password ) if ( account ~= false ) then name = getPlayerName(thePlayer) if getAccountName(account) == name then logIn ( thePlayer, account, password ) outputChatBox ( "Welcome", thePlayer, 255, 255, 0 ) else outputChatBox ( "ERROR: Your Username or Password is invalid", thePlayer, 255, 255, 0 ) end else cancelEvent() outputChatBox("ERROR: You can't login to this name",thePlayer,255,0,0) end end addCommandHandler ( "login", loginPlayer Link to comment
dzek (varez) Posted October 30, 2010 Share Posted October 30, 2010 remove addCommandHandler and replace it with onPlayerLogin event handler Link to comment
[DMC] Posted October 31, 2010 Author Share Posted October 31, 2010 this? function loginPlayer ( thePlayer, command, username, password ) local account = getAccount ( username, password ) if ( account ~= false ) then name = getPlayerName(thePlayer) if getAccountName(account) == name then logIn ( thePlayer, account, password ) outputChatBox ( "Welcome", thePlayer, 255, 255, 0 ) else outputChatBox ( "ERROR: Your Username or Password is invalid", thePlayer, 255, 255, 0 ) end else cancelEvent() outputChatBox("ERROR: You can't login to this name",thePlayer,255,0,0) end end addEventHandler( "onPlayerLogin", rootElement, loginPlayer ) Link to comment
dzek (varez) Posted October 31, 2010 Share Posted October 31, 2010 function loginPlayer (prev,curr,auto) local accname = getAccountName(curr) local plname = getPlayerName(source) if (accname~=plname) then outputChatBox("You can't login to this account.", source) cancelEvent() end end addEventHandler("onPlayerLogin", rootElement, loginPlayer) 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