Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /client<---
- print("Lodaed vb client")
- concommand.Add("vb4_register", function( p, c, a )
- local DFrame1 = vgui.Create('DFrame')
- DFrame1:SetSize(300, 300)
- DFrame1:SetPos(0, 0)
- DFrame1:SetTitle('Forum Registeration')
- DFrame1:SetSizable(true)
- DFrame1:SetDeleteOnClose(false)
- DFrame1:MakePopup()
- local DTextEntry1 = vgui.Create('DTextEntry', DFrame1)
- DTextEntry1:SetSize(100, 20)
- DTextEntry1:SetPos(5, 50)
- DTextEntry1:SetText('')
- local DLabel1 = vgui.Create('DLabel', DFrame1)
- DLabel1:SetPos(8, 30)
- DLabel1:SetText('Username:')
- DLabel1:SizeToContents()
- local DTextEntry2 = vgui.Create('DTextEntry', DFrame1)
- DTextEntry2:SetSize(100, 20)
- DTextEntry2:SetPos(5, 100)
- DTextEntry2:SetText('')
- local DLabel2 = vgui.Create('DLabel', DFrame1)
- DLabel2:SetPos(8, 80)
- DLabel2:SetText('Password:')
- DLabel2:SizeToContents()
- local DLabel3 = vgui.Create('DLabel', DFrame1)
- DLabel3:SetPos(8, 130)
- DLabel3:SetText('Email:')
- DLabel3:SizeToContents()
- local DTextEntry3 = vgui.Create('DTextEntry', DFrame1)
- DTextEntry3:SetSize(100, 20)
- DTextEntry3:SetPos(5, 150)
- DTextEntry3:SetText('')
- // This is if you want a logo right of your username, password, and email.
- /*
- local DPanel1 = vgui.Create('DImage', DFrame1)
- DPanel1:SetSize(296, 272)
- DPanel1:SetPos(1, 25)
- Dpanel1:SetMaterial( ) // Place some image here
- */
- local DButton1 = vgui.Create('DButton', DFrame1)
- DButton1:SetSize(70, 25)
- DButton1:SetPos(115, 271)
- DButton1:SetText('Submit')
- DButton1.DoClick = function()
- p:Register( DTextEntry1:GetValue(), DTextEntry2:GetValue(), DTextEntry3:GetValue() )
- end
- end)
- // server<---
- print("VB4 registeration loaded!")
- require("tmysql") // Were using tmysql 3 instead of 2.
- require("cryptopp") // For md5 encryption.
- Host = "localhost"
- User = "tokiz"
- Pass = "0382"
- DB = "vbu"
- Port = 3306
- tmysql.initialize( Host, User, Pass, DB, Port )
- local PLAYER = _R.Player
- function SQLHandle( result, _, error )
- if error and error != 0 then
- print( "SQL ERROR: " .. error )
- end
- end
- function PLAYER:Register( user, pass, email )
- local validemail1 = string.find(email, "@")
- local validemail2 = string.find(email, ".")
- if self.Registered then return false end
- if !user or !pass or !email then return false end
- 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 )
- self:ChatPrint( "[VB] You have successfully registered." )
- self.Registered = true
- end
- function PLAYER:IsRegistered( )
- tmysql.query( "SELECT `steamid` FROM `user` WHERE `steamid`= '" .. self:SteamID() .. "'", function ( Args )
- if Args[1] then
- self.Registered = true
- self:ChatPrint( "[VB] Welcome back " .. self:Nick() .. " remember to visit our forums." )
- else
- self.Registered = false
- self:ChatPrint( "[VB] You have register to play on our servers." )
- RunConsoleCommand( "vb4_register" )
- end
- end)
- end
- hook.Add("PlayerInitialSpawn", "CheckRegisteredStatus", function( p )
- if p:IsPlayer() then
- p:IsRegistered()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement