SA-MP Forums Archive
Block entering vehicle - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Block entering vehicle (/showthread.php?tid=242598)



Block entering vehicle - Ihsan-Cingisiz - 20.03.2011

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!


Re: Block entering vehicle - JamesC - 20.03.2011

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");
        }
    }
}



Re: Block entering vehicle - Jochemd - 20.03.2011

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


Re: Block entering vehicle - dice7 - 20.03.2011

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


Re: Block entering vehicle - Jochemd - 20.03.2011

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 :>