Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. print("VB4 registeration loaded!")
  2.  
  3. require("tmysql") // Were using tmysql 3 instead of 2.
  4. require("cryptopp") // For md5 encryption.
  5.  
  6. Host = "localhost"
  7. User = "tokiz"
  8. Pass = "1234"
  9. DB = "vbu"
  10. Port = 3306
  11.  
  12. tmysql.initialize( Host, User, Pass, DB, Port )
  13.  
  14. local PLAYER = _R.Player
  15.  
  16. function SQLHandle( result, _, error )
  17.     if error and error != 0 then
  18.         print( "SQL ERROR: " .. error )
  19.     end
  20. end
  21.  
  22. function PLAYER:Register( user, pass, email )
  23.     local validemail1 = string.find(email, "@")
  24.     local validemail2 = string.find(email, ".")
  25.     if self.Registered then return false end
  26.     if !user or !pass or !email then return false end
  27.    
  28.     tmysql.query("INSERT INTO `user` ( `username`, `password`, `passworddate`, `email`, `joindate`, `ipaddress`, `steamid` ) VALUES ( '" .. tmysql.escape(user) .. "', '" .. tmysql.escape(pass) .. "', '" .. os.date() .. "', '" .. tmysql.escape(email) .. "', '" .. os.date() .. "', '" .. self:IPAddress() .. "', '" .. self:SteamID() .. "' )" , SQLHandle )
  29.     self:ChatPrint( "[VB] You have successfully registered." )
  30.     self.Registered = true
  31. end
  32.  
  33. function PLAYER:IsRegistered( )
  34.     tmysql.query( "SELECT `steamid` FROM `user` WHERE `steamid`= '" .. self:SteamID() .. "'", function ( Args )
  35.         if Args[1] then
  36.             self.Registered = true
  37.             self:ChatPrint( "[VB] Welcome back " .. self:Nick() .. " remember to visit our forums." )
  38.         else
  39.             self.Registered = false
  40.             self:ChatPrint( "[VB] You have register to play on our servers." )
  41.             RunConsoleCommand( "vb4_register" )
  42.         end
  43.     end)
  44. end
  45.  
  46. hook.Add("PlayerInitialSpawn", "CheckRegisteredStatus", function( p )
  47.     if p:IsPlayer() then
  48.         p:IsRegistered()
  49.     end
  50. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement