#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == \'\\0\') && (dcmd_%1(playerid, \"\"))) || (((%3)[(%2) + 1] == \' \') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
new Engine[MAX_VEHICLES];
forward EngineTimer(playerid);
public OnFilterScriptInit()
{
print(\"Engine System loaded.\");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#endif
public OnPlayerExitVehicle(playerid, vehicleid)
{
TogglePlayerControllable(playerid,1);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(Engine[vehicleid] == 0)
{
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, COLOR_YELLOW, \"Indításhoz, /motor\");
}
else if(Engine[vehicleid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, \"A motor már jár.\");
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
if(Engine[vehicleid] == 0)
{
if(newkeys & KEY_SECONDARY_ATTACK)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
}
else if(newkeys & KEY_JUMP)
{
SendClientMessage(playerid, COLOR_GREEN, \"Motor indítás.\");
SetTimerEx(\"EngineTimer\", 2000, 0, \"i\", playerid);
}
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(exitveh, 7, cmdtext);
dcmd(engine, 6, cmdtext);
return 0;
}
public EngineTimer(playerid)
{
new rand = random(2);
if(rand == 0)
{
SendClientMessage(playerid, COLOR_GREEN, \"A motor elindult.\");
SendClientMessage(playerid, COLOR_YELLOW, \"A leállításhoz, /motor\");
new vehicleid = GetPlayerVehicleID(playerid);
Engine[vehicleid] = 1;
TogglePlayerControllable(playerid, 1);
}
if(rand == 1)
{
SendClientMessage(playerid, COLOR_RED, \"Motor nem indult be.\");
SendClientMessage(playerid, COLOR_YELLOW, \"Próbáld újra!\");
}
}
dcmd_engine(playerid, params[])
{
#pragma unused params
new vehicleid = GetPlayerVehicleID(playerid);
if(Engine[vehicleid] == 0)
{
SendClientMessage(playerid, COLOR_GREEN, \"Motor indítás.\");
SetTimerEx(\"EngineTimer\", 2000, 0, \"i\", playerid);
}
else if(Engine[vehicleid] == 1)
{
Engine[vehicleid] = 0;
SendClientMessage(playerid, COLOR_RED, \"A motor leállt.\");
SendClientMessage(playerid, COLOR_YELLOW, \"Kiszálláshoz nyomd meg az Enter gombot.\");
SendClientMessage(playerid, COLOR_YELLOW, \"Indításhoz, /motor\");
TogglePlayerControllable(playerid,0);
}
return 1;
}
dcmd_exitveh(playerid, params[])
{
#pragma unused params
if(IsPlayerInAnyVehicle(playerid))
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
}
else
{
SendClientMessage(playerid, COLOR_RED, \"Nem ülsz jármüben!\");
}
return 1;
}