MySQL saving stats. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL saving stats. (
/showthread.php?tid=216678)
MySQL saving stats. -
Haydz - 26.01.2011
Hey guys, could somebody please help me with saving stats. i'v tryed using this method.
When the player completed a mission it added a point to the type of mission they were doing.
pawn Код:
PlayerInfo[playerid][Shamal]++;
This is what i used to do when i used dini but i'v tryed it on mysql so i really had no idea how i would go about doing it.
So if somebody could give an example on how i would go about doing it it would be much appericated.
Re: MySQL saving stats. -
PeteShag - 26.01.2011
It should work.
I have this and save accounts
pawn Код:
CallBack: OneMinuteTimer()
{
if(mysql_ping() != 1)
{
mysql_reconnect();
}
for(new i = 0; i < MAX_PLAYERS; i ++ )
{
AccountInfo[i][PlayingTime] ++;//Adding one minute to the players playing time
Saveaccount(i);//Saving Account
//It works for me
}
}
Re: MySQL saving stats. -
Haydz - 26.01.2011
Strange, i'm guessing it's something eles in my code then.
pawn Код:
//playerfinishmission
{
PlayerInfo[playerid][Shamal]++;
SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
ResetMissionBar(playerid);
return 1;
}
pawn Код:
//the saving stock, the stats save when a player disconnects. and on a 3 min timer.
public SaveUser(playerid)
{
if(IsLogged(playerid))
{
new Query[300]; format(Query, sizeof(Query), "UPDATE users SET money = %d, score = %d, Shamal = %d, Cargo = %d, Helicopter = %d, ban = %d, ban_reason = '%s' WHERE username = '%s';", GetPlayerMoney(playerid), GetPlayerScore(playerid), PlayerInfo[playerid][Shamal], PlayerInfo[playerid][Cargo],PlayerInfo[playerid][Helicopter], PlayerInfo[playerid][Banned], PlayerInfo[playerid][Reason], GetName(playerid));
mysql_query(Query);
}
}
Re: MySQL saving stats. -
PeteShag - 26.01.2011
Do you get any error printed at the MySQL log?
EDIT:
WHERE username = '%s'
;"
You don't need that semicolon.
Re: MySQL saving stats. -
Haydz - 26.01.2011
That wont cause the problem as it saves other stats also. but i made it so the users save straight after the player finished the mission which now it saves stats. But without the example you gave i wouldn't have gotten it. Cheers man.
Re: MySQL saving stats. -
Not available - 26.01.2011
I'm not sure what the problem is, but you can try doing:
pawn Код:
PlayerInfo[playerid][Shamal] += 1;