15.08.2012, 21:52
(
Last edited by Healian; 15/08/2012 at 11:20 PM.
)
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
I Got things to work with this
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
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;
}
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);