[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:
Код:
User, Password, Kills, Deaths, Score, Money, IP, Level
This is how it should be:
Код:
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?