SQLLITE Help please ! -
Healian - 15.08.2012
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
Re: SQLLITE Help please ! -
Healian - 15.08.2012
ANYHELP ?
Re: SQLLITE Help please ! -
Vince - 15.08.2012
Check the syntax for GetPlayerName and don't ignore warnings!
Re: SQLLITE Help please ! -
Healian - 15.08.2012
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
Re: SQLLITE Help please ! -
Healian - 15.08.2012
Also i corrected the player name to
pawn Code:
new pName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, pName, sizeof(pName));
Re: SQLLITE Help please ! -
Healian - 15.08.2012
OK I GOT IT TO WORK
Was an sql commands error