MySQL should wear glasses :)
#1

Hi guys

I have problem with saving player stats... The problem is that the stats are messing up when i close my gamemode i have this code under OnGameModeExit
pawn Код:
public OnGameModeExit()
{
    ZacuvajIgraci()
    return 1;
}

forward ZacuvajIgraci();
public ZacuvajIgraci()
{
    foreach(new i : Player)
    {
        if(IsPlayerConnected(i))
        {
            if(ProfilVcitan[i] == 1)
            {
                format( queryig, sizeof(queryig), "UPDATE Igraci SET pKey = '%s', pLevel = '%d', pAdmin = '%d', pDonateRank = '%d', pConnectTime = '%d', pReg = '%d', pSex = '%d', pAge = '%d', pOrigin = '%d', pExp = '%d', pCash = '%d', pAccount = '%d', pPhoneBook = '%d', pLottoNr = '%d', pFishes = '%d', pBiggestFish = '%d', pJob = '%d', pPayCheck = '%d', pHeadValue = '%d', pJailed = '%d'",
                PlayerInfo[i][pKey],
                PlayerInfo[i][pLevel],
                PlayerInfo[i][pAdmin],
                PlayerInfo[i][pDonateRank],
                PlayerInfo[i][pConnectTime],
                PlayerInfo[i][pReg],
                PlayerInfo[i][pSex],
                PlayerInfo[i][pAge],
                PlayerInfo[i][pOrigin],
                PlayerInfo[i][pExp],
                PlayerInfo[i][pCash],
                PlayerInfo[i][pAccount],
                PlayerInfo[i][pPhoneBook],
                PlayerInfo[i][pLottoNr],
                PlayerInfo[i][pFishes],
                PlayerInfo[i][pBiggestFish],
                PlayerInfo[i][pJob],
                PlayerInfo[i][pPayCheck],
                PlayerInfo[i][pHeadValue],
                PlayerInfo[i][pJailed]);

                //etc,etc,etc,etc
                //etc,etc,etc,etc
                //etc,etc,etc,etc
                //etc,etc,etc,etc
                //etc,etc,etc,etc

            }
        }
    }
    return 1;
}
Eg. If i had 10.000 cash and someone from the onnline players had 5000 and then MySQL will save/write 5000 cash to me also... And my player stats are forever GONE
Reply
#2

You need glasses

Код:
format( queryig, sizeof(queryig), "UPDATE Igraci SET pKey = '%s', pLevel = '%d', pAdmin = '%d', pDonateRank = '%d', pConnectTime = '%d', pReg = '%d', pSex = '%d', pAge = '%d', pOrigin = '%d', pExp = '%d', pCash = '%d',\
 pAccount = '%d', pPhoneBook = '%d', pLottoNr = '%d', pFishes = '%d', pBiggestFish = '%d', pJob = '%d', pPayCheck = '%d', pHeadValue = '%d', pJailed = '%d' missing something here",
PlayerInfo[i][pKey],
PlayerInfo[i][pLevel],
PlayerInfo[i][pAdmin],
PlayerInfo[i][pDonateRank],
PlayerInfo[i][pConnectTime],
PlayerInfo[i][pReg],
PlayerInfo[i][pSex],
PlayerInfo[i][pAge],
PlayerInfo[i][pOrigin],
PlayerInfo[i][pExp],
PlayerInfo[i][pCash],
PlayerInfo[i][pAccount],
PlayerInfo[i][pPhoneBook],
PlayerInfo[i][pLottoNr],
PlayerInfo[i][pFishes],
PlayerInfo[i][pBiggestFish],
PlayerInfo[i][pJob],
PlayerInfo[i][pPayCheck],
PlayerInfo[i][pHeadValue],
PlayerInfo[i][pJailed]
here too);
You also do not need to use the apostrophes' for the integers (%d)..

EDIT: Stupid typos

EDIT2: Oh yeah, why the hell are you saving this on onplayergamemodeexit? Also, why don't you make stuff easier and put all that in a stock?
Reply
#3

Haha yea i should wear glasses but not for a reason that you've posted...

That was string which connects to another string which i didn't posted, so for WHERE pIgracID = '%d' i have putted just "i" (the playerid) but i created unique player id which is PlayerInfo[i][pIgracID] so i replaced "i" with "PlayerInfo[i][pIgracID]" and that's how i fixed it.

Anyway REP+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)