format(Query,sizeof(Query),"ADD COOKIES = 50 REMOVE COOKIES = 49 WHERE `NAME` = '%s'");
Oh,sorry,explained bad,how do I add\take(remove) a specific number to\from a value in the database ?
|
format( Query, sizeof( Query ), "UPDATE `TABLE_NAME` SET COOKIES = '%d' WHERE `NAME` = '%s'", cookies, DB_Escape( name ) );
db_free_result( db_query( Database, Query ) );
format( Query, sizeof( Query ), "DELETE FROM `TABLE_NAME` WHERE `NAME` = '%s'", DB_Escape( name ) );
db_free_result( db_query( Database, Query ) );
CMD:addcookies( playerid, params[ ] )
{
new
id,
cookies
;
if( sscanf( params, "ud", id, cookies ) ) return SendClientMessage( playerid, -1, "Syntax: /addcookies <ID> <Cookies>" );
if( !IsPlayerConnected( id ) && id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Invalid player ID!" );
new
name[ MAX_PLAYER_NAME ]
;
GetPlayerName( id, name, MAX_PLAYER_NAME );
format( Query, sizeof( Query ), "SELECT `COOKIES` FROM `USERS` WHERE `NAME` = '%s'", DB_Escape( name ) );
Result = db_query( Database, Query );
if( db_num_rows( Result ) )
{
new
Field[ 30 ]
;
format( Query, sizeof( Query ), "UPDATE `USERS` SET COOKIES = '%d' WHERE `NAME` = '%s'", db_get_field_assoc( Result, "COOKIES", Field, 30 ) + cookies, DB_Escape( Ip ) );
db_free_result( db_query( Database, Query ) );
}
return 1;
}