Try making the command without "else return" and just use "else" it might work. I'm not %100 sure it will help but it might well do. like this,
pawn Код:
dcmd_engine(playerid,params[])
{
#pragma unused params
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) != 481 && GetVehicleModel(vehicleid) != 509 && GetVehicleModel(vehicleid) != 510)
{
if(VehicleInfo[vehicleid][EngineRunning] == 0)
{
if(VehicleInfo[vehicleid][Fuel] > 0)
{
if(PlayerInfo[playerid][IsInUnboughtCar] == 0)
{
new rand = random(7);
if(rand == 0)
{
SendClientMessage(playerid,COLOR_WHITE,"* Engine didn't start, try again.");
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s puts a key into the ignition, twists it around but the engine didn't start.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
else if(rand == 1)
{
SendClientMessage(playerid,COLOR_WHITE,"* The engine has been started.");
VehicleInfo[vehicleid][EngineRunning] = 1;
TogglePlayerControllable(playerid,1);
PlayerPlaySound(playerid,1133,0,0,0);
VehicleInfo[vehicleid][FuelTimer] = SetTimerEx("FuelLower",40000,true,"i",playerid);
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s puts a key into the ignition, twists it around and the engine starts.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
else if(rand == 2)
{
SendClientMessage(playerid,COLOR_WHITE,"* The engine has been started.");
VehicleInfo[vehicleid][EngineRunning] = 1;
TogglePlayerControllable(playerid,1);
PlayerPlaySound(playerid,1133,0,0,0);
VehicleInfo[vehicleid][FuelTimer] = SetTimerEx("FuelLower",40000,true,"i",playerid);
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s puts a key into the ignition, twists it around and the engine starts.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
else if(rand == 3)
{
SendClientMessage(playerid,COLOR_WHITE,"* The engine has been started.");
VehicleInfo[vehicleid][EngineRunning] = 1;
TogglePlayerControllable(playerid,1);
PlayerPlaySound(playerid,1133,0,0,0);
VehicleInfo[vehicleid][FuelTimer] = SetTimerEx("FuelLower",40000,true,"i",playerid);
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s puts a key into the ignition, twists it around and the engine starts.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
else if(rand == 4)
{
SendClientMessage(playerid,COLOR_WHITE,"* The engine has been started.");
VehicleInfo[vehicleid][EngineRunning] = 1;
TogglePlayerControllable(playerid,1);
PlayerPlaySound(playerid,1133,0,0,0);
VehicleInfo[vehicleid][FuelTimer] = SetTimerEx("FuelLower",40000,true,"i",playerid);
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s puts a key into the ignition, twists it around and the engine starts.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
else if(rand == 5)
{
SendClientMessage(playerid,COLOR_WHITE,"* The engine has been started.");
VehicleInfo[vehicleid][EngineRunning] = 1;
TogglePlayerControllable(playerid,1);
PlayerPlaySound(playerid,1133,0,0,0);
VehicleInfo[vehicleid][FuelTimer] = SetTimerEx("FuelLower",40000,true,"i",playerid);
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s puts a key into the ignition, twists it around and the engine starts.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
else if(rand == 6)
{
SendClientMessage(playerid,COLOR_WHITE,"* The engine has been started.");
VehicleInfo[vehicleid][EngineRunning] = 1;
TogglePlayerControllable(playerid,1);
PlayerPlaySound(playerid,1133,0,0,0);
VehicleInfo[vehicleid][FuelTimer] = SetTimerEx("FuelLower",40000,true,"i",playerid);
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s puts a key into the ignition, twists it around and the engine starts.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
}
}
else SendClientMessage(playerid,COLOR_WHITE,"* The engine didn't start because the vehicle is out of fuel.");
}
else if(VehicleInfo[vehicleid][EngineRunning] == 1)
{
SendClientMessage(playerid,COLOR_WHITE,"* Engine stopped.");
TogglePlayerControllable(playerid,0);
KillTimer(VehicleInfo[vehicleid][FuelTimer]);
VehicleInfo[vehicleid][EngineRunning] = 0;
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
foreach(Player,i)
{
if(IsPlayerInRangeOfPoint(i,5,PosX,PosY,PosZ))
{
new string[128],Playername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s twists the key in the ignition and stops the engine.",Playername);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
}
else SendClientMessage(playerid,COLOR_RED,"* This vehicle doesn't have an engine.");
}
else SendClientMessage(playerid,COLOR_RED,"* You are not in a vehicle.");
return 1;
}