14.07.2011, 12:32
what's the problem with this script?
?
pawn Код:
#include < a_samp >
#define red 0xE60000FF
#define yellow 0xFFFF00FF
#define green 0x00FF00FF
#define blue 0x0000BBFF
#define BS 12000
#define BS2 12001
enum pInfo
{
Moneys,
Score,
};
new PlayerInfo[ MAX_PLAYERS ][ pInfo ];
new DB:Saver;
new string[ 128 ];
new Field[ 50 ];
public OnFilterScriptInit( )
{
Saver = db_open( "Saver.db" );
db_free_result( db_query( Saver, "CREATE TABLE IF NOT EXISTS `Saver` \
(`Nume` varchar(40),\
`Bani` INT,\
`Score` INT )" ) );
return 1;
}
public OnFilterScriptExit( )
{
db_close( Saver );
return 1;
}
public OnPlayerConnect( playerid )
{
new DBResult:Resultat, Query[ 256 ];
format( Query, sizeof( Query ), "SELECT * FROM `Saver` WHERE `Nume` = '%s'" , PlayerName2( playerid ) );
Resultat = db_query( Saver, Query );
if ( db_num_rows( Resultat ) )
{
db_get_field_assoc( Resultat, "Bani", Field, 30 );
PlayerInfo[ playerid ][ Moneys ] = strval( Field );
db_get_field_assoc( Resultat, "Score", Field, 30 );
PlayerInfo[ playerid ][ Score ] = strval( Field );
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, PlayerInfo[ playerid ][ Moneys ] );
SetPlayerScore( playerid, PlayerInfo[ playerid ][ Score ] );
format( string, sizeof( string ), "Ai %d bani\nAi %d score!", PlayerInfo[ playerid ][ Moneys ], PlayerInfo[ playerid ][ Score ] );
ShowPlayerDialog( playerid, BS, DIALOG_STYLE_MSGBOX, "Saver", string, "Quit", "" );
}
else
{
format( Query, sizeof( Query ), "INSERT INTO `Saver` ( `Nume`, `Bani`, `Score` ) VALUES( `%s`, '0', `0` )",PlayerName2( playerid ) );
db_free_result( db_query( Saver, Query ) );
}
db_free_result( Resultat );
return 1;
}
public OnPlayerDisconnect( playerid, reason )
{
new Query[ 256 ];
format( Query, sizeof( Query ), "UPDATE `Saver` SET `Bani` = '%d', `Score` = '%d' WHERE `Nume` = '%s'", GetPlayerMoney( playerid ), GetPlayerScore( playerid ), PlayerName2( playerid ) );
db_free_result( db_query( Saver, Query ) );
return 1;
}
stock PlayerName2( playerid )
{
new name[ 25 ];
GetPlayerName( playerid, name, 25 );
return name;
}