SA-MP Forums Archive
timer doesnt count down D: - 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: timer doesnt count down D: (/showthread.php?tid=164970)



timer doesnt count down D: - Kar - 02.08.2010

pawn Код:
new AtmRobTime[MAX_SERVER_SLOTS];
// one second timer
pawn Код:
if(AtmRobTime[i] == 1)
        {
            RobAtm(i);
            AtmRobTime[i] = 0;
        }
        if(AtmRobTime[i] >= 1)
        {
            AtmRobTime[i] --;
        }
// in robatm cmd
pawn Код:
AtmRobTime[playerid] = 13;
                        format(gametext, sizeof(gametext), "~w~Do Not Leave The ~r~Checkpoint ~n~~w~Untill The Robbery Is Complete %d seconds",AtmRobTime[playerid]);
                        GameTextForPlayer(playerid,gametext,13000,3);
pawn Код:
CMD:robatm(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid,2,2172.8428, 1416.7751, 11.0625)
    || IsPlayerInRangeOfPoint(playerid,2,2110.5188, 2060.4219, 10.8203)
    || IsPlayerInRangeOfPoint(playerid,2,2134.0115, 2379.3159, 10.8203)
    || IsPlayerInRangeOfPoint(playerid,2,2455.5420, 1681.4117, 11.0234)
    || IsPlayerInRangeOfPoint(playerid,2,-2635.9067,1398.5020,7.0938)
    || IsPlayerInRangeOfPoint(playerid,2,-1575.3977,902.4458,7.5610)
    || IsPlayerInRangeOfPoint(playerid,2,-2434.0908,516.8967,30.3705)
    || IsPlayerInRangeOfPoint(playerid,2,852.7184,-1760.9111,13.5491)
    || IsPlayerInRangeOfPoint(playerid,2,1243.2965,-1561.1505,13.5545)
    || IsPlayerInRangeOfPoint(playerid,2,1787.9928,-1592.2491,13.4870))
    {
            if(UsedATMRecently[playerid] != 0) return SendClientMessage(playerid, COLOR_RED,PlzWait);
            if(HasRobbedATMRecent != 0) return SendClientMessage(playerid, COLOR_RED,RobATMWait);
            if(gTeam[playerid] != TEAM_COPS && gTeam[playerid] != TEAM_MEDIC && gTeam[playerid] != TEAM_UNDERCOVERCIA)
            {
                if(!IsPlayerInAnyVehicle(playerid))
                {
                        HasRobbedATMRecent = 120;
                        new copmsg[128],robbername[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, robbername, sizeof(robbername));
                        format(copmsg, sizeof(copmsg), "[CRIME] %s[%d] has Started An ATM Machine Robbery Location: %s", robbername,playerid, GetPlayerArea(playerid));
                        CopRadio(ROYALBLUE,copmsg);
                        new gametext[128];
                        AtmRobTime[playerid] = 13;
                        format(gametext, sizeof(gametext), "~w~Do Not Leave The ~r~Checkpoint ~n~~w~Untill The Robbery Is Complete %d seconds",AtmRobTime[playerid]);
                        GameTextForPlayer(playerid,gametext,13000,3);
                }
                else return SendClientMessage(playerid, RED, "You cannot rob an ATM from inside a vehicle.");
            }
            else return SendClientMessage(playerid, RED, "Police Officers/Medics/Undercover CIA Cannot Rob Atms.");
    }
    else return SendClientMessage(playerid, red, "You must be on an ATM checkpoint to rob it.");
    return 1;
}
forward RobAtm(playerid);
public RobAtm(playerid)
{
    new chances = random(5);
    if(chances == 0 || chances == 1 || chances == 4 || chances == 5)
    {
        new cash = random(42562), robbername[MAX_PLAYER_NAME], robbermsg[128], copmsg[128];
        PlayerInfo[playerid][Money] += cash;
        GetPlayerName(playerid, robbername, sizeof(robbername));
        SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+ 4);
        format(robbermsg, sizeof(robbermsg), "You robbed the ATM. You got $%d. Watch out for the police!", cash);
        format(copmsg, sizeof(copmsg), "[CRIME] %s[%d] has robbed $%d from an ATM Machine. Location: %s", robbername,playerid, cash, GetPlayerArea(playerid));
        CopRadio(ROYALBLUE,copmsg);
        SendClientMessage(playerid, WHITE, robbermsg);
        SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
        printf("%s[ID:%d] Has Robbed %d From An ATM.", Playername(playerid),playerid,cash);
        new msg[128];
        format(msg,sizeof(msg),"%s[%d] Has Robbed %d From An Atm In %s",Playername(playerid),playerid,cash,GetPlayerArea(playerid));
        IRC_GroupSay(gGroupID, IRC_CHANNEL, msg);
        return true;
        }
        else if(chances == 3)
        {
            SendClientMessage(playerid, red, "You couldn't rob any money this time. Try again later.");
            printf("%s[ID:%d] failed to rob an ATM.", Playername(playerid),playerid);
            return true;
        }
    return 1;
}



Re: timer doesnt count down D: - Mystique - 02.08.2010

When I quickly checked this, what the hell is [MAX_SERVER_SLOTS] ? Shouldn't it be [MAX_PLAYERS] or am I wrong?


Re: timer doesnt count down D: - Saurik - 02.08.2010

Quote:
Originally Posted by Mystique
Посмотреть сообщение
When I quickly checked this, what the hell is [MAX_SERVER_SLOTS] ? Shouldn't it be [MAX_PLAYERS] or am I wrong?
yes...

where did slots come from?


Re: timer doesnt count down D: - MrDeath537 - 02.08.2010

Is the timer "repeat" value in "true"?


Re: timer doesnt count down D: - Kar - 02.08.2010

new AtmRobTime[MAX_PLAYERS];

ok but it still says 13 seconds left it doesnt count down

edit. SetTimer("wantedcolor",1000,true);//2 Seconds lol