Timer doesnt seem to quit the loop.
#1

Okay so i am experiencing problems with killing a timer. For some reason sometimes this function keeps running in an infinite loop. Causing players to lose all of their money. This is my function:
pawn Код:
public Trucker_VehicleTimer(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]);
    }
}
The timer keeps running. How to stop it when it keeps looping?
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: 2 Guest(s)