Vehicles States?
#1

hi... again... xD, im trying to make an engine on off command for vehicles and i'd like to know if theres a way to make some states (like ON OFF) to set to each vehicle.....
Reply
#2

Sure.

pawn Код:
new bool:EngineRunning[MAX_VEHICLES];
new OldVehicle[MAX_PLAYERS];

public OnPlayerStateChange(playerid,newstate,oldstate)
{
   if(newstate == 2)
   {
     new vehi = GetPlayerVehicleID(playerid);
     OldVehicle[playerid] = vehi;
     EngineRunning[vehi] = true;
   }
   if(newstate == 1 && oldstate == 2)
   {
     EngineRunning[OldVehicle[playerid]] = false;
   }
   return 1;
}
I don't think GetPlayerVehicleID will work when his new state equals on foot so I made a variable to store his last vehicle. That should work though. Edit: I think you mean to turn vehicles on and off. This will just store if someone is in it. Shit...
Reply
#3

yea i mean to turn the engine on of... but i thinkg that code gave me the solution ^^... I didn't knew how to put certains "states" to the vehicles and you just gave me the idea.... thx....
Reply
#4

pawn Код:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
  if ( newstate == PLAYER_STATE_DRIVER ) TogglePlayerControllable( playerid, false );
  return 1;
}

//wherever you want to start it, say a keypress or a command
TogglePlayerControllable( playerid, true );
This will freeze the player every time he gets in a vehicle as the driver until you fire the command or the keypress which you want to start the vehicle again. There is no need to use variables or whatever here IMO as you use the state like you would the variable anyway.

Ofcourse this may conflict somewhere due to commands and features I don't know about (your script) but a quick fix could be made I'm sure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)