Freezed when jacked
#1

Okay so i have a vehicle engine system, I got everything done, but all i need is some sort of function.
When a player gets in the vehicle and doesn't turn on engine, it freezes him, as in every engine script.
BUT, when he gets jacked it still freezes him.
Both when jacked in front and from passenger seat.
I tried doing something with OnPlayerExitVehicle but that only works when he isn't jacked.
So anyone could help me with adding some sort of function when a player gets jacked it unfreezes him.
I tried everything but no.

Thanks in advance.
Reply
#2

Well, you could just check if the played is meant to be in the car. If not unfreeze him.
Reply
#3

Quote:
Originally Posted by [HiC
TheKiller ]
Well, you could just check if the played is meant to be in the car. If not unfreeze him.
You don't understand, I am using OnPlayerStateChange, Player gets inside the car, It freezes him untill he presses CTRL.
And you can only start engine if your in a car, so i don't have any problem of that.
But, You get jacked before you turn on engine, and you are freezed.
Is there any callback/custom callback referring to car jacking?
Something like this?
pawn Код:
public OnPlayerJacked(playerid, jacked, jacker)
{
    return 1;
}
Reply
#4

Quote:
Originally Posted by Blades
Quote:
Originally Posted by [HiC
TheKiller ]
Well, you could just check if the played is meant to be in the car. If not unfreeze him.
You don't understand, I am using OnPlayerStateChange, Player gets inside the car, It freezes him untill he presses CTRL.
And you can only start engine if your in a car, so i don't have any problem of that.
But, You get jacked before you turn on engine, and you are freezed.
Is there any callback/custom callback referring to car jacking?
Something like this?
pawn Код:
public OnPlayerJacked(playerid, jacked, jacker)
{
    return 1;
}
I do get what you are saying. When the state changes to the driver and you freeze the person, set a variable E.g.
Код:
InCar[playerid] = 1;
Then make a timer and Check if the player is in the vehicle with the variable:

pawn Код:
public AntiFreeze()
{
  for(new i=0;i<GetMaxPlayers();i++)
  {
    if(!IsPlayerInAnyVehicle(playerid)) && InCar[i] == 1)
    {
      TogglePlayerControllable(i, false);
      InCar[i] = 0;
    }
   }
   return 1;
}
Also when the player Exits the car use InCar[playerid] = 0;
Reply
#5

Why use extra code, when you don't really need it. Try this OnPlayerStateChange().

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2 && oldstate == 1)
    {
        // The old state was on foot, now checking if they're changing their state to driving a vehicle.
        TogglePlayerControllable(playerid, true);
    {
    return 1;
}
Reply
#6

Quote:
Originally Posted by Calgon
Why use extra code, when you don't really need it. Try this OnPlayerStateChange().

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2 && oldstate == 1)
    {
        // The old state was on foot, now checking if they're changing their state to driving a vehicle.
        TogglePlayerControllable(playerid, true);
    {
    return 1;
}
Doesn't work, i wanted it to check if he is jacked, it toggles controllable to true.
So i tried putting if(newstate == 1 && oldstate == 2) so it will check if you were in a car and now on foot it sets controllable to 1.
But it doesn't work if your jacked from front or front back seat(passenger).

Please help me out, since i tried lots and lots of stuff like timers and tried to modify your code but nothing.

Reply
#7

Nvm -_-
Reply
#8

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    TogglePlayerControllable(playerid,0);
    return 1;
}
Try that.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)