SA-MP Forums Archive
[help] car /engine - 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: [help] car /engine (/showthread.php?tid=65969)



[help] car /engine - tony_fitto - 18.02.2009

Hey all scripters i have a question is there some one as know how i can do to turn of the engine on the cars ? help plzz


Re: [help] car /engine - Mikep - 18.02.2009

Firstly, plzz isn't a word.

Secondly, you can't.


Re: [help] car /engine - Toxicity - 18.02.2009

As Mikep said you can't but an alternative is to freeze the player if the engine is off:

Код:
new engine[700]; //number of cars in the server (700 is maximum number of cars)
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmd, "/engine", true) == 0)//when they type /engine do this:
	{
		if (IsPlayerInAnyVehicle(playerid))//check if they are in a car
		{
			new vehicleId = GetPlayerVehicleID(playerid);//get the ID of the car the player is in
			if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)//if the player is not the driver
			{
				return SendClientMessage(playerid, , "You can't start/stop the engine, you're not the driver!");
			}
			if (engine[vehicleId] == 1)//if the car is on
			{
				engine[vehicleId] = 0;//set the car as off
				TogglePlayerControllable(playerid, 0);//set the player to be unable move
			}
			else if (engine[carid] == 0)//if the car is off
			{
				engine[vehicleId] = 1;//set the car as on
				TogglePlayerControllable(playerid, 1);//set the player to be able to move
			}
			return 1;
		}
	}
}
I don't know if this will work or not, try it.

PS: 0.o My first post on the sa-mp forums.
PPS: "plzz" is not a word. If I wasn't trying to beat Daren, I wouldn't have helped you. Use English in the future.


Re: [help] car /engine - DX[Boss] - 18.02.2009

Where should i Paste it?


Re: [help] car /engine - Toxicity - 19.02.2009

Код:
new engine[700]; //number of cars in the server (700 is maximum number of cars)
Put this after your #includes and #defines.

Код:
	if(strcmp(cmd, "/engine", true) == 0)//when they type /engine do this:
	{
		if (IsPlayerInAnyVehicle(playerid))//check if they are in a car
		{
			new vehicleId = GetPlayerVehicleID(playerid);//get the ID of the car the player is in
			if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)//if the player is not the driver
			{
				return SendClientMessage(playerid, , "You can't start/stop the engine, you're not the driver!");
			}
			if (engine[vehicleId] == 1)//if the car is on
			{
				engine[vehicleId] = 0;//set the car as off
				TogglePlayerControllable(playerid, 0);//set the player to be unable move
			}
			else if (engine[carid] == 0)//if the car is off
			{
				engine[vehicleId] = 1;//set the car as on
				TogglePlayerControllable(playerid, 1);//set the player to be able to move
			}
			return 1;
		}
	}
Put this inside the braquets for OnPlayerCommandText.