• MyBB registration error
    3 replies, posted
Lua Error: Hook [addons\mybb\lua\autorun\cl_mybb.lua:4] attempt to call global 'LocalPlayer' (a nil value) I don't know how to fixed i try a lot of but i give up. cl_mybb.lua [CODE] print("This server is running MyBB Registeration by Clark(Aide)") concommand.Add("mybb_register", function( ) local p = LocalPlayer() DFrame1 = vgui.Create("DFrame") DFrame1:SetSize(186, 224) DFrame1:SetPos(ScrW() / 2 - 63, ScrH() / 2 - 112) DFrame1:SetTitle("Account Creation") DFrame1:SetSizable(true) DFrame1:SetDeleteOnClose(false) DFrame1:ShowCloseButton(false) DFrame1:MakePopup() DFrame1.Paint = function() draw.RoundedBox( 6, 0, 0, 186, 224, Color( 29, 36, 53, 255 ) ) end local DImage9 = vgui.Create("DImageButton", DFrame1) DImage9:SetSize(16, 16) DImage9:SetPos(164, 4) DImage9:SetImage( "gui/silkicons/folder_go" ) DImage9:SetToolTip( "Already have an account?" ) DImage9:SizeToContents() DImage9.DoClick = function() RunConsoleCommand("mybb_link") DFrame1:Close() end // Username local DLabel1 = vgui.Create("DLabel", DFrame1) DLabel1:SetPos(10, 30) DLabel1:SetText("Username") DLabel1:SizeToContents() local DTextEntry1 = vgui.Create("DTextEntry", DFrame1) DTextEntry1:SetSize(125, 20) DTextEntry1:SetPos(30, 44) DTextEntry1:SetText("") DTextEntry1.Think = function( ) local username = DTextEntry1:GetValue() if string.len(username) > 5 then DImage5:SetImage( "gui/silkicons/check_on" ) end end local DImage1 = vgui.Create("DImage", DFrame1) DImage1:SetSize(16, 16) DImage1:SetPos(10, 44) DImage1:SetImage("gui/silkicons/user") DImage1:SizeToContents() DImage5 = vgui.Create("DImage", DFrame1) DImage5:SetSize(16, 16) DImage5:SetPos(160, 44) DImage5:SetImage( "gui/silkicons/check_off" ) DImage5:SizeToContents() // Password local DLabel2 = vgui.Create("DLabel", DFrame1) DLabel2:SetPos(10, 68) DLabel2:SetText("Password") DLabel2:SizeToContents() local DTextEntry2 = vgui.Create("DTextEntry", DFrame1) DTextEntry2:SetSize(125, 20) DTextEntry2:SetPos(30, 83) DTextEntry2:SetText("") DTextEntry2.Think = function( ) local password = DTextEntry2:GetValue() if string.len(password) > 5 then DImage6:SetImage( "gui/silkicons/check_on" ) end end local DImage2 = vgui.Create("DImage", DFrame1) DImage2:SetSize(16, 16) DImage2:SetPos(10, 83) DImage2:SetImage("gui/silkicons/shield") DImage2:SizeToContents() DImage6 = vgui.Create("DImage", DFrame1) DImage6:SetSize(16, 16) DImage6:SetPos(160, 83) DImage6:SetImage( "gui/silkicons/check_off" ) DImage6:SizeToContents() // Email local DLabel3 = vgui.Create("DLabel", DFrame1) DLabel3:SetPos(10, 110) DLabel3:SetText("Email") DLabel3:SizeToContents() local DTextEntry3 = vgui.Create("DTextEntry", DFrame1) DTextEntry3:SetSize(125, 20) DTextEntry3:SetPos(30, 125) DTextEntry3:SetText("") DTextEntry3.Think = function( ) local email = DTextEntry3:GetValue() if string.len(email) > 8 then DImage7:SetImage( "gui/silkicons/check_on" ) end end local DImage3 = vgui.Create("DImage", DFrame1) DImage3:SetSize(16, 16) DImage3:SetPos(10, 125) DImage3:SetImage("gui/silkicons/world") DImage3:SizeToContents() DImage7 = vgui.Create("DImage", DFrame1) DImage7:SetSize(16, 16) DImage7:SetPos(160, 127) DImage7:SetImage( "gui/silkicons/check_off" ) DImage7:SizeToContents() // Submit local DButton1 = vgui.Create("DButton", DFrame1) DButton1:SetSize(70, 25) DButton1:SetPos(58, 194) DButton1:SetText("Submit") DButton1.Paint = function() draw.RoundedBox( 6, 0, 0, 70, 25, Color( 32, 40, 57, 255 ) ) end DButton1.DoClick = function() local username = DTextEntry1:GetValue() local password = DTextEntry2:GetValue() local email = DTextEntry3:GetValue() if string.len(username) < 6 then LocalPlayer():ChatPrint("[MyBB] Your username has be 6 characters or more.") return end if string.len(password) < 6 then LocalPlayer():ChatPrint("[MyBB] Your password has be 6 characters or more.") return end if string.len(email) < 8 then LocalPlayer():ChatPrint("[MyBB] Your email has be 8 characters or more.") return end DFrame1:Close() datastream.StreamToServer( "SendInfo", { username, password, email } ) end end) concommand.Add("mybb_link", function( ) local p = LocalPlayer() DDFrame1 = vgui.Create("DFrame") DDFrame1:SetSize(186, 224) DDFrame1:SetPos(ScrW() / 2 - 63, ScrH() / 2 - 112) DDFrame1:SetTitle("Account Link") DDFrame1:SetSizable(true) DDFrame1:SetDeleteOnClose(false) DDFrame1:ShowCloseButton(false) DDFrame1:MakePopup() DDFrame1.Paint = function() draw.RoundedBox( 6, 0, 0, 186, 224, Color( 29, 36, 53, 255 ) ) end local DImage9 = vgui.Create("DImageButton", DDFrame1) DImage9:SetSize(16, 16) DImage9:SetPos(164, 4) DImage9:SetImage( "gui/silkicons/folder_go" ) DImage9:SetToolTip( "Don't have an account?" ) DImage9:SizeToContents() DImage9.DoClick = function() RunConsoleCommand("mybb_register") DDFrame1:Close() end // Username local DDLabel1 = vgui.Create("DLabel", DDFrame1) DDLabel1:SetPos(10, 30) DDLabel1:SetText("Username") DDLabel1:SizeToContents() local DDTextEntry1 = vgui.Create("DTextEntry", DDFrame1) DDTextEntry1:SetSize(125, 20) DDTextEntry1:SetPos(30, 44) DDTextEntry1:SetText("") DDTextEntry1.Think = function( ) local username = DDTextEntry1:GetValue() if string.len(username) > 3 then DDImage5:SetImage( "gui/silkicons/check_on" ) end end local DDImage1 = vgui.Create("DImage", DDFrame1) DDImage1:SetSize(16, 16) DDImage1:SetPos(10, 44) DDImage1:SetImage("gui/silkicons/user") DDImage1:SizeToContents() DDImage5 = vgui.Create("DImage", DDFrame1) DDImage5:SetSize(16, 16) DDImage5:SetPos(160, 44) DDImage5:SetImage( "gui/silkicons/check_off" ) DDImage5:SizeToContents() // Password local DDLabel2 = vgui.Create("DLabel", DDFrame1) DDLabel2:SetPos(10, 68) DDLabel2:SetText("Password") DDLabel2:SizeToContents() local DDTextEntry2 = vgui.Create("DTextEntry", DDFrame1) DDTextEntry2:SetSize(125, 20) DDTextEntry2:SetPos(30, 83) DDTextEntry2:SetText("") DDTextEntry2.Think = function( ) local password = DDTextEntry2:GetValue() if string.len(password) > 3 then DDImage6:SetImage( "gui/silkicons/check_on" ) end end local DDImage2 = vgui.Create("DImage", DDFrame1) DDImage2:SetSize(16, 16) DDImage2:SetPos(10, 83) DDImage2:SetImage("gui/silkicons/shield") DDImage2:SizeToContents() DDImage6 = vgui.Create("DImage", DDFrame1) DDImage6:SetSize(16, 16) DDImage6:SetPos(160, 83) DDImage6:SetImage( "gui/silkicons/check_off" ) DDImage6:SizeToContents() // Submit local DDButton1 = vgui.Create("DButton", DDFrame1) DDButton1:SetSize(70, 25) DDButton1:SetPos(58, 194) DDButton1:SetText("Submit") DDButton1.Paint = function() draw.RoundedBox( 6, 0, 0, 70, 25, Color( 32, 40, 57, 255 ) ) end DDButton1.DoClick = function() local username = DDTextEntry1:GetValue() local password = DDTextEntry2:GetValue() if string.len(username) < 4 then LocalPlayer():ChatPrint("[MyBB] Your username has be 4 characters or more.") return end if string.len(password) < 4 then LocalPlayer():ChatPrint("[MyBB] Your password has be 4 characters or more.") return end DDFrame1:Close() datastream.StreamToServer( "CheckMatch", { username, password } ) end end) [/CODE] sv_mybb.lua [CODE] require("tmysql") require("cryptopp") Host = "localhost" // Host(IP/Hostname) User = "gmodas" // Username Pass = "wsWtcvs5U3rUxWXn" // Password DB = "smf" // Databse to select Port = 3306 // Port, By default it's 3306. Group = 2 // This is the default group they will be placed into. By default 0 is registered. Must be a number! WEBURL = "http://www.garrysmod.com" // This is your website url. 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 // This creates a user as if he/she was registering on the forums. function Player:RegisterUser( uid, user, pass, email, group, regdate ) if !user or !pass or !email then self:ChatPrint( "[MyBB] Failed to create new user, one of the fields were nil." ) return end if !group then group = Group or 2 end
cl_ means it's a client side file, looks like you're running it server side
Place the cl file in autorun/client and see if that works.
now i'm getting error unknown command "mybb_register"
Sorry, you need to Log In to post a reply to this thread.