public OnPlayerConnect ( playerid )
{
new pName [ MAX_PLAYER_NAME ] ;
SetPVarInt ( playerid , "Logged" , 0 ) ;
GetPlayerName ( playerid , pName , sizeof ( pName ) ) ;
format ( Query , sizeof ( Query ) , "SELECT * FROM `data` WHERE `Name` = '%s'" , pName ) ;
mysql_query ( Query ) ;
mysql_store_result ( ) ;
if ( mysql_num_rows ( ) == 1 )
{
format ( String , sizeof ( String ) , ""LIGHTGREEN"Enter your password to proceed" ) ;
ShowPlayerDialog ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , DIALOG_TITLE , String , "Submit" , "" ) ;
}
else if ( mysql_num_rows ( ) == 0 )
{
format ( String , sizeof ( String ) , ""LIGHTGREEN"Enter your password to register" ) ;
ShowPlayerDialog ( playerid , DIALOG_REGISTER , DIALOG_STYLE_PASSWORD , DIALOG_TITLE , String , "Submit" , "" ) ;
}
mysql_free_result ( ) ;
return 1 ;
}
case DIALOG_REGISTER:
{
if ( response )
{
if ( strlen ( inputtext ) < 0 || strlen ( inputtext ) > 100 )
{
format ( String , sizeof ( String ) , ""LIGHTGREEN"You dont not enter any string or you just exceeding limit of password" ) ;
ShowPlayerDialog ( playerid , DIALOG_REGISTER , DIALOG_STYLE_PASSWORD , DIALOG_TITLE , String , "Submit" , "" ) ;
}
else
{
new pName [ MAX_PLAYER_NAME ] ;
GetPlayerName ( playerid , pName , sizeof ( pName ) ) ;
mysql_real_escape_string ( inputtext , inputtext ) ;
format ( Query , sizeof ( Query ) , "INSERT INTO `data` ( `Name` , `Level` , `Password` , `Kill` , `Death` , `Money` , `Score` ) VALUES( '%s' , 0 , '%s' , 0 , 0 , 10000 , 0 )" , pName , inputtext ) ;
mysql_query ( Query ) ;
SetPVarInt ( playerid , "Level" , 0 ) ;
SetPVarInt ( playerid , "Kill" , 0 ) ;
SetPVarInt ( playerid , "Death" , 0 ) ;
GivePlayerMoney ( playerid , 10000 ) ;
SetPlayerScore ( playerid , 0 ) ;
SetPVarInt ( playerid , "Logged" , 1 ) ;
}
}
return 1 ;
}
mysql_debug(1);
[11:31:48] [11:31:48] --------------------------- [11:31:48] MySQL Debugging activated (12/31/11) [11:31:48] --------------------------- [11:31:48] [11:31:48] >> mysql_ping( Connection handle: 1 ) [11:31:48] CMySQLHandler::Ping() - Connection is still alive. [11:32:12] >> mysql_query( Connection handle: 1 ) [11:32:12] CMySQLHandler::Query(SELECT * FROM `data` WHERE `Name` = '[Sir]MonKat') - Successfully executed. [11:32:12] >> mysql_store_result( Connection handle: 1 ) [11:32:12] CMySQLHandler::StoreResult() - Result was stored. [11:32:12] >> mysql_num_rows( Connection handle: 1 ) [11:32:12] CMySQLHandler::NumRows() - Returned 0 row(s) [11:32:12] >> mysql_num_rows( Connection handle: 1 ) [11:32:12] CMySQLHandler::NumRows() - Returned 0 row(s) [11:32:12] >> mysql_free_result( Connection handle: 1 ) [11:32:12] CMySQLHandler::FreeResult() - Result was successfully free'd.
What shows up the freaking register download, over and over again? <-- Makes no sense to me at all.
|
if(mysql_num_rows() > 0) //registered { } else //not registered { }
... WHERE `Name` = '%s' LIMIT 1;
Use rather
Код:
if(mysql_num_rows() > 0) //registered { } else //not registered { } Код:
... WHERE `Name` = '%s' LIMIT 1; Your log didn't cover the register query. |