Guest User

Untitled

a guest
Aug 7th, 2018
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. function login(source,cmd,username,password)
  2.     if not username then -- Check if they've not entered a username
  3.         outputChatBox("login: Please specify a username and password",source,255,168,0)
  4.         return false
  5.     end
  6.     if not password then -- If they haven't specified a password, presume they're using '/login [password]'
  7.         password = username
  8.         username = getPlayerName(source)
  9.     end
  10.     if isGuestAccount(getPlayerAccount(source)) then -- They aren't logged in.
  11.         local account = getAccount(username,password) -- Parse the account
  12.         if account then
  13.             logIn(source,account,password) -- Attempt to login
  14.         else -- They entered incorrect credentials.
  15.             outputChatBox("login: Invalid credentials",source,255,168,0)
  16.         end
  17.     else -- They're logged in.
  18.         outputChatBox("login: You are already logged in",source,255,168,0)
  19.     end
  20. end
  21. addCommandHandler("login",login,false,false)
Add Comment
Please, Sign In to add comment