register problem

Started by Cool, Apr 23, 2016, 10:15 AM

Previous topic - Next topic

Milos

#45
constructor( playerName, dbGlobal ){
  local query = ::QuerySQL( dbGlobal, "SELECT Cash, Bank, Kills, Deaths, Level, LastUsedIP, nogoto FROM Accounts WHERE Name='" + playerName + "' COLLATE NOCASE" );
  if( ::GetSQLColumnData( query, 5 ) ){
   Cash = ::GetSQLColumnData( query, 0 );
   Bank = ::GetSQLColumnData( query, 1 );
   Kills = ::GetSQLColumnData( query, 2 );
   Deaths = ::GetSQLColumnData( query, 3 );
   Level = ::GetSQLColumnData( query, 4 );
   LastUsedIP = ::GetSQLColumnData( query, 5 );
  }
  ::FreeSQLQuery( query );
 }

::QuerySQL( dbGlobal, "SELECT Cash, Bank, Kills, Deaths, Level, LastUsedIP, nogoto FROM Accounts WHERE Name='" + playerName + "' AND NameLower='" + playerName.tolower() + "'" );to
::QuerySQL( dbGlobal, "SELECT Cash, Bank, Kills, Deaths, Level, LastUsedIP, nogoto FROM Accounts WHERE Name='" + playerName + "' COLLATE NOCASE" );

Mötley

If any of this does not work Once again we need pictures of your Browser( with a registered player) also include your create table.

Milos

Quote from: Mr_Motley on Apr 26, 2016, 08:02 PMIf any of this does not work Once again we need pictures of your Browser( with a registered player) also include your create table.
I believe that now work. I had the same problem, and that was my solution.
Now the server checks Necrose and necrose and loads the stats for any of these nicks :).


Mötley

I have made a small mistake and had my create table values off a little as well (added to much at once) in the browser causing issues upon registering and logging in, That is the only reason why I said that

DizzasTeR

What are all these messy replies? The problem is in his register command and KAKAN's conmand which he posted will work pretty well.

Cool

doom its now shows you registered please login
but while logging its says me you are not registered i think problem is in login cmd and function and take a look on function update and register maybe a mistake here
else if( cmd == "login" ){
if( !text ){
MessagePlayer( "Syntax Error!", player );
MessagePlayer( "Correct syntax: /login <password>", player );
}
else if( pstats[ player.ID ].Logged == true ){
MessagePlayer( "You are already logged in.", player );
}
else{
pstats[ player.ID ].Login( player, text, sqliteDB );
}

function Login( player, password, dbGlobal ){
local query = ::QuerySQL( dbGlobal, "SELECT Password FROM Accounts WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
if( ::GetSQLColumnData( query, 0 ) == null ){
::MessagePlayer( "[#FF0000][TIP] [#FFFFFF] You are not registered Register With /register pass.", player );
}
else if( ::SHA256( password ) != ::GetSQLColumnData( query, 0 ) ){
::MessagePlayer( "[#FF0000] [Info] [#FFFFFF]Wrong password.", player );
}
else{
LastUsedIP = player.IP;
Logged = true;
::MessagePlayer( "[#FF0000] [Info] [#FFFFFF]Successfully logged in.", player );
}

function Update( player, dbGlobal ){
::QuerySQL( dbGlobal, "UPDATE Accounts SET Cash=" + Cash + ", Bank=" + Bank + ", Kills=" + Kills + ", Deaths=" + Deaths + ", Level=" + Level + ", LastUsedIP='" + LastUsedIP + ", nogoto='" + nogoto + "' WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
}

function Register( player, password, dbGlobal ){
::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ::SHA256( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + 0 + "')" );
Level = 1;
LastUsedIP = player.IP;
Logged = true;
::MessagePlayer( "[#FF0000] [Info] [#FFFFFF]Successfully registered.", player );
::MessagePlayer( "[#FF0000] [Tip] [#FFFFFF]Don't forget your password. [" + password + "]", player );
}

DizzasTeR

For fuck sake dude, if you want help, then atleast follow the instructions given to you, I've told you to give me your register command, if you're so sure about the error, where and why is it occurring then fix it yourself.

Cool

#52
you say me modify your post in which i post login cmd when you say me by mistake give me login cmds i updated my that post with register

Cool

Quote from: Hercules on Apr 26, 2016, 04:51 PMif( cmd == "register" ){
if( !text ){
MessagePlayer(WHITE+"Syntax Error!", player );
MessagePlayer(RED+"[SYNTAX]"+WHITE+" /register <password>", player );
}
else if( pstats[ player.ID ].Logged == true ){
MessagePlayer( "You are already logged in.", player );
}
else{
pstats[ player.ID ].Register( player, text, sqliteDB );
}

DizzasTeR

if( cmd == "register" )
{
    if( !text )
    {
        MessagePlayer(WHITE+"Syntax Error!", player );
        MessagePlayer(RED+"[SYNTAX]"+WHITE+" /register <password>", player );
    }
    else if( pstats[ player.ID ].Logged == true )
    {
        MessagePlayer( "You are already logged in.", player );
    }
    else
     {
        local szName = player.Name, szNameLower = player.Name.tolower(), sqlQuery = mysql_query( sqLiteDB, "SELECT Level FROM Accounts WHERE Name='" + szName + "' AND NameLower='" + szNameLower + "'" );
        if( mysql_num_rows( sqlQuery ) == 1 ) MessagePlayer( "You are already registered.", player );
        else
        {
            pstats[ player.ID ].Register( player, params[0], params[1], sqLiteDB );
        }
        mysql_free_result( sqlQuery );
    }
}

Coolkid

Quote from: Doom_Kill3R on Apr 27, 2016, 12:56 PMif( cmd == "register" )
{
    if( !text )
    {
        MessagePlayer(WHITE+"Syntax Error!", player );
        MessagePlayer(RED+"[SYNTAX]"+WHITE+" /register <password>", player );
    }
    else if( pstats[ player.ID ].Logged == true )
    {
        MessagePlayer( "You are already logged in.", player );
    }
    else
     {
        local szName = player.Name, szNameLower = player.Name.tolower(), sqlQuery = mysql_query( sqLiteDB, "SELECT Level FROM Accounts WHERE Name='" + szName + "' AND NameLower='" + szNameLower + "'" );
        if( mysql_num_rows( sqlQuery ) == 1 ) MessagePlayer( "You are already registered.", player );
        else
        {
            pstats[ player.ID ].Register( player, params[0], params[1], sqLiteDB );
        }
        mysql_free_result( sqlQuery );
    }
}

Test it now

Mötley

This now sounds like a hashing issue(I could be wrong).
what hashing are you using are they both the same ?
example: your login is MD5 then the register is whirlpool
It needs to be one or the other not two different ones, double check this, also Doom_Kill3R only posting similar issues and other stuff in case he happened to have the same issues. I still feel like this is also possibly a database table issue

Cool


Thijn

As you can see from the LOCALS, sqlQuery is false. Which means your query fails. It's syntax is invalid or your mysql isn't actually connected.

KAKAN

Quote from: Thijn on Apr 27, 2016, 02:30 PMyour mysql isn't actually connected.
He's asking with SQLite, so it's shit to think about MySQL :D
Well, @Hercules, scroll up and try the register command which I posted.
oh no