SA-MP Forums Archive
Annoying MySQL problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Annoying MySQL problem (/showthread.php?tid=249045)



[SOLVED] Annoying MySQL problem - Mean - 16.04.2011

So, I have started learning MySQL, this is ma code for auto-login:
pawn Код:
if( mysql_num_rows( ) != 0 )
{
    new line[ 750 ];
    SetPVarInt( playerid, "Logged", 1 );
    SendClientMessage( playerid, 0x009600AA, "Auto Logged in!" );
    if( mysql_fetch_row( line ) )
    {
        new data[ 3 ][ 50 ];
        new data2[ 6 ];
        sscanf( line, "p|ssddddds", data[ 0 ], data[ 1 ], data2[ 0 ], data2[ 1 ], data2[ 2 ], data2[ 3 ], data2[ 5 ], data[ 2 ] );
        SetPVarInt( playerid, "Kills", data2[ 0 ] );
        SetPVarInt( playerid, "Logged", 1 );
        SetPVarInt( playerid, "Deaths", data2[ 1 ] );
        SetPlayerScore( playerid, data2[ 2 ] );
        GivePlayerMoney( playerid, data2[ 3 ] );
        SetPVarInt( playerid, "Level", data2[ 5 ] );
        mysql_free_result( );
    }
}
I did this by [HiC]TheKiller's tutorial, I am just learning MySQL, and when I login, my lvl is still 0! Even tho the table says that my level is 5. Any help to the beginner?

My TABLE:

user
hidden

password
hidden

kills
0

deaths
1

score
5

money
30000

IP
hidden

level
5


All of the stats get loaded, kills, deaths, everything, but level doesn't.


Re: Annoying MySQL problem - [L3th4l] - 16.04.2011

The sscanf syntax doesn't match your table:
pawn Код:
"p|ssddddds"
Код:
User, Password, Kills, Deaths, Score, Money, IP, Level
This is how it should be:
pawn Код:
"p|ssddddsd"
Код:
User, Password, Kills, Deaths, Score, Money, IP, Level
Also, turn on mysql log under OGMI.


Re: Annoying MySQL problem - Mean - 16.04.2011

Now it shows LEVEL: 49 in my stats. Lol.

And it's

User, Password, Kills, Deaths, Score, Money, Level, IP.


Re: Annoying MySQL problem - Donya - 17.04.2011

pawn Код:
if( mysql_num_rows( ) != 0 )
{
    new line[ 750 ];
    SetPVarInt( playerid, "Logged", 1 );
    SendClientMessage( playerid, 0x009600AA, "Auto Logged in!" );
    if( mysql_fetch_row( line ) )
    {
        new data[ 3 ][ 50 ];
        new data2[ 6 ];
        sscanf( line, "p<|>ssddddsd", data[ 0 ], data[ 1 ], data2[ 0 ], data2[ 1 ], data2[ 2 ], data2[ 3 ], data2[ 5 ], data[ 2 ] );
        SetPVarInt( playerid, "Kills", data2[ 0 ] );
        SetPVarInt( playerid, "Logged", 1 );
        SetPVarInt( playerid, "Deaths", data2[ 1 ] );
        SetPlayerScore( playerid, data2[ 2 ] );
        GivePlayerMoney( playerid, data2[ 3 ] );
        SetPVarInt( playerid, "Level", data2[ 5 ] );
        mysql_free_result( );
    }
}



Re: Annoying MySQL problem - Mean - 17.04.2011

