31.12.2011, 02:37
hey guys im back from playing certain games and wanted back to script. In those case i have a little bit problem that i can't even figure out how to solve this. Hope you guys know how to solve this mysql registration failure.
those are the codes for registration on mysql database.
pawn Код:
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 ;
}
pawn Код:
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 ;
}