Help With Engine Please
#1

Quote:

if(newkeys == KEY_WALK)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerConnected(playerid))
{
new Vehicle = GetPlayerVehicleID(playerid);
if(VehicleStarted[Vehicle] == 1)
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s turns the engine off", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
printf("%s", string);
VehicleStarted[Vehicle] = 0;
TogglePlayerControllable(playerid,1);
RemovePlayerFromVehicle(playerid);
}else{
SendClientMessage(playerid,0xAFAFAFAA,"[!] The engine is already off!");
}
}
}
}
if(newkeys == KEY_WALK)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerConnected(playerid))
{
new Vehicle = GetPlayerVehicleID(playerid);
if(VehicleStarted[Vehicle] == 0)
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s tries to start the vehicle", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
printf("%s", string);
GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~ g~Starting vehicle...",3000,3);
SetTimerEx("Starting",3500,0,"i",playerid);
}else{
SendClientMessage(playerid,COLOR_GRAD2,"[!] This vehicle is already started!");
}
}
}
}
return 0;
}

Here Is My Engine Command It Should Turn On Engine With Tab if you press 1 time ant if you press second time it should turn off it but it dosent turn off Why and how can i fix this please help !
Reply
#2

You never set VehicleStarted[Vehicle] to 1
Reply
#3

i dont need it its a timerex
Quote:

SetTimerEx("Starting",3500,0,"i",playerid);

i think it does it at the same time i start the engine cuz it show engine altredy off too
Reply
#4

Anyone?
Reply
#5

Try this:

pawn Код:
if(newkeys == KEY_WALK)
{
  if(IsPlayerInAnyVehicle(playerid))
  {
    new Vehicle = GetPlayerVehicleID(playerid), name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(VehicleStarted[Vehicle] == 1)
    {
      format(string, sizeof(string), "* %s turns the engine off", name);
      ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
      print(string);
      VehicleStarted[Vehicle] = 0;
      TogglePlayerControllable(playerid,1);
      RemovePlayerFromVehicle(playerid);
    }
    else
    {
      format(string, sizeof(string), "* %s tries to start the vehicle", name);
      ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
      print(string);
      GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~g~Starting vehicle...",3000,3);
      SetTimerEx("Starting",3500,0,"i",playerid); //I hope you have 'VehicleStarted[Vehicle] = 1;' somewhere in this timer.
    }
  }
}
Reply
#6

Hmm the script is nice but i cant get it to work hope some one do
Reply
#7

In a loop, Check the EngineStarted or something like that, If it's false, Turn off the engine, and set the varieble to 0, If it's true turn if on and set the varieble to 1.
Reply
#8

I Tryed All This Help But Nothings Helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)