#Benjamin
Новичок
Если есть в автомобиль то показывается только playerid текстдравы а global невидно кроме того после того как выйти из авто таймер спидометра не прекращает свою работу хотя в чате показывается сообщение "#debug | oldstate == PLAYER_STATE_DRIVER true" а вот уже "#debug PlayerStateChange | delete TimerUpdateSpeed: " нет
PHP:
if(newstate == PLAYER_STATE_DRIVER)
{
if(!IsAPlane(newcar) && !BezBenzacar(newcar))
{
TimerUpdateSpeed[playerid] = SetTimerEx("UpdateSpeedometr", 200, true, "ii", playerid, GetPlayerVehicleID(playerid));
for(new i; i < sizeof(SPEED_TD); i++) TextDrawShowForPlayer(playerid, SPEED_TD[i]);
for(new i; i < sizeof(SPEED_PTD); i++)
{
PlayerTextDrawShow(playerid, SPEED_PTD[playerid][i]);
printf("SPEED_PTD: %d", i);
}
if(num_srv == srv_Test)
{
format(string_debug, 144, "#debug PlayerStateChange | TimerUpdateSpeed: %d", TimerUpdateSpeed[playerid]);
SendClientMessage(playerid, COLOR_RED, string_debug);
}
}
}
if(oldstate == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, COLOR_RED, "#debug | oldstate == PLAYER_STATE_DRIVER true");
for(new i; i < sizeof(SPEED_TD); i++) TextDrawHideForPlayer(playerid, SPEED_TD[i]);
for(new i; i < sizeof(SPEED_TD); i++) PlayerTextDrawHide(playerid, SPEED_PTD[playerid][i]);
KillTimer(TimerUpdateSpeed[playerid]);
TimerUpdateSpeed[playerid] = -1;
if(num_srv == srv_Test)
{
format(string_debug, 144, "#debug PlayerStateChange | delete TimerUpdateSpeed: %d", TimerUpdateSpeed[playerid]);
SendClientMessage(playerid, COLOR_RED, string_debug);
}
}
publics: UpdateSpeedometr(playerid, vehiceleID)
{
new fmt_string[32], Float:health;
GetVehicleHealth(vehiceleID, health);
format(string_debug, sizeof(string_debug), "#debug | UpdateSpeedometr | PlayerState: %d", GetPlayerState(playerid));
SendClientMessage(playerid, COLOR_RED, string_debug);
if(!Fuell[vehiceleID] || health <= 350) SetVehicleParamsEx(vehiceleID, 0, gLights, gAlarm, gDoors, gBonnet, gBoot, gObjective), cEngine{vehiceleID} = 0;
format(fmt_string, 32, "%s", VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
PlayerTextDrawSetString(playerid, SPEED_PTD[playerid][0], fmt_string);
format(fmt_string, 20, "%i", VehicleSpeed(vehiceleID));
PlayerTextDrawSetString(playerid, SPEED_PTD[playerid][1], fmt_string);
format(fmt_string, 20, "FUEL:_%iL", Fuell[vehiceleID]);
PlayerTextDrawSetString(playerid, SPEED_PTD[playerid][3], fmt_string);
format(fmt_string, 20, "%d_KM", 0);
PlayerTextDrawSetString(playerid, SPEED_PTD[playerid][4], fmt_string);
PlayerTextDrawTextSize(playerid, SPEED_PTD[playerid][5], Fuell[vehiceleID] * 0.25, 2.0000); // Прогресс бар кол-ва бензина
PlayerTextDrawShow(playerid, SPEED_PTD[playerid][5]);
PlayerTextDrawTextSize(playerid, SPEED_PTD[playerid][7], health / 10 * 0.22, 1.5000); // Прогресс бар кол-ва HP автомобиля
PlayerTextDrawShow(playerid, SPEED_PTD[playerid][7]);
PlayerTextDrawHide(playerid, SPEED_PTD[playerid][2]);
PlayerTextDrawColor(playerid, SPEED_PTD[playerid][2], (gEngine) ? (-16776961) : (16711935)); //engine
PlayerTextDrawShow(playerid, SPEED_PTD[playerid][2]);
PlayerTextDrawHide(playerid, SPEED_PTD[playerid][6]);
PlayerTextDrawColor(playerid, SPEED_PTD[playerid][6], (gDoors) ? (-16776961) : (16711935)); //doors
PlayerTextDrawShow(playerid, SPEED_PTD[playerid][6]);
return 1;
}
