new
pQue[ 256 ];
format( pQue, sizeof (pQue), "SELECT * FROM `Muted` WHERE `IP` = '%s'", GetPlayerIPEx( params[ 0 ] ) );
new DBResult:RESULT = db_query( UsefullDatabase, pQue );
P_DATA[ params[ 0 ] ][ Muted ] = 1;
P_DATA[ params[ 0 ] ][ MutedTime ] = 0;
new pQue2[ 256 ];
if ( db_num_rows( RESULT ) )
format( pQue2, sizeof (pQue2),"UPDATE `Muted` SET `IP` = '%s', `Muted` = '1', `Time` = '0', `RealName` = '%s'",GetPlayerIPEx( params[ 0 ] ), Name( params[ 0 ] ) );
else
format( pQue2, sizeof (pQue2), "INSERT INTO `Muted` ( `IP`, `Muted`, `Time`, `RealName` ) VALUES ('%s', '1', '0', '%s')", GetPlayerIPEx( params[ 0 ] ), Name( params[ 0 ] ) );
db_query( UsefullDatabase, pQue2 );
db_free_result( RESULT );
P_DATA[ params[ 0 ] ][ Muted ] = 1;
P_DATA[ params[ 0 ] ][ MutedTime ] = 0;
#if SAVE_MUTE == true
new
pQue[ 256 ];
format( pQue, sizeof (pQue), "SELECT * FROM `Muted` WHERE `IP` = '%s'", GetPlayerIPEx( params[ 0 ] ) );
new DBResult:RESULT = db_query( UsefullDatabase, pQue );
new pQue2[ 256 ];
if ( db_num_rows( RESULT ) )
format( pQue2, sizeof (pQue2),"UPDATE `Muted` SET `IP` = '%s', `Muted` = '1', `Time` = '0', `RealName` = '%s'",GetPlayerIPEx( params[ 0 ] ), Name( params[ 0 ] ) );
else
format( pQue2, sizeof (pQue2), "INSERT INTO `Muted` ( `IP`, `Muted`, `Time`, `RealName` ) VALUES ('%s', '1', '0', '%s')", GetPlayerIPEx( params[ 0 ] ), Name( params[ 0 ] ) );
db_query( UsefullDatabase, pQue2 ) && db_free_result( RESULT );
#endif
SendAdminCMD( playerid, "Admin "ORAN"%s[%i]"GREY" muted player "ORAN"%s[%i]", Name( playerid ), playerid, Name( params[ 0 ] ), params[ 0 ], params[ 1 ] );
FormatMSG( playerid, Color:GREY, "You muted "ORAN"%s[%i]", Name( params[ 0 ] ), params[ 0 ] );
SendClientMessage( params[ 0 ], Color:GREY, "You have been muted!");
What's with the "&&"? This isn't JavaScript... Plus that will only free your result if the first query happens - if it fails you have a memory leak.
|
"INSERT OR REPLACE INTO `Muted` ( `IP`, `Muted`, `Time`, `RealName` ) VALUES ('%s', '1', '0', '%s')", ....
You may try INSERT OR REPLACE INTO
http://www.sqlite.org/lang_conflict.html pawn Код:
|