Checking if engine is on or off -
Tom1412 - 16.09.2013
The problems is that all of a sudden the engine system anit checking.
I've place a send client message so i know when its checking the engine which it is then it just stops.
Any help?
pawn Код:
CMD:engine(playerid,params[])
{
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid, engine,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "checking if(engine");
if(engine == 0)
{
SetVehicleParamsEx(vehicleid, 1,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "You turned the key and the engine started.");
}
else if(engine == 1)
{
SetVehicleParamsEx(vehicleid, 0, lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "You turned the key and turned the engine off.");
}
}
else
{
SendClientMessage(playerid, -1, "You have to be the driver to start the engine.");
}
return 1;
}
Re: Checking if engine is on or off -
Isolated - 16.09.2013
What's wrong with that code?
Re: Checking if engine is on or off -
Tom1412 - 16.09.2013
NVM, Fixed it needed else after both engine checks to set the engine off and say it stalled. since sometiems the engine params wasnt set
Re: Checking if engine is on or off -
Isolated - 16.09.2013
You could use a switch, then cases.
pawn Код:
if(engine == 0)
// turns to
switch(engine)
{
case 0:
{
//code//
}
}
Re: Checking if engine is on or off -
Tom1412 - 16.09.2013
This is what i needed to have
pawn Код:
CMD:engine(playerid,params[])
{
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid, engine,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "checking if(engine");
if(engine == 0)
{
SetVehicleParamsEx(vehicleid, 1,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "You turned the key and the engine started.");
}
else if(engine == 1)
{
SetVehicleParamsEx(vehicleid, 0, lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "You turned the key and turned the engine off.");
}
else
{
SetVehicleParamsEx(vehicleid, 0, lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "You turned the key and the engine failed to start.");
}
}
else
{
SendClientMessage(playerid, -1, "You have to be the driver to start the engine.");
}
return 1;
}
Re: Checking if engine is on or off -
xganyx - 16.09.2013
here
pawn Код:
CMD:engine(playerid,params[])
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid, engine,lights,alarm,doors,bonnet,boot,objective);
switch(engine)
{
case 0:
{
SetVehicleParamsEx(vehicleid, 1,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "You turned the key and the engine started.");
}
case 1:
{
SetVehicleParamsEx(vehicleid, 0, lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "You turned the key and turned the engine off.");
}
}
}
else return SendClientMessage(playerid, -1, "You have to be the driver to start the engine.");
return 1;
}