Help with Car controls
#1

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
Reply
#2

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.
Reply
#3

wouldnt that case just constantly switch the car on and off?
Reply
#4

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);
Reply
#5

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
Reply
#6

the car is always started no matter what. =S
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)