Help with Car controls -
slymatt - 27.07.2011
I dont understand how to work car controls i did
Код:
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
in a command /engine, when i enter the car the car's engine is already on, when i type /engine the car doesnt turn off or on =l
Re: Help with Car controls -
iPLEOMAX - 27.07.2011
pawn Код:
new vid, engine, lights, alarm, doors, bonnet, boot, objective;
vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
switch(engine)
{
case 0: { SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective); SendClientMessage(playerid, 0x00FF00FF, "Engine turned on!"); }
case 1: { SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective); SendClientMessage(playerid, 0xFF0000FF, "Engine turned off!"); }
}
//Note that 0 - off 1 - on.
Re: Help with Car controls -
slymatt - 27.07.2011
wouldnt that case just constantly switch the car on and off?
Re: Help with Car controls -
AndreT - 27.07.2011
Quote:
Originally Posted by slymatt
wouldnt that case just constantly switch the car on and off?
|
No.
But I'd suggest using a triadic statement here to make the code more simple.
pawn Код:
new vID = GetPlayerVehicleID(playerid),
engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, (engine ? 0 : 1), lights, alarm, doors, bonnet, boot, objective);
Re: Help with Car controls -
slymatt - 27.07.2011
So how would i actually pit that in to my command it looks like this:
Код:
CMD:engine(playerid,params[])
{
new vid, engine, lights, alarm, doors, bonnet, boot, objective;
vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
switch(engine)
{
case 0: { SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective); SendClientMessage(playerid, 0x00FF00FF, "Engine turned on!"); }
case 1: { SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective); SendClientMessage(playerid, 0xFF0000FF, "Engine turned off!"); }
}
return 1;
}
but that doesnt work
Re: Help with Car controls -
slymatt - 27.07.2011
the car is always started no matter what. =S