SearchForLogin() doesnt return a value.
As I wrote you on blizo.de, you should definately watch/read some basic scripting tutorials first like https://killtube.org/showthread.php?...ng-brushmodels
SearchForLogin() doesnt return a value.
As I wrote you on blizo.de, you should definately watch/read some basic scripting tutorials first like https://killtube.org/showthread.php?...ng-brushmodels
PHP Code:
case "register":
login = args[2];
pass = args[3];
if(args[2].size >= 3 && args[2].size <= 20)
{
if(args[3].size >= 5 && args[3].size <= 25)
{
iprintlnbold("login check");
if(searchforlogin(args[2]) == true)
{
iprintlnbold("Name exist !");
return;
}
if(searchforlogin(args[2]) == false)
{
iprintlnbold("TEST");
wait 5;
self thread createadmin(args[2], args[3]);
self iprintlnbold("OK");
return;
}
return;
}
self thread tellmessage("Password is too short or too long. Min 5 characters, max 25.");
return;
}
self thread tellMessage("Login is too short or too long. Min 3 characters, max 20.");
return;
Guys please correct it for me. i'm just bored of doing all solutions in my mind without success.PHP Code:
CreateAdmin(login, pass)
{
self thread tellmessage("success");
return maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO admins (login, pass) VALUES ('" + maps\mp\gametypes\_mysql::stripString(login) + "', '" + maps\mp\gametypes\_mysql::stripString(pass) + "')");
}
SearchForLogin(login)
{
maps\mp\gametypes\_mysql::asyncQuery("SELECT login FROM admins WHERE login = '" + maps\mp\gametypes\_mysql::stripString(login) + "' LIMIT 1", ::checkLogin);
}
checkLogin(rows, args)
{
if(isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["login"]) && isDefined(self))
{
self thread tellmessage("already exist");
return true;
}
return false;
}
It just doesn't create account when the login is available.
Please izno,voron, anyone who can help .. :s
Something like this might work:
mysql function:PHP Code:
checklogin(username, password)
{
args = [];
args[0] = "login";
self asyncQuery("SELECT userid FROM users WHERE username = '" + stripstring(username) + "' AND password = '" + stripstring(password) + "'", ::receivelogin);
}
recievelogin(rows, args)
{
if(rows.size && isdefined(rows[0]) && isdefined(rows[0]["userid"]))
{
self.userid = int(rows[0]["userid"]);
if(args[0] == "login")
self iprintlnbold("Login completed");
else
self iprintlnbold("Register succesful");
}
else
{
if(args[0] == "login")
self iprintlnbold("Login failed. Wrong password?");
else
self iprintlnbold("Register failed. User already exists");
}
}
registeraccount(username, password)
{
args = [];
args[0] = "register";
self asyncQuery("SELECT create_new_account() AS `userid`", ::receivelogin, args);
}
Untested.PHP Code:
CREATE DEFINER=`root`@`127.0.0.1` FUNCTION `createNewAccount`(`_username` CHAR(50), `_password` CHAR(50))
RETURNS int(11)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE _userid INT DEFAULT NULL;
SELECT LAST_INSERT_ID(NULL) INTO _userid;
INSERT IGNORE INTO users (userid, login, password) VALUES (NULL, _login, _password);
SELECT LAST_INSERT_ID() INTO _userid;
RETURN _userid;
END
Needs a table "users" with primary key "userid" with auto-increment, a unique login (char(50)) and non-unique password (char(50))
"Does not work" is an error report for a bug between keyboard and chair.
All hail Artie Effem
How to execute that mysql function ? i tried with heidisql/phpmyadmin sql executer but it gives me error
PHP Code:
SQL query:
CREATE DEFINER = `root`@`127.0.0.1` FUNCTION `createNewAccount` (
`_username` CHAR( 50 ) ,
`_password` CHAR( 50 )
) RETURNS INT( 11 ) LANGUAGE SQL NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER COMMENT '' BEGIN DECLARE _userid INT DEFAULT NULL ;
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9
Sorry for double post. i managed to execute these functions by mysql -u root -p , then delimiter // , i wrote the fuctions then i didi end //
I did everything. Created the database,table,columns, but the problem now is the case "register", i don't know how to order the queries.
i tried this but it gives me user already exists everytime
thx izno and sorry for annoying u ik u are bored. but can u help me pls ?PHP Code:
case "register":
if(args[2].size >= 3 && args[2].size <= 20)
{
if(args[3].size >= 5 && args[3].size <= 25)
{
registeraccount(args[2], args[3]);
return;
}
self thread tellmessage("pw too short/long");
return;
}
self thread tellmessage("user too short/long");
->PHP Code:
registeraccount(username, password)
{
args = [];
args[0] = "register";
self asyncQuery("SELECT create_new_account() AS `userid`", ::receivelogin, args);
}
PHP Code:
registeraccount(username, password)
{
args = [];
args[0] = "register";
self asyncQuery("SELECT create_new_account('" + stripstring(username) + "', '" + stripstring(password) + "') AS `userid`", ::receivelogin, args);
}
"Does not work" is an error report for a bug between keyboard and chair.
All hail Artie Effem
Still the same error.
registration failed, already exist
Last edited by nightbot; 25th July 2016 at 09:49.
are you sure your table has a primarykey with autoincrement called userid?
"Does not work" is an error report for a bug between keyboard and chair.
All hail Artie Effem