Timer doesnt seem to quit the loop.
#9

pawn Код:
public Trucker_VehicleTimer(playerid)
{
    static continueRun[MAX_PLAYERS];
    if(!continueRun[playerid])
    {
        new OldVehicleID = APlayerData[playerid][VehicleID];
        new NewVehicleID = GetPlayerVehicleID(playerid);
        new OldTrailerID = APlayerData[playerid][TrailerID];
        new NewTrailerID = GetVehicleTrailer(GetPlayerVehicleID(playerid));

        if (APlayerData[playerid][VehicleTimerTime] != 0)
        {
            // If VehicleID and TrailerID are still the same as when the player accepted the job
            if ((OldVehicleID == NewVehicleID) && (OldTrailerID == NewTrailerID))
                APlayerData[playerid][VehicleTimerTime] = Trucker_TimeToFailMission; // Reset the time before the mission fails
            else // One (or both) aren't still the same (player lost his trailer or vehicle)
            {
                new TimeLeft[5];
                // Reduce the time left by 1
                APlayerData[playerid][VehicleTimerTime] = APlayerData[playerid][VehicleTimerTime] - 1;
                // Convert the time left to a string for displaying
                valstr(TimeLeft, APlayerData[playerid][VehicleTimerTime]);
                // Display the time left
                GameTextForPlayer(playerid, TimeLeft, 1000, 4);
                // Send only one message to inform the player what he must do
                if (APlayerData[playerid][VehicleTimerTime] == (Trucker_TimeToFailMission - 1))
                    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must enter your vehicle or re-attach your trailer");
            }
        }
        else
        {
            // Time left has reached 0
            Trucker_EndJob(playerid);
            // If the player is part of a convoy, kick him from it (as he failed his mission, the rest of the convoy would be stuck)
            Convoy_Leave(playerid);
            // Inform the player that he failed the mission
            GameTextForPlayer(playerid, "~w~You ~r~failed~w~ your mission. You lost ~y~$1000~w~ to cover expenses.", 5000, 4);
            GivePlayerCash(playerid, -1000);
            KillTimer(APlayerData[playerid][VehicleTimer]);
            continueRun[playerid] = 1;
        }
    }
    else
    {
        KillTimer(APlayerData[playerid][VehicleTimer]);
    }
}
This should end the looping problem, try to print(str[]); to debug it if it still runs after getting killed twice.
Reply


Messages In This Thread
Timer doesnt seem to quit the loop. - by thimo - 05.02.2014, 12:04
Re: Timer doesnt seem to quit the loop. - by Phil_Cutcliffe - 05.02.2014, 12:07
Re: Timer doesnt seem to quit the loop. - by thimo - 05.02.2014, 12:10
Re: Timer doesnt seem to quit the loop. - by Phil_Cutcliffe - 05.02.2014, 12:12
Re: Timer doesnt seem to quit the loop. - by thimo - 05.02.2014, 12:16
Re: Timer doesnt seem to quit the loop. - by Phil_Cutcliffe - 05.02.2014, 12:25
Re: Timer doesnt seem to quit the loop. - by thimo - 05.02.2014, 12:26
Re: Timer doesnt seem to quit the loop. - by thimo - 06.02.2014, 11:42
Re: Timer doesnt seem to quit the loop. - by BullseyeHawk - 06.02.2014, 11:48

Forum Jump:


Users browsing this thread: 1 Guest(s)