Problem with engine...
#1

I have epic problem: I want to make cars engine. Then player enter car and this car is started, he doesn't need to do anything, but if car doesn't started he need to push space to start the car and if he want to start off the car he need to push ctrl. all works fine but if player want to start off car and want to alight form car he can't do that because i use function: TogglePlayerControllable(playerid,0); Thereis my code:
Code:
#include <a_samp>

#define FILTERSCRIPT

#if defined FILTERSCRIPT

#define COLOR_GREEN 0x008000FF

#define COLOR_RED 0xFF0000FF

#define COLOR_YELLOW 0xFFFF00FF

new Engine[MAX_VEHICLES];
Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
           new vehicleid = GetPlayerVehicleID(playerid);
	   if(Engine[vehicleid] == 0)
	   {
           TogglePlayerControllable(playerid,0);
           SendClientMessage(playerid, COLOR_YELLOW, "If you want to start the car you need to push the SPACE button.");
	   }
	   else if(Engine[vehicleid] == 1)
	   {
          SendClientMessage(playerid, 0x99FF00AA, "If you want to off car you need to push Ctrl.");
	   }
	   return 1;
}
Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    TogglePlayerControllable(playerid,1);
	return 1;
}
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new vehicleid = GetPlayerVehicleID(playerid);
	if(IsPlayerInAnyVehicle(playerid))
	{
	   if(Engine[vehicleid] == 0)
	   {
		  if(newkeys & KEY_SPRINT)
		  {
             TogglePlayerControllable(playerid, 1);
             SendClientMessage(playerid, COLOR_GREEN, "Uћvedei variklį.");
             SendClientMessage(playerid, 0x99FF00AA, "Norėdamas uћgesinti variklį spausk Ctrl mygtuką.");
             Engine[vehicleid] = 1;
		  }
	   }
	   if(Engine[vehicleid] == 1)
	   {
		  if(newkeys & KEY_ACTION)
		  {
             TogglePlayerControllable(playerid, 0);
             Engine[vehicleid] = 0;
             SendClientMessage(playerid, 0xBFC0C2FF, "Uћgesinai variklį.");
		  }
	   }
	}
	return 1;
}
Please help me and I will be very grateful
Reply
#2

You will have to create one of the two:
1. Create another check that checks if the player has pressed the ENTER or F key (to enter/exit the vehicle)
2. create a command that throws the player out the car (/exit -> RemovePlayerFromVehicle(playerid))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)