PDA

View Full Version : Removeplayerfromvehicle not working


jeffery30162
21/03/2014, 03:09 AM
Removeplayerfromvehicle is not working. here is my code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new name[128];
GetPlayerName(playerid, name, sizeof(name));
for(new idx=1; idx<MAX_CAR; idx++)
{
if(vehicleid == CarInfo[idx][cVID] && CarInfo[idx][cStatus] == 1)
{
if(strcmp(CarInfo[idx][cOwner], name, false) != 0)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "YOU DO NOT OWN THIS CAR");
}
}
else
{
if(CarInfo[idx][cStatus] == 2)
{
SendClientMessage(playerid, COLOR_RED, "THIS CAR IS FOR SALE");
RemovePlayerFromVehicle(playerid);
}
}
}
return 1;
}

Unte99
21/03/2014, 03:18 AM
for(new idx=1;


Do you know how loops work ?

jeffery30162
21/03/2014, 03:19 AM
yes i do. that's not my concern. i'm trying to remove the player from the vehicle

Unte99
21/03/2014, 03:35 AM
yes i do. that's not my concern. i'm trying to remove the player from the vehicle

Why did you edit the post, when at first you said you don't know how the loop works? You are just trying to get the code from people?

jeffery30162
21/03/2014, 04:03 AM
is there a problem? there's a help section for a reason, if you don't like it.. do us all a favor and remove your ethernet cable from your pc.

iggy1
21/03/2014, 04:10 AM
OnPlayerEnterVehicle is called as soon as you press enter, not when you are in a vehicle.

So the player isn't actually in the vehicle when you call RemovePlayerFromVehicle.

Try using OnPlayerStateChange - which is called when the players state actually changes eg, from on foot to driving.

EDIT: I'm not actually sure (can't test) but in your code clearing animations instead of RemovePlayerFromVehicle might prevent the player from entering. This is purely a guess and might not work.

There's also SetVehicleParamsForPlayer for locking vehicle doors.

jeffery30162
21/03/2014, 02:59 PM
ClearAnimations(playerid); worked perfectly


thank you