SQLite Problem
#1

pawn Код:
public OnPlayerConnect( playerid )
{
    new Query2[ 256 ];
    new DBResult:RRezult;
    format( Query2, sizeof( Query2 ), "SELECT 'Reputation' FROM `REPUTATION` WHERE `Name` = '%s'", CName( playerid ) );
    RRezult = db_query( Database, Query2 );
    if( db_num_rows( RRezult ) )
    {
        new Field[ 30 ];
        new Reputation;
        db_get_field_assoc( RRezult, #Reputation, Field, 30 );
        Reputation = strval( Field );
        RK_REP[ playerid ][ RK_REPUTATION ] = Reputation;
    }
    db_free_result( RRezult );
}

public OnPlayerDisconnect( playerid )
{
    format( Query, sizeof( Query ), "UPDATE `REPUTATION` (`Name`, `Reputation`) VALUES('%s', '%d')", CName( playerid ), RK_REP[ playerid ][ RK_REPUTATION ] );
    db_free_result( db_query( Database, Query ) );
}
It save's "Reputation" but it doesen't load on connect, what the problem could be ?
Reply
#2

instead of #Reputation try "Reputation"

If that wont work, supposedly, it could be the OnPlayerDisconnect query
Reply
#3

pawn Код:
C:\Documents and Settings\--\Desktop\--.pwn(54) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Doesen't work that way...
Reply
#4

pawn Код:
public OnPlayerDisconnect( playerid )
{
    format( Query, sizeof( Query ), "UPDATE `REPUTATION` SET Reputation = '%d' WHERE Name = '%s') ", RK_REP[ playerid ][ RK_REPUTATION ], GetName(playerid) );
    db_free_result( db_query( Database, Query ) );
}
Try this.

That should work, it has to have the ' " ' character besides them like this:
pawn Код:
db_get_field_assoc(Result, "GANGID", Field, 30);
Reply
#5

Код:
UPDATE `Reputation` SET `Reputation` = '%d' WHERE `Name` = '%s';
I don't know on what basis you want to update the database. Also, why do you need to update the player's name ?
Reply
#6

There is something wrong with your db_get_field_assoc function. It's returning an invalid tag because you must have something conflicting with "Reputation". Do you have a definition with Reputation?
Reply
#7

@Bakr
No...

@Lorenc_
Doesen't Work...

It won't load and it won't update...
Reply
#8

Have you even inserted the player data into the database?

Ahhh!!

change 'Reputation' to `Reputation`
Reply
#9

pawn Код:
public OnFilterScriptInit( )
{
    Database = db_open( "RepPlayers.db" );
    db_free_result( db_query( Database, "CREATE TABLE IF NOT EXISTS `REP` (`Name`, `Reputation`)" ) );
}

public OnFilterScriptExit( )
{
    db_close( Database );
}

public OnPlayerConnect( playerid )
{
    new Query2[ 256 ];
    new DBResult:RRezult;
    format( Query2, sizeof( Query2 ), "SELECT 'Reputation' FROM `REP` WHERE `Name` = '%s'", CName( playerid ) );
    RRezult = db_query( Database, Query2 );
    if( db_num_rows( RRezult ) )
    {
        new Field[ 30 ];
        new Reputation;
        db_get_field_assoc( RRezult, "Reputation", Field, 30);
        Reputation = strval( Field );
        RK_REP[ playerid ][ RK_REPUTATION ] = Reputation;
    }
    db_free_result( RRezult );
}

public OnPlayerDisconnect( playerid )
{
    format( Query, sizeof( Query ), "UPDATE 'Reputation' FROM `REP` (`Name`, `Reputation`) VALUES('%s', '%d')", CName( playerid ), RK_REP[ playerid ][ RK_REPUTATION ] );
    db_free_result( db_query( Database, Query ) );
}
The part of the code witch contains SQLite
Reply
#10

Код:
SELECT `Reputation` FROM `REP` WHERE `Name` = '%s'
pawn Код:
new field[30];
db_get_field_assoc(RREzult, "Reputation", field, sizeof (field));
RK_REP[playerid][RK_REPUTATION] = strval(field);
Your UPDATE syntax is not correct, check the posts above.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)