MySQL saving stats.
#1

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.
Reply
#2

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
    }
}
Reply
#3

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);
    }
}
Reply
#4

Do you get any error printed at the MySQL log?

EDIT:

WHERE username = '%s';"

You don't need that semicolon.
Reply
#5

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.
Reply
#6

I'm not sure what the problem is, but you can try doing:
pawn Код:
PlayerInfo[playerid][Shamal] += 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)