06.02.2014, 11:48
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]);
}
}