SQLLITE Help please !
#1

I want to use SQLLITE As a database in my gamemode and to build the ideas i am trying to make a simple /save func
to test saving data to the database but unfortunately it does not work

here is my cmd

pawn Code:
if (strcmp("/saveinfo", cmdtext, true, 10) == 0)
    {
       
        new Query[256], pName, pScore, pMoney ;
        pName = GetPlayerName(playerid);
        pScore = GetPlayerScore(playerid);
        pMoney = GetPlayerMoney(playerid);
        format(Query, sizeof(Query), "UPDATE `Accounts` SET (`MONEY` = '%d', `SCORE` = '%d') WHERE `NAME` = '%s'", pMoney, pScore, pName);
        db_query(DATABASE, Query);
        db_free_result(db_query(DATABASE, Query));
        return 1;
    }
I Got things to work with this

pawn Code:
new Query[1000], Query2[1000], pScore[128], pMoney[256];
        ew pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(pScore, sizeof(pScore), "%i",GetPlayerScore(playerid));
        format(pMoney, sizeof(pMoney), "%i",GetPlayerMoney(playerid));
       
        format(Query2, sizeof(Query2), "INSERT INTO `Accounts` (`NAME`) VALUES('%s')", DB_Escape(pName));
        db_free_result(db_query(DATABASE, Query2));
        format(Query, sizeof(Query), "UPDATE `Accounts` SET SCORE = '%s', CASH = '%s' WHERE `NAME` = '%s'", pScore, pMoney, DB_Escape(pName));
       // db_query(DATABASE, Query);
        db_free_result(db_query(DATABASE, Query));
        SendClientMessage(playerid, COL_VIP, pName);
        SendClientMessage(playerid, COL_VIP, pScore)
        SendClientMessage(playerid, COL_VIP, pMoney);
        SendClientMessage(playerid, COL_VIP, " ");
        SendClientMessage(playerid, COL_VIP, " ");
        SendClientMessage(playerid, COL_VIP, Query);
OFC This is a shity crap cuz i was just learning myself how to use the sqllite in PAWN but it is how i got things to work
Reply
#2

ANYHELP ?
Reply
#3

Check the syntax for GetPlayerName and don't ignore warnings!
Reply
#4

Warnings

Code:
ARole.pwn(101) : warning 202: number of arguments does not match definition
ARole.pwn(101) : warning 202: number of arguments does not match definition
They are pointing to the query format
Reply
#5

Also i corrected the player name to

pawn Code:
new pName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, pName, sizeof(pName));
Reply
#6

OK I GOT IT TO WORK Was an sql commands error
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)