Cuberite Forum
Login - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Releases (https://forum.cuberite.org/forum-2.html)
+--- Thread: Login (/thread-811.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11


RE: Login - xoft - 06-01-2013

To get the values out, you just use a SELECT sql command:
Code:
SELECT * FROM password WHERE name='Niels';

Then, there's the Lua binding, which dictates how to get to the values that the SQL database returns. It turns out the binding is pretty straightforward. You call the "exec" function on the database object, it has three parameters, the sql command, callback and userdata. It then calls the callback for each row of data that the sql command produced. The userdata parameter is given to the callback as well, it is a way to pass any kind of information through. So, for example, this will be a skeleton code for you:
-- Somewhere global:
PwdDB = {};  -- The password database object

-- In the Initialize function:
PwdDB, ErrCode, ErrMsg = sqlite3.open("pwd.sqlite");
-- TODO: Handle errors in ErrCode

-- In the login hook:
local UserName = ...;  -- Username of the player logging in
local PasswordGiven = ...;  -- What password is the user logging in with?
local ShouldAllowLogin = false;
local function ProcessRow(UserData, NumCols, Values, Names)
	for i = 1, NumCols do
		if (Names[i] == "Password") then  -- "Password" is the column name
			ShouldAllowLogin = (Values[i] == PasswordGiven);
		end
	end
	return 0;
end
local Res = PwdDB:exec("SELECT * FROM Passwords WHERE Username=\"" .. UserName .."\"", ProcessRow, nil);
if (Res ~= sqlite3.OK) then
	LOG("SQL query failed: " .. Res .. " (" .. PwdDB:errmsg() .. ")");
end;
-- ShouldAllowLogin now has the bool value saying whether to allow the user in or not



RE: Login - NiLSPACE - 06-01-2013

Hurray I have SQLite ( kinda ) working Wink You can now register ;D


RE: Login - NiLSPACE - 06-01-2013

I've commited the first versionBig Grin It is in beta stage and its very ugly Wink
https://github.com/STRWarrior/Login/tree/Dev


RE: Login - bearbin - 06-02-2013

Cool!


RE: Login - testeflighter - 06-11-2013

Code:
[13:42:04] cWebPlugin::cWebPlugin()
[13:42:04] -- Plugins/Login/main.lua:23: error in function 'AddHook'.
     argument #3 is 'nil'; 'number' expected.

[13:42:04] Error in plugin Plugins/Login calling function Initialize()
[13:42:04] ~cWebPlugin::cWebPlugin()
[13:42:04] Core
[13:42:04] Login-master
[13:42:04] Got nil! NOOOO
[13:42:08] Path: /webadmin/Core/Manage_Plugins
[13:42:09] Path: /webadmin/Core/Manage_Plugins
not working


RE: Login - NiLSPACE - 06-12-2013

does a reload fix it?


RE: Login - testeflighter - 06-12-2013

No, a lot of times it rebooted the same thing


RE: Login - xoft - 06-12-2013

What MCServer version are you using? If it's an older release, the API might have changed.


RE: Login - testeflighter - 06-12-2013

Yes, apparently this problem, and what should I use?


RE: Login - NiLSPACE - 06-12-2013

You can find the latest version for windows here: http://mc-server.xoft.cz/
The latest version is r1581