Another SQLite Problem...
#1

Well.. I have this command:
pawn Код:
CMD:freeze( playerid, params[ ] )
{
    new u_P;
    if( unformat( params, "u", u_P ) )                  return Send_Usage( playerid, "[PlayerID]", "Will freeze a specified player, he will cannot freeze-evade!" );
   
    if( u_P  == ( 0xFFFF ) )                            return eInfo( playerid, "Player not connected" );
    if( u_P  == playerid )                              return eInfo( playerid, "You cannot freeze yourself" );
    if( Bit1_Get( g_iBit1_p_DATA[ p_Frozen ], u_P ) )   return eInfo( playerid, "Player is already frozen" );
   
    FreezePlayer( u_P );

    return ( 1 );
}
And this function:
pawn Код:
FreezePlayer( playerid )
{
    new Query[ 256 ];
    format( Query, sizeof Query, "INSERT INTO `Frozen` VALUES('%s', '%s')", GetPlayerIpEx( playerid ), pName( playerid ) );
    DB::query( g_dbKeptAlive, Query );

    Bit1_Set( g_iBit1_p_DATA[ p_Frozen ], playerid, 1 );
    TogglePlayerControllable( playerid, false );
   
    return ( 1 );
}
And the command doesn't write in the Database, any ideas why ?
Reply
#2

You must define Colums in which to write.
Ex.
pawn Код:
format( Query, sizeof Query, "INSERT INTO `Frozen` (`IP`,`Name`) VALUES('%s', '%s')", GetPlayerIpEx( playerid ), pName( playerid ) );
Reply
#3

Same thing...
Reply
#4

If you have a primary key in 'Frozen' you need to make sure it's set to auto increment.
Reply
#5

I don't have any Primary Key...
pawn Код:
db_query(g_dbKeptAlive, "CREATE TABLE IF NOT EXISTS `Frozen` (`IP` TEXT,`Name` TEXT)")
Reply
#6

Hmm, guys ?
Reply
#7

If the database already has that player in frozen table, you will need to run an "UPDATE" query instead of "INSERT". I'm no expert in SQL but i think that might be your problem.

EDIT: I thought you was setting values in the DB not just adding entries sorry.
Reply
#8

... I'm not so 'newbie' in SQLite, and no, it doesn't write it in the Database...
The player isn't in the *.db
Reply
#9

Yeah i edited my post i should have read your code properly.
Reply
#10

No problem, but I'm going mad because this snippet of code doesn't work...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)