Klesh Posted April 24, 2011 Share Posted April 24, 2011 Community of MTA team, i have a script, is a login panel all works good and fine, register/login, but the only think no works is in the login panel on Username no gets the player name so here is the code; addEvent ("login", true) addEvent ("register", true) addEvent ("checkaccname", true) function login (uname, pass) local account = getPlayerName ( uname ) if ( account ~= false ) then logIn ( source, account, tostring(pass) ) triggerClientEvent ( "hide", source ) else outputChatBox ( "Wrong username or password!", source, 255, 255, 0 ) end end addEventHandler ( "login", getRootElement(), login ) function register (uname, pass) if ( pass ~= "" and pass ~= nil ) then local accountAdded = addAccount( uname, pass ) if ( accountAdded ) then outputChatBox ( "Thank you " .. getPlayerName(source) .. ", you're now registed, Username : " .. uname .. " Password : " .. pass .. " remember it for login !", source ) logIn ( source, uname, tostring(pass) ) triggerClientEvent ( "hide", source ) else outputChatBox ( "Error creating account, contact the server admin", source ) end else outputChatBox ( "Error creating account, Enter your password", source ) end end addEventHandler ( "register", getRootElement(), register ) function check () account = getPlayerAccount ( source ) name = getPlayerName ( account ) if name ~= "guest" then triggerClientEvent ( "hide", source ) else triggerClientEvent ( "show", source ) end end addEventHandler ( "checkaccname", getRootElement(), check ) function login () name = getPlayerName ( source ) if name ~= "guest" then triggerClientEvent ( "hide", source ) else triggerClientEvent ( "show", source ) end end addEventHandler ( "onPlayerLogin", getRootElement(), login ) Any help is grate! thanks to all!! Link to comment
CowTurbo Posted April 25, 2011 Share Posted April 25, 2011 addEvent ("login", true) addEvent ("register", true) addEvent ("checkaccname", true) function login (uname, pass) local account = getPlayerName ( uname ) if ( account ~= false ) then logIn ( source, account, tostring(pass) ) triggerClientEvent ( "hide", source ) else outputChatBox ( "Wrong username or password!", source, 255, 255, 0 ) end end addEventHandler ( "login", getRootElement(), login ) function register (uname, pass) if ( pass ~= "" and pass ~= nil ) then local accountAdded = addAccount( uname, pass ) if ( accountAdded ) then outputChatBox ( "Thank you " .. getPlayerName(source) .. ", you're now registed, Username : " .. uname .. " Password : " .. pass .. " remember it for login !", source ) logIn ( source, uname, tostring(pass) ) triggerClientEvent ( "hide", source ) else outputChatBox ( "Error creating account, contact the server admin", source ) end else outputChatBox ( "Error creating account, Enter your password", source ) end end addEventHandler ( "register", getRootElement(), register ) function check () account = getPlayerAccount ( source ) name = getPlayerName ( source) if name ~= "guest" then triggerClientEvent ( "hide", source ) else triggerClientEvent ( "show", source ) end end addEventHandler ( "checkaccname", getRootElement(), check ) function login () name = getPlayerName ( source ) if name ~= "guest" then triggerClientEvent ( "hide", source ) else triggerClientEvent ( "show", source ) end end addEventHandler ( "onPlayerLogin", getRootElement(), login ) You were name = getPlayerName ( account) have to be name = getPlayerName ( source) 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