хз не тестил:
[pwn]#include <a_samp> forward VehicleCheck(playerid);
new VehicleWarmings[][64] =
{
"Отпал инжектор",
"Пробит радиатор",
"Раскрошилась шаровая",
"Заклинило рулевое",
"Лопнул аккомулятор"
};
new VehicleControllable[700];
new VehicleCheckTimer[200];
public OnFilterScriptInit()
{
for(new vehicleid;vehicleid < 700; vehicleid++)
{
VehicleControllable[vehicleid] = 255;
}
return 1;
}
public OnPlayerConnect(playerid)
{
VehicleCheckTimer[playerid] = 255;
return 1;
}
public VehicleCheck(playerid)
{
if(IsPlayerConnected(playerid))
{
if(GetPlayerState(playerid) == 2)
{
new Float:vehiclehp;
GetVehicleHealth(GetPlayerVehicleID(playerid), vehiclehp);
if(vehiclehp <= 300.0)
{
TogglePlayerControllable(playerid, false);
VehicleControllable[GetPlayerVehicleID(playerid)] = random(sizeof(VehicleWarmings));
}
}
}
return true;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerConnected(playerid))
{
if(GetPlayerState(playerid) == 2)
{
if(VehicleControllable[GetPlayerVehicleID(playerid)] != 255)
{
if(newkeys == KEY_SECONDARY_ATTACK)
{
RemovePlayerFromVehicle(playerid);
}
else if(newkeys != 1 && newkeys != 2)
{
new string[256];
format(string,sizeof(string)," Ты никуда не уедешь на этой тачке, %s.",VehicleWarmings[VehicleControllable[GetPlayerVehicleID(playerid)]]);
SendClientMessage(playerid, 0xFF0000FF, string);
}
}
}
}
return true;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(VehicleControllable[vehicleid] != 255)
{
new string[256];
format(string,sizeof(string)," Ты никуда не уедешь на этой тачке, %s.",VehicleWarmings[VehicleControllable[GetPlayerVehicleID(playerid)]]);
SendClientMessage(playerid, 0xFF0000FF, string);
}
VehicleCheckTimer[playerid] = SetTimerEx("VehicleCheck",200,1,"d",playerid);
return true;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(VehicleCheckTimer[playerid] != 255)
{
KillTimer(VehicleCheckTimer[playerid]);
TogglePlayerControllable(playerid, true);
VehicleCheckTimer[playerid] = 255;
}
return true;
}
public OnVehicleSpawn(vehicleid)
{
if(VehicleControllable[vehicleid] != 255)
{
VehicleControllable[vehicleid] = 255;
}
return true;
}[/pwn]