10.11.2012, 11:09
How to add\remove with SQLite ?
10.11.2012, 11:16
pawn Код:
format( Query, sizeof( Query ), "UPDATE `TABLE_NAME` SET COOKIES = '%d' WHERE `NAME` = '%s'", cookies, DB_Escape( name ) );
db_free_result( db_query( Database, Query ) );
pawn Код:
format( Query, sizeof( Query ), "DELETE FROM `TABLE_NAME` WHERE `NAME` = '%s'", DB_Escape( name ) );
db_free_result( db_query( Database, Query ) );
10.11.2012, 11:26
EDIT: Oh,sorry,explained bad,how do I add\take(remove) a specific number to\from a value in the database ?
10.11.2012, 11:29
It sets it to the specified number, but you can add it if you want by adding the previous number of cookies + cookies.
10.11.2012, 11:37
Sorry,I recently started learning SQLite,can you show how should I do it ?
I understood what you said,but it means I should 'get' the value and add to it the number I want,like x + 23
but how do I know what number written in the database ? (x = ?)
I understood what you said,but it means I should 'get' the value and add to it the number I want,like x + 23
but how do I know what number written in the database ? (x = ?)
10.11.2012, 11:53
I wrote an example as command!
Almost similar for /takecookies except that instead of "db_get_field_assoc( Result, "COOKIES", Field, 30 ) + cookies", you'll have minus.
pawn Код:
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;
}
10.11.2012, 11:56
Oh,thanks
« Next Oldest | Next Newest »
Users browsing this thread: 1 Guest(s)