Removeplayerfromvehicle not working - 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)
+--- Thread: Removeplayerfromvehicle not working (
/showthread.php?tid=501903)
Removeplayerfromvehicle not working -
jeffery30162 - 21.03.2014
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;
}
Re: Removeplayerfromvehicle not working -
Unte99 - 21.03.2014
Do you know how loops work ?
Re: Removeplayerfromvehicle not working -
jeffery30162 - 21.03.2014
yes i do. that's not my concern. i'm trying to remove the player from the vehicle
Re: Removeplayerfromvehicle not working -
Unte99 - 21.03.2014
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?
Re: Removeplayerfromvehicle not working -
jeffery30162 - 21.03.2014
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.
Re: Removeplayerfromvehicle not working -
iggy1 - 21.03.2014
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.
Re: Removeplayerfromvehicle not working -
jeffery30162 - 21.03.2014
ClearAnimations(playerid); worked perfectly
thank you