Stop car engine when it hasnt been started - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Stop car engine when it hasnt been started (
/showthread.php?tid=272325)
Stop car engine when it hasnt been started -
slymatt - 27.07.2011
The first time the car is used it shouldnt be started i have 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 when i enter the car it still automatically starts and /engine command does nothing =S
Re: Stop car engine when it hasnt been started -
Basicz - 27.07.2011
I think you need to use a variable. Like:
pawn Код:
new
vEngine[ MAX_VEHICLES ]
;
public OnGameModeInit( )
{
ManualVehicleEngineAndLights( );
return 1;
}
public OnVehicleSpawn( vehicleid )
{
vEngine[ vehicleid ] = 0;
return 1;
}
COMMAND:engine( playerid, params[ ] )
{
if ( !IsPlayerInAnyVehicle( playerid ) )
return SendClientMessage( playerid, -1, "You are not in any vehicle." );
new vid = GetPlayerVehicleID( playerid ), engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
switch( vEngine[ vid ] )
{
case 0: vEngine[ vid ] = 1, SetVehicleParamsEx( vid, 1, lights, alarm, doors, bonnet, boot, objective ), SendClientMessage( playerid, -1, "turned on" );
default: vEngine[ vid ] = 0, SetVehicleParamsEx( vid, 0, lights, alarm, doors, bonnet, boot, objective ),
SendClientMessage( playerid, -1, "turned off" );
}
return 1;
}
Hope it helps.
Re: Stop car engine when it hasnt been started -
slymatt - 27.07.2011
Cheer for that you helped alot. =P