Not saving correctly -
ShoortyFl - 20.06.2015
So the problem is this doesn't save variables correctly in database, it sets the same strings for everyone in the db, everything is the same for everybody idk what is the problem
pawn Код:
stock UpdateIgraca(playerid)
{
format(gQuery, sizeof(gQuery), "UPDATE `Igraci` SET `Spol` = '%d', `Godine` = '%d', `Skin` = '%d', `Admin` = '%d', `Banovan` = '%d', `Opomene` = '%d', `Lisice` = '%d', `Lider` = '%d'", PI[playerid][Spol], PI[playerid][Godine], PI[playerid][Skin], PI[playerid][Admin], PI[playerid][Banovan], PI[playerid][Opomene], PI[playerid][Lisice], PI[playerid][Lider]);
mysql_function_query(konekt, gQuery, true, "OnQueryFinish", "ii", THREAD_OSTALO, playerid);
format(gQuery, sizeof(gQuery), "%s, `Clan` = '%d', `Rank` = '%d', `TrazeniNivo` = '%d', `Zatvoren` = '%d', `ZatvorenVreme` = '%d', `UhapsenPuta` = '%d', `Utisan` = '%d'", gQuery, PI[playerid][Clan], PI[playerid][Rank], PI[playerid][TrazeniNivo], PI[playerid][Zatvoren], PI[playerid][ZatvorenVreme], PI[playerid][UhapsenPuta], PI[playerid][Utisan], ImeIgraca(playerid));
mysql_function_query(konekt, gQuery, true, "OnQueryFinish", "ii", THREAD_OSTALO, playerid);
format(gQuery, sizeof(gQuery), "%s, `Int` = '%d', `Telefon` = '%d', `Imenik` = '%d', `Mobilni` = '%d', `Novac` = '%d', `Posao` = '%d', `PosaoUgovor` = '%d'", gQuery, GetPlayerInterior(playerid), PI[playerid][Telefon], PI[playerid][Imenik], PI[playerid][Mobilni], PI[playerid][Novac], PI[playerid][Posao], PI[playerid][PosaoUgovor]);
mysql_function_query(konekt, gQuery, true, "OnQueryFinish", "ii", THREAD_OSTALO, playerid);
format(gQuery, sizeof(gQuery), "%s, `Maska` = '%d', `Droga` = '%d', `Level` = '%d', `Exp` = '%d', `PDPoeni` = '%d', `SatiIgre` = '%d'", gQuery, PI[playerid][Maska], PI[playerid][Droga], PI[playerid][Level], PI[playerid][Exp], PI[playerid][PDPoeni], PI[playerid][SatiIgre]);
mysql_function_query(konekt, gQuery, true, "OnQueryFinish", "ii", THREAD_OSTALO, playerid);
format(gQuery, sizeof(gQuery), "%s, `Posao` = '%d', `PosaoUgovor` = '%d', `Kuca` = '%d', `RentaKucu` = '%d', `Banka` = '%d', `Kredit` = '%d', `IznosRate` = '%d', `PreostaloOdplatiti` = '%d' WHERE `Ime` = '%s'", gQuery, PI[playerid][PosaoUgovor], PI[playerid][Kuca], PI[playerid][RentaKucu], PI[playerid][Banka], PI[playerid][Kredit], PI[playerid][IznosRate], PI[playerid][PreostaloOdplatiti], ImeIgraca(playerid));
mysql_function_query(konekt, gQuery, true, "OnQueryFinish", "ii", THREAD_OSTALO, playerid);
return 1;
}
and the function that calls this
pawn Код:
CMD:gmx(playerid, params[])
{
if(PI[playerid][Admin] < 5) return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Niste ovlasteni za koristenje ove komande.");
new str[220];
format(str, sizeof(str), "(( Staff %s je zapoceo restart servera, server ce se restartovati za 5 sekundi. ))", ImeIgraca(playerid));
SendClientMessageToAll(DBLUE, str);
foreach(Player, i)
{
UpdateIgraca(i);
SetTimer("ServerGMX", 5000, false);
}
return 1;
}
Re: Not saving correctly -
Dusan01 - 20.06.2015
try it like this:
Re: Not saving correctly -
ShoortyFl - 20.06.2015
dude thats another mysql version lol
Re: Not saving correctly -
Dusan01 - 20.06.2015
Ah, sry my bad, can u give us: public OnQueryFinish
Re: Not saving correctly -
ShoortyFl - 20.06.2015
You don't need that public because thread that im sending query to is not doing anything
Re: Not saving correctly -
Dusan01 - 20.06.2015
then use this:
Код:
mysql_function_query(konekt, gQuery, false, "", "");
Код:
stock UpdateIgraca(playerid)
{
format(gQuery, sizeof(gQuery), "UPDATE `Igraci` SET `Spol` = '%d', `Godine` = '%d', `Skin` = '%d', `Admin` = '%d', `Banovan` = '%d', `Opomene` = '%d', `Lisice` = '%d', `Lider` = '%d'", PI[playerid][Spol], PI[playerid][Godine], PI[playerid][Skin], PI[playerid][Admin], PI[playerid][Banovan], PI[playerid][Opomene], PI[playerid][Lisice], PI[playerid][Lider]);
mysql_function_query(konekt, gQuery, false, "", "");
format(gQuery, sizeof(gQuery), "%s, `Clan` = '%d', `Rank` = '%d', `TrazeniNivo` = '%d', `Zatvoren` = '%d', `ZatvorenVreme` = '%d', `UhapsenPuta` = '%d', `Utisan` = '%d'", gQuery, PI[playerid][Clan], PI[playerid][Rank], PI[playerid][TrazeniNivo], PI[playerid][Zatvoren], PI[playerid][ZatvorenVreme], PI[playerid][UhapsenPuta], PI[playerid][Utisan], ImeIgraca(playerid));
mysql_function_query(konekt, gQuery, false, "", "");
format(gQuery, sizeof(gQuery), "%s, `Int` = '%d', `Telefon` = '%d', `Imenik` = '%d', `Mobilni` = '%d', `Novac` = '%d', `Posao` = '%d', `PosaoUgovor` = '%d'", gQuery, GetPlayerInterior(playerid), PI[playerid][Telefon], PI[playerid][Imenik], PI[playerid][Mobilni], PI[playerid][Novac], PI[playerid][Posao], PI[playerid][PosaoUgovor]);
mysql_function_query(konekt, gQuery, false, "", "");
format(gQuery, sizeof(gQuery), "%s, `Maska` = '%d', `Droga` = '%d', `Level` = '%d', `Exp` = '%d', `PDPoeni` = '%d', `SatiIgre` = '%d'", gQuery, PI[playerid][Maska], PI[playerid][Droga], PI[playerid][Level], PI[playerid][Exp], PI[playerid][PDPoeni], PI[playerid][SatiIgre]);
mysql_function_query(konekt, gQuery, false, "", "");
format(gQuery, sizeof(gQuery), "%s, `Posao` = '%d', `PosaoUgovor` = '%d', `Kuca` = '%d', `RentaKucu` = '%d', `Banka` = '%d', `Kredit` = '%d', `IznosRate` = '%d', `PreostaloOdplatiti` = '%d' WHERE `Ime` = '%s'", gQuery, PI[playerid][PosaoUgovor], PI[playerid][Kuca], PI[playerid][RentaKucu], PI[playerid][Banka], PI[playerid][Kredit], PI[playerid][IznosRate], PI[playerid][PreostaloOdplatiti], ImeIgraca(playerid));
mysql_function_query(konekt, gQuery, false, "", "");
return 1;
}
Re: Not saving correctly -
ShoortyFl - 21.06.2015
Nope, anyone ?
Re: Not saving correctly -
IzadorO - 21.06.2015
I can not really understand your language, not the SQL itself. But try adding WHERE `Ime` = '%s' and the according variable, with all strings?
Re: Not saving correctly -
Stanford - 21.06.2015
I think he means that the statistics aren't saved after the server restart if I did get it right..
About this:
pawn Код:
foreach(Player, i)
{
UpdateIgraca(i);
SetTimer("ServerGMX", 5000, false);
}
Show us "ServerGMX" function as this function might be the reason why just this happens.. I am thinking that the stats are saved only for one player that is online in your server not sure though I didn't check your server nor its code!
Re: Not saving correctly -
Konstantinos - 21.06.2015
- You execute incomplete queries when all you have to do is format them and call mysql_function_query only once; at the end of UpdateIgraca.
- You create multiply timers in the loop. It should have been after the loop and you may need to increase the interval just for sure.