Quote:
Originally Posted by Donya
Посмотреть сообщение
pawn Код:
if( mysql_num_rows( ) != 0 )
{
    new line[ 750 ];
    SetPVarInt( playerid, "Logged", 1 );
    SendClientMessage( playerid, 0x009600AA, "Auto Logged in!" );
    if( mysql_fetch_row( line ) )
    {
        new data[ 3 ][ 50 ];
        new data2[ 6 ];
        sscanf( line, "p<|>ssddddsd", data[ 0 ], data[ 1 ], data2[ 0 ], data2[ 1 ], data2[ 2 ], data2[ 3 ], data2[ 5 ], data[ 2 ] );
        SetPVarInt( playerid, "Kills", data2[ 0 ] );
        SetPVarInt( playerid, "Logged", 1 );
        SetPVarInt( playerid, "Deaths", data2[ 1 ] );
        SetPlayerScore( playerid, data2[ 2 ] );
        GivePlayerMoney( playerid, data2[ 3 ] );
        SetPVarInt( playerid, "Level", data2[ 5 ] );
        mysql_free_result( );
    }
}
With that code non of my stats get loaded, all zero.
And it is User, Password, Kills, Deaths, Score, Money, Level, IP.


Re: Annoying MySQL problem - Mean - 17.04.2011

Bump.


Re: Annoying MySQL problem - playbox12 - 17.04.2011

pawn Код:
if( mysql_num_rows( ) != 0 )
{
    new line[ 750 ];
    SetPVarInt( playerid, "Logged", 1 );
    SendClientMessage( playerid, 0x009600AA, "Auto Logged in!" );
    if( mysql_fetch_row( line ) )
    {
        new data[ 3 ][ 50 ];
        new data2[ 6 ];
        if(sscanf( line, "p<|>s[24]s[129]ddddds[19]", data[ 0 ], data[ 1 ], data2[ 0 ], data2[ 1 ], data2[ 2 ], data2[ 3 ], data2[ 5 ], data[ 2 ] ))
        {
            print("ERROR during auto- login");
        }
        else
        {
            SetPVarInt( playerid, "Kills", data2[ 0 ] );
            SetPVarInt( playerid, "Logged", 1 );
            SetPVarInt( playerid, "Deaths", data2[ 1 ] );
            SetPlayerScore( playerid, data2[ 2 ] );
            GivePlayerMoney( playerid, data2[ 3 ] );
            SetPVarInt( playerid, "Level", data2[ 5 ] );
            mysql_free_result( );
        }
    }
}



Re: Annoying MySQL problem - Mean - 17.04.2011

Quote:
Originally Posted by playbox12
Посмотреть сообщение
pawn Код:
if( mysql_num_rows( ) != 0 )
{
    new line[ 750 ];
    SetPVarInt( playerid, "Logged", 1 );
    SendClientMessage( playerid, 0x009600AA, "Auto Logged in!" );
    if( mysql_fetch_row( line ) )
    {
        new data[ 3 ][ 50 ];
        new data2[ 6 ];
        if(sscanf( line, "p<|>s[24]s[129]ddddds[19]", data[ 0 ], data[ 1 ], data2[ 0 ], data2[ 1 ], data2[ 2 ], data2[ 3 ], data2[ 5 ], data[ 2 ] ))
        {
            print("ERROR during auto- login");
        }
        else
        {
            SetPVarInt( playerid, "Kills", data2[ 0 ] );
            SetPVarInt( playerid, "Logged", 1 );
            SetPVarInt( playerid, "Deaths", data2[ 1 ] );
            SetPlayerScore( playerid, data2[ 2 ] );
            GivePlayerMoney( playerid, data2[ 3 ] );
            SetPVarInt( playerid, "Level", data2[ 5 ] );
            mysql_free_result( );
        }
    }
}
With that code non of my stats get loaded, not even cash, kills, deaths, etc.

EDIT: I moved the "level" field before IP because that's how I do it in SSCANF, and now my level shows 49. Lol.


Re: Annoying MySQL problem - playbox12 - 17.04.2011

Quote:
Originally Posted by Mean
Посмотреть сообщение
With that code non of my stats get loaded, not even cash, kills, deaths, etc.
Does it give the print error?

Also are you using strickenkids plugin or g'stylezz?


Re: Annoying MySQL problem - Mean - 17.04.2011

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Does it give the print error?

Also are you using strickenkids plugin or g'stylezz?
It doesn't print, it's success.
G-Stylezz's plugin.

EDIT: I am also using the older sscanf, with a stock, so I don't need string sizes.

I am a noob at SQL, can you show me a way without sscanf?