new EngineRandom[][] =
{
{"* Engine started.", 1 },
{"* Engine start failed.", 0 }
};
dcmd_engine(playerid,params[])
{
#pragma unused params
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(PlayerInfo[vehicleid][EngineRunning] == 0)
{
new rand = random(sizeof(EngineRandom));
SendClientMessage(playerid,COLOR_WHITE,EngineRandom[rand][0]);
PlayerInfo[vehicleid][EngineRunning] = EngineRandom[rand][1];
TogglePlayerControllable(playerid,0);
}
else if(PlayerInfo[vehicleid][EngineRunning] == 1)
{
SendClientMessage(playerid,COLOR_WHITE,"* Engine stopped.");
TogglePlayerControllable(playerid,0);
PlayerInfo[vehicleid][EngineRunning] = 0;
}
}
else return SendClientMessage(playerid,COLOR_RED,"* You are not in a vehicle.");
return 1;
}
PlayerInfo[vehicleid][EngineRunning]
dcmd_engine(playerid,params[])
{
#pragma unused params
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(PlayerInfo[vehicleid][EngineRunning] == 0)
{
new rand = random(sizeof(EngineRandom));
SendClientMessage(playerid,COLOR_WHITE,EngineRandom[rand][0]);
PlayerInfo[vehicleid][EngineRunning] = EngineRandom[rand][1];
TogglePlayerControllable(playerid,1); // <--- This was 0 (aka, false or frozen)
}
else if(PlayerInfo[vehicleid][EngineRunning] == 1)
{
SendClientMessage(playerid,COLOR_WHITE,"* Engine stopped.");
TogglePlayerControllable(playerid,0);
PlayerInfo[vehicleid][EngineRunning] = 0;
}
}
else return SendClientMessage(playerid,COLOR_RED,"* You are not in a vehicle.");
return 1;
}
Ok that is fixed.. but now, when the engine is running, and I type /engine again it doesnt turn off. What could that be? It doesnt even give a message. Maybe the variable is set wrong?
|
dcmd_engine(playerid, params[])
{
#pragma unused params
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(PlayerInfo[vehicleid][EngineRunning] == 0)
{
if(random(2) == random(2)) //just out of fun
return SendClientMessage(playerid, COLOR_WHITE, "* Engine start failed.");
SendClientMessage(playerid, COLOR_WHITE, "* Engine started.");
PlayerInfo[vehicleid][EngineRunning] = true;
TogglePlayerControllable(playerid, true);
} else {
SendClientMessage(playerid, COLOR_WHITE, "* Engine stopped.");
PlayerInfo[vehicleid][EngineRunning] = false;
TogglePlayerControllable(playerid, false);
}
return 1;
}
return SendClientMessage(playerid,COLOR_RED,"* You are not in a vehicle.");
}