Jump to content

getPlayerName


Klesh

Recommended Posts

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
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

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...