Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. function registerPlayer(userName,password,passwordReEntry)
  2.     if userName ~= nil and password ~= nil and passwordReEntry ~= nil then
  3.         local checkIfAccountAvailable = executeSQLQuery("SELECT * FROM accounts WHERE accountname =?",userName)[1]
  4.         outputChatBox(tostring(checkIfAccountAvailable))
  5.         if (string.len(password) < 6) then
  6.             outputChatBox("Your password should be at least 6 chars. long!",client,255,0,0)
  7.         elseif (password ~= passwordReEntry) then
  8.             outputChatBox("Your password and your re-enter arent the same!",client,255,0,0)
  9.         elseif (string.len(userName) <= 0) then
  10.             outputChatBox("Please insert an username!",client,255,0,0)
  11.         elseif (#checkIfAccountAvailable == 1 ) then
  12.             outputChatBox("#FF0000This Username is already taken!#FFFFFF( "..userName.." )", client, 255,0,0, true)
  13.             return
  14.         elseif userName and password == passwordReEntry then
  15.             local ipFromPlayerRegistered = getPlayerIP(client)
  16.             local serialFromPlayerRegistered = getPlayerSerial(client)
  17.             executeSQLInsert("accounts","'"..userName.."','"..password.."',0,'"..ipFromPlayerRegistered.."','"..serialFromPlayerRegistered.."'","accountname,accountpassword,level,ip,serial")
  18.             outputChatBox("#FF0000Your account has been successfully created!#FFFFFF(User: "..tostring(userName)..", Password: "..tostring(password)..")",client,255,0,0,true)
  19.             triggerClientEvent("onRegisterDone",getRootElement())
  20.         end
  21.     end
  22. end
  23.  
  24. addEvent("onClientRegisterFinish",true)
  25. addEventHandler("onClientRegisterFinish",getRootElement(),registerPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement