Block entering vehicle
#1

Hello,

I tried eveything to get the player away from a cop car
if they are not a LEO. I made this to test it out but it didn't
worked:
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
 if(vehicleid == 596)
	{
		if(PlayerInfo[playerid][pFaction] != 1)
		{
		    new Float:X, Float:Y, Float:Z;
		    GetPlayerPos(playerid, X, Y, Z);
		    SetPlayerPos(playerid, X, Y, Z);
		    SendClientMessage(playerid, COLOR_GREY, "YOU DONT HAVE THE KEYS");
		}
	}
	return 1;
}
but it doesn't wokr, how to do this on the right wy?

thank!
Reply
#2

596 is the modelid not the vehicleid.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 596) // If the model of the vehicleid is 596 (LA police)
    {
        if(PlayerInfo[playerid][pFaction] != 1)
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid, X, Y, Z);
            SetPlayerPos(playerid, X, Y, Z);
            SendClientMessage(playerid, COLOR_GREY, "YOU DONT HAVE THE KEYS");
        }
    }
}
Reply
#3

I'm unsure, but you could try to use "TogglePlayerControllable(playerid, 1);" after you gave him the message
Reply
#4

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
I'm unsure, but you could try to use "TogglePlayerControllable(playerid, 1);" after you gave him the message
That will freeze him. Instead of setting his pos, you can just use ClearAnimations() to prevent him entering the vehicle, since OnPlayerEnterVehicle is called when the player presses the ENTER key and is not yet in the vehicle
Reply
#5

Quote:
Originally Posted by dice7
Посмотреть сообщение
That will freeze him. Instead of setting his pos, you can just use ClearAnimations() to prevent him entering the vehicle, since OnPlayerEnterVehicle is called when the player presses the ENTER key and is not yet in the vehicle
It won't freeze him, since it would be set to 1. But I was unsure, I have never used it. Now I know it though, thanks :>
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)