How can I make this stop showing 0 minutes? /ajail
#1

pawn Код:
for(new p = 0; p < MAX_PLAYERS; p++)
    {
        if(LoggedIn[p] == 1 && IsPlayerConnected(p))
        {
            if(AdminJail[p] >= 1 && AdminJail[p] != 0)
            {
                AdminJail[p] --;
               
                format(string, sizeof(string), "You have %d minute(s) left in Admin Jail.", AdminJail[p]);
                SendClientMessage(p, COLOUR_GREY, string);

                if(AdminJail[p] == 0)
                {
                    SendClientMessage(p, COLOUR_LIGHTBLUE, "You have been released from Admin Jail");
                    MySQL_SetInteger(PlayerSQLID[p], "AdminJail", -1, "accounts");
                    AdminJail[p] = -1;
                    SetPlayerPos(p, -216.0915,972.2845,19.3201);
                    SetPlayerVirtualWorld(p, 0);
                    SetPlayerInterior(p, 0);
                    SetCameraBehindPlayer(p);//release.
                }
            }
        }
    }
This may seem like a stupid question, but when the timer reaches 0, it still sends a client message and I've no idea why. Could someone tell me what I'm doing wrong?
Reply
#2

How about killing the timer after SetCameraBehindPlayer(p);

KillTimer(timerid);
pawn Код:
for(new p = 0; p < MAX_PLAYERS; p++)
    {
        if(LoggedIn[p] == 1 && IsPlayerConnected(p))
        {
            if(AdminJail[p] >= 1 && AdminJail[p] != 0)
            {
                AdminJail[p] --;
               
                format(string, sizeof(string), "You have %d minute(s) left in Admin Jail.", AdminJail[p]);
                SendClientMessage(p, COLOUR_GREY, string);

                if(AdminJail[p] == 0)
                {
                    SendClientMessage(p, COLOUR_LIGHTBLUE, "You have been released from Admin Jail");
                    MySQL_SetInteger(PlayerSQLID[p], "AdminJail", -1, "accounts");
                    AdminJail[p] = -1;
                    SetPlayerPos(p, -216.0915,972.2845,19.3201);
                    SetPlayerVirtualWorld(p, 0);
                    SetPlayerInterior(p, 0);
                    SetCameraBehindPlayer(p);//release.
                    // Kill Timer over here
                }
            }
        }
    }
Reply
#3

it looks like it's more then a player's loop, it's for each player, so you should only skip that loop, continue does that..
pawn Код:
for(new p = 0; p < MAX_PLAYERS; p++)
    {
        if(LoggedIn[p] == 1 && IsPlayerConnected(p))
        {
            if(AdminJail[p] >= 1 && AdminJail[p] != 0)
            {
                if(AdminJail[p] == 0)
                {
                    SendClientMessage(p, COLOUR_LIGHTBLUE, "You have been released from Admin Jail");
                    MySQL_SetInteger(PlayerSQLID[p], "AdminJail", -1, "accounts");
                    AdminJail[p] = -1;
                    SetPlayerPos(p, -216.0915,972.2845,19.3201);
                    SetPlayerVirtualWorld(p, 0);
                    SetPlayerInterior(p, 0);
                    SetCameraBehindPlayer(p);//release.
                    continue;
                }
                AdminJail[p] --;

                format(string, sizeof(string), "You have %d minute(s) left in Admin Jail.", AdminJail[p]);
                SendClientMessage(p, COLOUR_GREY, string);
            }
        }
    }
Reply
#4

Ahh thank you.

I have another question....


in
OnGameModeInit sometimes various textdraws don't load, sometimes. Is there any reason for this? Usually they always do, sometimes they don't.
Reply
#5

That didn't fix it, I'm afraid.
Reply
#6

Is this a global timer or a player timer?
P.S I'm not sure why are you checking the value twice, the first check should return true since the value is not 0, and right after you're checking again if the value is not 0.
pawn Код:
if(AdminJail[p] >= 1 && AdminJail[p] != 0)
This should be enough:
pawn Код:
if(AdminJail[p] > 0)
Reply
#7

Global time, I know...

Yeah that's what it originally was. It didn't work.
Reply
#8

If none if the above helps, I'd suggest to debug in order to see what is its current value.
pawn Код:
for(new p = 0; p < MAX_PLAYERS; p++)
    {
        if(LoggedIn[p] == 1 && IsPlayerConnected(p))
        {
            if(AdminJail[p] >= 1 && AdminJail[p] != 0)
            {
                AdminJail[p] --;
               
                format(string, sizeof(string), "You have %d minute(s) left in Admin Jail.", AdminJail[p]);
                SendClientMessage(p, COLOUR_GREY, string);

                if(AdminJail[p] == 0)
                {
                    SendClientMessage(p, COLOUR_LIGHTBLUE, "You have been released from Admin Jail");
                    MySQL_SetInteger(PlayerSQLID[p], "AdminJail", -1, "accounts");
                    AdminJail[p] = -1;
                    SetPlayerPos(p, -216.0915,972.2845,19.3201);
                    SetPlayerVirtualWorld(p, 0);
                    SetPlayerInterior(p, 0);
                    SetCameraBehindPlayer(p);//release.
                }
            }
            printf("Player %d AdminJail value: %d", p, AdminJail[p]);
        }
    }
Reply
#9

It returned -1.
Reply
#10

Still unresolved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)