Problem with RemovePlayerFromVehicle -
-CaRRoT - 26.05.2012
Well.. I Don't know why.. I've Tried to fix it alot - But i don't get the Problem - RemovePlayerFromVehicle Doesn't work in my script AT ALL - I am using it alot but it don't work... Some Examples :
PHP код:
SendClientMessage(playerid, COLOR_GREY, "You have the maximum car limit!");
RemovePlayerFromVehicle(playerid);
PHP код:
SendClientMessage(playerid, COLOR_GREY, "You don't have enough money!");
RemovePlayerFromVehicle(playerid);
PHP код:
SendClientMessage(playerid, COLOR_GREY, " You don't know how to Drive yet, so you left the Car !");
RemovePlayerFromVehicle(playerid);
But.. none of them work.. Actually - I have more.. But still - None of them work -.-
Re: Problem with RemovePlayerFromVehicle -
newbienoob - 26.05.2012
It's not working for me too. I just use GetPlayerPos and SetPlayerPos. Example
pawn Код:
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid,x,y,z)
GetPlayerFacingAngle(playerid,a);
SetPlayerPos(playerid,x,y,z);
SetPlayerFacingAngle(playerid,a);
SendClientMessage(playerid,-1,"You can't enter this vehicle");
Re: Problem with RemovePlayerFromVehicle -
-CaRRoT - 26.05.2012
Mhm.. So.. It's a 0.3e Problem or what ?
Re: Problem with RemovePlayerFromVehicle -
iggy1 - 26.05.2012
It depends where you are putting that code. If your putting it in OnPlayerEnterVehicle it wont work. However if you put it in OnPlayerStateChange and check if the newstate is PLAYER_STATE_DRIVER then remove them from vehicle. That should work.
OnPlayerEnterVehicle is called before the player actually enters the vehicle. As soon as they press enter it's called.
Re: Problem with RemovePlayerFromVehicle -
-CaRRoT - 26.05.2012
Already put it under OnPlayerStateChange..
Here :
PHP код:
if(newstate == PLAYER_STATE_DRIVER)
{
new Float:V1X, Float:V1Y, Float:V1Z;
new newcar = GetPlayerVehicleID(playerid);
new Model = GetVehicleModel(newcar);
new oldcar = gLastCar[playerid];
if(IsABoat(newcar))
{
if(PlayerInfo[playerid][pBoatLic] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't know how to Sail yet, so you left the Boat !");
RemovePlayerFromVehicle(playerid);
}
}
else
{
if(PlayerInfo[playerid][pCarLic] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't know how to Drive yet, so you left the Car !");
RemovePlayerFromVehicle(playerid);
}
}
This is a Part of the Code..
Re: Problem with RemovePlayerFromVehicle -
iggy1 - 26.05.2012
Your getting the messages? It's just not exiting the vehicle?
Re: Problem with RemovePlayerFromVehicle -
-CaRRoT - 26.05.2012
Nope - Not getting the message and not exiting the car
Re: Problem with RemovePlayerFromVehicle -
newbienoob - 26.05.2012
pawn Код:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
//your codes...
Re: Problem with RemovePlayerFromVehicle -
iggy1 - 26.05.2012
It's a problem with your variables then, because RemovePlayerFromVehicle isn't even being executed. Print their values to make sure your doing it right. Put a load of prints there to see what gets executed and what doesn't.
Doesn't look like a problem with RemovePlayerFromVehicle.
EDIT: something like this.
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
print("player is driver");
new Float:V1X, Float:V1Y, Float:V1Z;
new newcar = GetPlayerVehicleID(playerid);
new Model = GetVehicleModel(newcar);
new oldcar = gLastCar[playerid];
if(IsABoat(newcar))
{
printf("vehicle is a boat PlayerInfo[playerid][pBoatLic] = %d", PlayerInfo[playerid][pBoatLic] );
if(PlayerInfo[playerid][pBoatLic] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't know how to Sail yet, so you left the Boat !");
RemovePlayerFromVehicle(playerid);
print("RemovePlayerFromVehicle executed (boat)");
}
}
else
{
printf("vehicle is not a boat PlayerInfo[playerid][pCarLic] = %d", PlayerInfo[playerid][pCarLic] );
if(PlayerInfo[playerid][pCarLic] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't know how to Drive yet, so you left the Car !");
RemovePlayerFromVehicle(playerid);
print("RemovePlayerFromVehicle executed (car)");
}
}
That should help narrow it down. It's a good idea to do this before posting for help because 99% of the time you will find the problem.