Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.28 KB | None | 0 0
  1. /client<---
  2.  
  3.  
  4. print("Lodaed vb client")
  5.  
  6. concommand.Add("vb4_register", function( p, c, a )
  7.     local DFrame1 = vgui.Create('DFrame')
  8.     DFrame1:SetSize(300, 300)
  9.     DFrame1:SetPos(0, 0)
  10.     DFrame1:SetTitle('Forum Registeration')
  11.     DFrame1:SetSizable(true)
  12.     DFrame1:SetDeleteOnClose(false)
  13.     DFrame1:MakePopup()
  14.  
  15.     local DTextEntry1 = vgui.Create('DTextEntry', DFrame1)
  16.     DTextEntry1:SetSize(100, 20)
  17.     DTextEntry1:SetPos(5, 50)
  18.     DTextEntry1:SetText('')
  19.  
  20.     local DLabel1 = vgui.Create('DLabel', DFrame1)
  21.     DLabel1:SetPos(8, 30)
  22.     DLabel1:SetText('Username:')
  23.     DLabel1:SizeToContents()
  24.  
  25.     local DTextEntry2 = vgui.Create('DTextEntry', DFrame1)
  26.     DTextEntry2:SetSize(100, 20)
  27.     DTextEntry2:SetPos(5, 100)
  28.     DTextEntry2:SetText('')
  29.  
  30.     local DLabel2 = vgui.Create('DLabel', DFrame1)
  31.     DLabel2:SetPos(8, 80)
  32.     DLabel2:SetText('Password:')
  33.     DLabel2:SizeToContents()
  34.  
  35.     local DLabel3 = vgui.Create('DLabel', DFrame1)
  36.     DLabel3:SetPos(8, 130)
  37.     DLabel3:SetText('Email:')
  38.     DLabel3:SizeToContents()
  39.  
  40.     local DTextEntry3 = vgui.Create('DTextEntry', DFrame1)
  41.     DTextEntry3:SetSize(100, 20)
  42.     DTextEntry3:SetPos(5, 150)
  43.     DTextEntry3:SetText('')
  44.  
  45.     // This is if you want a logo right of your username, password, and email.
  46.     /*
  47.     local DPanel1 = vgui.Create('DImage', DFrame1)
  48.     DPanel1:SetSize(296, 272)
  49.     DPanel1:SetPos(1, 25)
  50.     Dpanel1:SetMaterial( ) // Place some image here
  51.     */
  52.    
  53.     local DButton1 = vgui.Create('DButton', DFrame1)
  54.     DButton1:SetSize(70, 25)
  55.     DButton1:SetPos(115, 271)
  56.     DButton1:SetText('Submit')
  57.     DButton1.DoClick = function()
  58.         p:Register( DTextEntry1:GetValue(), DTextEntry2:GetValue(), DTextEntry3:GetValue() )
  59.     end
  60. end)
  61.  
  62.  
  63.  
  64.  
  65. //  server<---
  66.  
  67. print("VB4 registeration loaded!")
  68.  
  69. require("tmysql") // Were using tmysql 3 instead of 2.
  70. require("cryptopp") // For md5 encryption.
  71.  
  72. Host = "localhost"
  73. User = "tokiz"
  74. Pass = "0382"
  75. DB = "vbu"
  76. Port = 3306
  77.  
  78. tmysql.initialize( Host, User, Pass, DB, Port )
  79.  
  80. local PLAYER = _R.Player
  81.  
  82. function SQLHandle( result, _, error )
  83.     if error and error != 0 then
  84.         print( "SQL ERROR: " .. error )
  85.     end
  86. end
  87.  
  88. function PLAYER:Register( user, pass, email )
  89.     local validemail1 = string.find(email, "@")
  90.     local validemail2 = string.find(email, ".")
  91.     if self.Registered then return false end
  92.     if !user or !pass or !email then return false end
  93.    
  94.     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 )
  95.     self:ChatPrint( "[VB] You have successfully registered." )
  96.     self.Registered = true
  97. end
  98.  
  99. function PLAYER:IsRegistered( )
  100.     tmysql.query( "SELECT `steamid` FROM `user` WHERE `steamid`= '" .. self:SteamID() .. "'", function ( Args )
  101.         if Args[1] then
  102.             self.Registered = true
  103.             self:ChatPrint( "[VB] Welcome back " .. self:Nick() .. " remember to visit our forums." )
  104.         else
  105.             self.Registered = false
  106.             self:ChatPrint( "[VB] You have register to play on our servers." )
  107.             RunConsoleCommand( "vb4_register" )
  108.         end
  109.     end)
  110. end
  111.  
  112. hook.Add("PlayerInitialSpawn", "CheckRegisteredStatus", function( p )
  113.     if p:IsPlayer() then
  114.         p:IsRegistered()
  115.     end
  116. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement