Problem updating db / Muted time ended.
#1

Hey , i have a problem , when my silence time is ended it not updating my database.
pawn Код:
/* ------------------------------------------------------ */

    foreach(Player, x) {
   
        playerVariables[x][pConnectedSeconds] += 1;
        if(gTime[2] >= 59) syncPlayerTime(x);
        if(playerVariables[x][pStatus] == 1)
        {
            if(playerVariables[x][pMuted] > 0)
            {
                if(playerVariables[x][pMuteTime] > 0)
                {
                    playerVariables[x][pMuteTime]--;
                }
                if(playerVariables[x][pMuteTime] <= 0)
                {
                    new string2[184];
                    playerVariables[x][pMuted] = 0;
                    playerVariables[x][pMuteTime] = 0;
                    SendClientMessage(x, COLOR_LIGHTRED, "* Your time of silence has ended.");
                    format(string2, sizeof(string2), "UPDATE playeraccounts SET `Muted`='0',`MuteTime`='0' WHERE `playername`='%s'");
                    mysql_query(string2);
                   
                }
            }
            if(playerVariables[x][pAnticheatExemption] >= 1) {
                playerVariables[x][pAnticheatExemption]--;
            }

            if(playerVariables[x][pAdminLevel] > 0) {
                if(GetPVarInt(x, "pAdminPINConfirmed") >= 1)
                    SetPVarInt(x, "pAdminPINConfirmed", GetPVarInt(x, "pAdminPINConfirmed")-1);
            }

            if(playerVariables[x][pPhoneCall] != -1) {

                playerVariables[x][pPhoneCredit]--;

                if(playerVariables[x][pPhoneCredit] == 60) {
                    SendClientMessage(x, COLOR_HOTORANGE, "You're almost out of credit, you have 60 seconds left.");
                }
               
                else if(playerVariables[x][pPhoneCredit] < 1) {
                    SendClientMessage(x, COLOR_WHITE, "Your phone has ran out of credit, visit a 24/7 to buy a top up voucher.");

                    if(GetPlayerSpecialAction(x) == SPECIAL_ACTION_USECELLPHONE) {
                        SetPlayerSpecialAction(x, SPECIAL_ACTION_STOPUSECELLPHONE);
                    }
                    if(playerVariables[x][pPhoneCall] != -1 && playerVariables[x][pPhoneCall] < MAX_PLAYERS) {

                        SendClientMessage(playerVariables[x][pPhoneCall], COLOR_WHITE, "Your call has been terminated by the other party (ran out of credit).");

                        if(GetPlayerSpecialAction(playerVariables[x][pPhoneCall]) == SPECIAL_ACTION_USECELLPHONE) {
                            SetPlayerSpecialAction(playerVariables[x][pPhoneCall], SPECIAL_ACTION_STOPUSECELLPHONE);
                        }
                        playerVariables[playerVariables[x][pPhoneCall]][pPhoneCall] = -1;
                    }
                    playerVariables[x][pPhoneCall] = -1;
                }
            }
            if(playerVariables[x][pSpectating] != INVALID_PLAYER_ID) { // OnPlayerInteriorChange doesn't work properly when spectating.
                if(GetPlayerInterior(x) != GetPlayerInterior(playerVariables[x][pSpectating])){
                    SetPlayerInterior(x, GetPlayerInterior(playerVariables[x][pSpectating]));
                }
                if(GetPlayerVirtualWorld(x) != GetPlayerVirtualWorld(playerVariables[x][pSpectating])){
                    SetPlayerVirtualWorld(x, GetPlayerVirtualWorld(playerVariables[x][pSpectating]));
                }
            }
            if(playerVariables[x][pBackup] != -1) {
                if(IsPlayerConnectedEx(playerVariables[x][pBackup])) {
                    GetPlayerPos(playerVariables[x][pBackup], playerVariables[playerVariables[x][pBackup]][pPos][0], playerVariables[playerVariables[x][pBackup]][pPos][1], playerVariables[playerVariables[x][pBackup]][pPos][2]);
                    SetPlayerCheckpoint(x, playerVariables[playerVariables[x][pBackup]][pPos][0], playerVariables[playerVariables[x][pBackup]][pPos][1], playerVariables[playerVariables[x][pBackup]][pPos][2], 10.0);
                }
                else {
                    playerVariables[x][pBackup] = -1;
                    playerVariables[x][pCheckpoint] = 0;

                    SendClientMessage(x, COLOR_GREY, "The player requesting for backup has disconnected.");
                    DisablePlayerCheckpoint(x);
                }
            }

            if(playerVariables[x][pMatrunTime] >= 1) {
                playerVariables[x][pMatrunTime]++;
            }
           
            if(playerVariables[x][pHackWarnings] >= 1) {
                playerVariables[x][pHackWarnTime]++;

                if(playerVariables[x][pHackWarnTime] >= 10) {
                    playerVariables[x][pHackWarnings] = 0;
                    playerVariables[x][pHackWarnTime] = 0;
                }
            }

            if(playerVariables[x][pDropCarTimeout] >= 1) {
                playerVariables[x][pDropCarTimeout]--;
                if(playerVariables[x][pDropCarTimeout] == 1) {
                    playerVariables[x][pDropCarTimeout] = 0;
                    SendClientMessage(x, COLOR_WHITE, "You can now drop vehicles again at the crane.");
                }
            }
            if(playerVariables[x][pFreezeTime] != 0) {
                TogglePlayerControllable(x, 0);
                if(playerVariables[x][pFreezeType] == 5)
                    ApplyAnimation(x, "FAT", "IDLE_TIRED", 4.1, 1, 1, 1, 1, 0, 1);
                   
                if(playerVariables[x][pFreezeTime] > 0) {
                    playerVariables[x][pFreezeTime]--;
                    if(playerVariables[x][pFreezeTime] == 0) {
                        if(playerVariables[x][pFreezeType] == 5) {
                            SetPlayerDrunkLevel(x, 0);
                            ClearAnimations(x);
                        }
                        playerVariables[x][pFreezeType] = 0;
                        TogglePlayerControllable(x, true);
                    }
                }

            }

            if(playerVariables[x][pPrisonID] > 0) {
                playerVariables[x][pPrisonTime]--;

                switch(playerVariables[x][pPrisonID]) {
                    case 1: {
                        format(szMessage, sizeof(szMessage), "~n~~n~~n~~n~~n~~n~~n~ ~r~Prisoned!~n~~w~%d seconds (%d minutes) left", playerVariables[x][pPrisonTime], playerVariables[x][pPrisonTime]/60);
                    }
                    case 2, 3: { // We're going to be using 3 for IC jail, so... yeah
                        format(szMessage, sizeof(szMessage), "~n~~n~~n~~n~~n~~n~~n~ ~r~Jailed!~n~~w~%d seconds (%d minutes) left", playerVariables[x][pPrisonTime], playerVariables[x][pPrisonTime]/60);
                    }
                }

                GameTextForPlayer(x, szMessage, 2000, 3); // Always specify the game text time longer than the intended time; it always fades out before it should, causing an annoying flash.

                if(playerVariables[x][pPrisonTime] == 1 && playerVariables[x][pPrisonID] >= 1) {
                    playerVariables[x][pPrisonID] = 0;
                    playerVariables[x][pPrisonTime] = 0;
                    SendClientMessage(x, COLOR_WHITE, "Your time is up! You have been released from jail.");
                    SetPlayerPos(x, 1545.0101,-1676.0103,13.5595);
                    SetPlayerVirtualWorld(x, 0);
                    SetPlayerInterior(x, 0);
                }
            }

            if(playerVariables[x][pSpamCount] >= 1)
                playerVariables[x][pSpamCount]--;

            if(playerVariables[x][pSpamCount] >= 5 && playerVariables[x][pAdminLevel] == 0) {
                playerVariables[x][pMuted] = 10;
                playerVariables[x][pSpamCount] = 0;
                SendClientMessage(x, COLOR_GREY, "You have been auto-muted for spamming. You will be unmuted in 10 seconds.");
            }
            if(GetPlayerMoney(x) != playerVariables[x][pMoney]) {
                ResetPlayerMoney(x);
                GivePlayerMoney(x, playerVariables[x][pMoney]);
            }
        }
    }

    return true;
}
The message is showing , i can talk to the chat, but when i reconnect i am still muted , because the database isn't updating . If i do /unmute the database is updating , and Muted goes to 0 , and MutedTime to 0 too in phpmyadmin.
Unmute cmd:
pawn Код:
CMD:unmute(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if (playerVariables[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
        {
            new id,string[256],sendername[25],giveplayer[25];
            if(sscanf(params, "u",id)) return SCM(playerid,0xFFFFFFFF, "{B8DBFF}Syntax: /unmute <Name/Playerid>");
            if(IsPlayerConnected(id))
            {
                playerVariables[id][pMuted] = 0;
                playerVariables[id][pMuteTime] = 0;
                GetPlayerName(id, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "* You were unmuted by Admin %s.", sendername);
                SendClientMessage(id, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "{f03337}Warning: Admin %s unmuted %s.", sendername,giveplayer);
                ABroadCast(COLOR_WHITE,string,3);
                new string2[184];
                format(string2, sizeof(string2), "UPDATE playeraccounts SET `Muted`='0',`MuteTime`='0' WHERE `playername`='%s'",giveplayer);
                mysql_query(string2);
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Player not connected.");
            }
        }
    }
    return 1;
}
Reply
#2

UP!
I give rep , what is wrong there?
Reply
#3

Replace this line:
pawn Код:
format(string2, sizeof(string2), "UPDATE playeraccounts SET `Muted`='0',`MuteTime`='0' WHERE `playername`='%s'");
With these:
pawn Код:
new name[24];
GetPlayerName(x, name, sizeof(name));
format(string2, sizeof(string2), "UPDATE playeraccounts SET `Muted`='0',`MuteTime`='0' WHERE `playername`='%s'", name);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)