Кароче решил в enginescript добавить поломку авто но почемуто когда машина машина как обычно разбиваеться и взрываеться(( помогите
[pwn]
//*==========================================================================*//
//Скрипт замка зажигания
//*==========================================================================*//
#include <a_samp>
#define COLOR_RED 0xCC0000AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0x33FF00AA
#define COLOR_CYAN 0x33FFFFAA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_ORANGE 0xFFCC00AA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLACK 0x000000AA
#define COLOR_GREY 0xCCCCCCAA new engineOn[MAX_VEHICLES];
new vehicleEntered[MAX_PLAYERS][MAX_VEHICLES];
new isinvehicle[MAX_PLAYERS];
new engineenabled;
forward Startup(playerid, vehicleid);
forward VehicleCheck(playerid);
#define FILTERSCRIPT
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("[FS] ENGINE");
print("--------------------------------------\n");
return true;
}
public OnFilterScriptExit()
{
return true;
}
#else
main()
{
print("\n----------------------------------");
print("[FS] ENGINE");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
return true;
}
public OnGameModeExit()
{
return true;
}
public OnPlayerRequestClass(playerid, classid)
{
return true;
}
public OnPlayerRequestSpawn(playerid)
{
return true;
}
public OnPlayerConnect(playerid)
{
engineenabled = true;
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
return true;
}
public OnPlayerSpawn(playerid)
{
return true;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return true;
}
public OnPlayerEnterVehicle(playerid, vehicleid)
{
isinvehicle[playerid] = true;
return true;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
isinvehicle[playerid] = false;
return true;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(isinvehicle[playerid] && newkeys == KEY_JUMP)
{
engineOn[GetPlayerVehicleID(playerid)] = true;
}
return true;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new pveh = GetVehicleModel(GetPlayerVehicleID(playerid));
new vehicle = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER && (pveh == 522 || pveh == 581 || pveh == 462 || pveh == 521 || pveh == 463 || pveh == 461 || pveh == 448 || pveh == 471 || pveh == 468 || pveh == 586) && (pveh != 509 && pveh != 481 && pveh != 510))
{
SetTimerEx("Startup", 1, false, "ii", playerid, vehicle);
}
else if(newstate == PLAYER_STATE_DRIVER)
{
SetTimerEx("Startup", 1, false, "ii", playerid, vehicle);
}
return true;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
new Float:vehiclehp;
GetVehicleHealth(GetPlayerVehicleID(playerid), vehiclehp);
if(engineenabled)
{
if(!strcmp(cmd, "/on", true))
{
if(engineOn[GetPlayerVehicleID(playerid)]) return SendClientMessage(playerid, COLOR_RED, "*Пассажир не может запустить двигатель");
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_RED, "*Только водитель может сделать это!");
engineOn[GetPlayerVehicleID(playerid)] = true;
TogglePlayerControllable(playerid, true);
new playerveh = GetPlayerVehicleID(playerid);
PutPlayerInVehicle(playerid, playerveh, 0);
SendClientMessage(playerid, COLOR_GREEN, "*Двигатель запущен");
if(vehiclehp <= 300.0)
{
SendClientMessage(playerid, COLOR_RED, "*Двигатель не заводиться! Звони механику.");
engineOn[GetPlayerVehicleID(playerid)] = false;
}
return true;
}
if(!strcmp(cmd, "/off", true))
{
if(!engineOn[GetPlayerVehicleID(playerid)]) return SendClientMessage(playerid, COLOR_RED, "*Двигатель не запущен");
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_RED, "*Только водитель может сделать это!");
engineOn[GetPlayerVehicleID(playerid)] = false;
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "*Двигатель выключен");
return true;
}
}
return false;
}
public Startup(playerid, vehicleid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER || engineOn[vehicleid])
{
//I do nothing!
}
else if(!engineOn[vehicleid] && !vehicleEntered[playerid][vehicleid] && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, COLOR_YELLOW, "*Набери /on чтобы запустить двигатель, а чтобы заглушить /off");
TogglePlayerControllable(playerid, false);
vehicleEntered[playerid][vehicleid] = true;
}
else if(!engineOn[vehicleid] && vehicleEntered[playerid][vehicleid] && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, COLOR_YELLOW, "*Набери /on чтобы запустить двигатель, а чтобы заглушить /off");
TogglePlayerControllable(playerid, false);
}
}
strtok(const string[], &index, const seperator[] = " ")
{
new index2, result[30];
index2 = strfind(string, seperator, false, index);
if(index2 == -1)
{
if(strlen(string) > index)
{
strmid(result, string, index, strlen(string), 30);
index = strlen(string);
}
return result; // This string is empty, probably, if index came to an end
}
if(index2 > (index + 29))
{
index2 = index + 29;
strmid(result, string, index, index2, 30);
index = index2;
return result;
}
strmid(result, string, index, index2, 30);
index = index2 + 1;
return result;
}
public VehicleCheck(playerid)
{
if(IsPlayerConnected(playerid))
{
if(GetPlayerState(playerid) == 2)
{
new Float:vehiclehp;
GetVehicleHealth(GetPlayerVehicleID(playerid), vehiclehp);
if(vehiclehp <= 300.0)
{
SendClientMessage(playerid, COLOR_RED, "*Тачка рабита! звони механику.");
engineOn[GetPlayerVehicleID(playerid)] = false;
SetVehicleHealth(GetPlayerVehicleID(playerid),300);
}
}
}
return true;
}
[/pwn]