Keep a player in a vehicle [rep++]
#7

Thanks much for your replies, guys.

I have figured out a way to do this that is as close to what I want as possible. As Pottus stated, there is no clean, direct way to do this (correct me if I'm wrong, and I wish I was). However I found another technicality that allows me to stop the player getting out of their vehicle.

When the player gets out of the vehicle, as far as the game is concerned, it plays an animation. All I have to do is use the clear animations function, which stops the leave vehicle animation from playing, and then put the player back in the vehicle. This is not seamless, it will cause the player's camera position to be reset (to directly behind the vehicle), but the player will not appear to leave the vehicle, and in theory, the other clients that are streamed in shouldn't notice anything, but I haven't tested that yet.

The solution code:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK &&
        PlayerIsArrested[playerid]){
        ClearAnimations(playerid, 1);
        PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), GetPlayerVehicleSeat(playerid));
    return 1;
}
All this does is stops the animation from being played by the clients, and puts the player back in the vehicle when they try to get out. If there is an even better way to do this (which I doubt there would be), I will happily let you inform me, but for now, I think this will be good enough.

Again, I would give rep to Pottus, as his reply was the most helpful, however I already did that for something else, and the forum won't let me do it again
Reply


Messages In This Thread
Keep a player in a vehicle [rep++] - by EnforcerDon - 21.10.2014, 04:16
Re: Keep a player in a vehicle [rep++] - by DaTa[X] - 21.10.2014, 04:20
Re: Keep a player in a vehicle [rep++] - by EnforcerDon - 21.10.2014, 04:25
Re: Keep a player in a vehicle [rep++] - by Pottus - 21.10.2014, 04:31
Re: Keep a player in a vehicle [rep++] - by Steel_ - 21.10.2014, 08:42
Re: Keep a player in a vehicle [rep++] - by Pottus - 21.10.2014, 08:46
Re: Keep a player in a vehicle [rep++] - by EnforcerDon - 21.10.2014, 11:32

Forum Jump:


Users browsing this thread: 1 Guest(s)