SA-MP Forums Archive
Help plox - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help plox (/showthread.php?tid=162035)



Help plox - bartje01 - 22.07.2010

Hey guys.

I have a question.
Like when I do SetPlayerPos the player automaticly gets out of the vehicle. How to let him stay in the car?
Thanks


Re: Help plox - [L3th4l] - 22.07.2010

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
{
    SetPlayerPos(.....)
}
else
{
    SetPlayerPos(.....)
}



Re: Help plox - MisterTickle - 22.07.2010

If their in the driver seat I think you need to do RemovePlayerFromVehicle(playerid); but, I am unsure.


Re: Help plox - bartje01 - 22.07.2010

He must stay in the vehicle. So the vehicle and himself will both fly.


Re: Help plox - MisterTickle - 22.07.2010

Oh, So you wan't to make it so they can't exit the vehicle. Well you could make it so... You set a variable like "InFlight" and when they exit the vehicle if their "InFlight" == 1 it will PutPlayerInVehicle(playerid, vehicleid, 0);

0 = Driver Seat btw


Re: Help plox - bartje01 - 22.07.2010

Well i don't think I need that :P I just want that the player stays in the vehicle when I set his pos.


Re: Help plox - Kar - 22.07.2010

return 0. if id == in vehicle then return 0

wow .. L<.<@ mister


Re: Help plox - bartje01 - 22.07.2010

I'll try


Re: Help plox - MisterTickle - 22.07.2010

Quote:
Originally Posted by bartje01
Посмотреть сообщение
Well i don't think I need that :P I just want that the player stays in the vehicle when I set his pos.
Exactly, And that insures if they tried to exit it would put them right back. I believe.

Quote:
Originally Posted by Kar
Посмотреть сообщение
return 0. if id == in vehicle then return 0

wow .. L<.<@ mister
Don't be rude now. I was thinking of that but, I assumed that was outside of SAMP and when you press F it will make you exit the vehicle anyway and OnPlayerExitVehicle was just a public to check when you actually did.


Re: Help plox - Carlton - 22.07.2010

It takes a delay for users to exit the vehicle so you would have to start a timer and make them re-enter it.

pawn Код:
new MyVehicle[MAX_PLAYERS];

public OnPlayerStateChange(playerid, newstate, oldstate) {
     if(newstate == PLAYER_STATE_DRIVER) MyVehicle[playerid] = GetPlayerVehicleID(playerid);
     return 1;
}

public OnPlayerExitVehicle(playerid, vehicle) {
     // SendClientMessage(playerid, 0xFFFFFFFF, "You can't exit >:]");
     SetTimerEx("PlacePlayerBackInVehicle", 5000, 0, "i", playerid);
     return 1;
}

forward PlacePlayerBackInVehicle(playerid);
public PlacePlayerBackInVehicle(playerid) {
     PutPlayerInVehicle(playerid, MyVehicle[playerid], 0);
     return 1;
}
I just coded this at the spot, so if you find any bugs, post it.

Edit: There's no function to force a player to stay in the vehicle.