Removeplayerfromvehicle not working
#1

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;
}
Reply
#2

pawn Код:
for(new idx=1;
Do you know how loops work ?
Reply
#3

yes i do. that's not my concern. i'm trying to remove the player from the vehicle
Reply
#4

Quote:
Originally Posted by jeffery30162
Посмотреть сообщение
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?
Reply
#5

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.
Reply
#6

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.
Reply
#7

ClearAnimations(playerid); worked perfectly


thank you
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)