19.11.2013, 18:44
Well, I've searched and searched and found no solution yet, so I decided to post here.
My problem is basically I can't stop a timer. It gives me no errors and no warnings, it simply doesn't stop. It's used for 2 things and in 2 different situations, 1st it's used when a player enters the vehicle as driver and the other is started when a mechanic is fixing it, they don't start at same time never. The problem is that it doesn't stop, when he exits or when he stops fixing and when I enter another car it just do both (well it's just for updating textdraws for velocity and kilometers and other shits, so when I exit it and enter another vehicle the textdraws updates overlap. I've added a debug line to the timer to be sure if it would stop and found out it wouldn't...)
So can please someone tell me if I'm doing something wrong or what I can do to fix this?
The code is too damn long so I won't post it all here, but the main things are there:
My problem is basically I can't stop a timer. It gives me no errors and no warnings, it simply doesn't stop. It's used for 2 things and in 2 different situations, 1st it's used when a player enters the vehicle as driver and the other is started when a mechanic is fixing it, they don't start at same time never. The problem is that it doesn't stop, when he exits or when he stops fixing and when I enter another car it just do both (well it's just for updating textdraws for velocity and kilometers and other shits, so when I exit it and enter another vehicle the textdraws updates overlap. I've added a debug line to the timer to be sure if it would stop and found out it wouldn't...)
So can please someone tell me if I'm doing something wrong or what I can do to fix this?
The code is too damn long so I won't post it all here, but the main things are there:
pawn Код:
new Timer:VU[MAX_VEHICLES];
timer VehiclesU[500](vid, playerid)
{
if(!PlayInfo[playerid][Fixing])
{
new Float:sx, Float:sy, Float:sz, Float:speed1, Float:speed2, speedo[40], kms[100], TW[100], oil[100], fuel[100], engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
//engine
if(VehInfo[vid][StartEng] >= 1)
{
if(VehInfo[vid][StartEng] < 4)
VehInfo[vid][StartEng]++;
else
{
SendClientMessage(playerid, X11_GREEN_4, "[INFO]: Engine Started.");
VehInfo[vid][StartEng] = 0;
SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
}
}
....
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
VU[GetPlayerVehicleID(playerid)] = repeat VehiclesU(GetPlayerVehicleID(playerid), playerid);
PlayInfo[playerid][InCar] = GetPlayerVehicleID(playerid);
PlayerTextDrawShow(playerid, SpeedoBack[playerid]);
PlayerTextDrawShow(playerid, Speedometer[playerid]);
PlayerTextDrawShow(playerid, TurnLeft[playerid]);
PlayerTextDrawShow(playerid, HeadLights[playerid]);
PlayerTextDrawShow(playerid, TurnRight[playerid]);
PlayerTextDrawShow(playerid, Kilometrage[playerid]);
PlayerTextDrawShow(playerid, FuelLevel[playerid]);
PlayerTextDrawShow(playerid, OilLevel[playerid]);
PlayerTextDrawShow(playerid, FuelWarn1[playerid]);
PlayerTextDrawShow(playerid, FuelWarn2[playerid]);
PlayerTextDrawShow(playerid, OilWarn1[playerid]);
PlayerTextDrawShow(playerid, OilWarn2[playerid]);
/*if(VehType(playerid) != 3 && VehType(playerid) != 4)
{*/
PlayerTextDrawShow(playerid, TireWarn1[playerid]);
PlayerTextDrawShow(playerid, TireWarn2[playerid]);
PlayerTextDrawShow(playerid, TireWear[playerid]);
//}
}
if(oldstate == PLAYER_STATE_DRIVER)
{
stop VU[PlayInfo[playerid][InCar]];
PlayInfo[playerid][InCar] = 0;
PlayerTextDrawHide(playerid, SpeedoBack[playerid]);
PlayerTextDrawHide(playerid, Speedometer[playerid]);
PlayerTextDrawHide(playerid, TurnLeft[playerid]);
PlayerTextDrawHide(playerid, HeadLights[playerid]);
PlayerTextDrawHide(playerid, TurnRight[playerid]);
PlayerTextDrawHide(playerid, Kilometrage[playerid]);
PlayerTextDrawHide(playerid, FuelLevel[playerid]);
PlayerTextDrawHide(playerid, OilLevel[playerid]);
PlayerTextDrawHide(playerid, TireWear[playerid]);
PlayerTextDrawHide(playerid, FuelWarn1[playerid]);
PlayerTextDrawHide(playerid, FuelWarn2[playerid]);
PlayerTextDrawHide(playerid, OilWarn1[playerid]);
PlayerTextDrawHide(playerid, OilWarn2[playerid]);
PlayerTextDrawHide(playerid, TireWarn1[playerid]);
PlayerTextDrawHide(playerid, TireWarn2[playerid]);
}
return 1;
}