OnPlayerEnterVehicle | Question - 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: OnPlayerEnterVehicle | Question (
/showthread.php?tid=526483)
OnPlayerEnterVehicle | Question -
Cole_William - 17.07.2014
I'm trying to make the vehicle only restrict users from entering if they're attempting to get in the driver seat BUT the script is stopping both driver and passenger...How can i make it only driver and allow passenger??
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i < 12; i++)
{
if(vehicleid == LSPDVehicles[i]) //If the vehicleid is an LSPD vehicle
{
if(PlayerInfo[playerid][pFaction] != 1)
{
ClearAnimations(playerid);
SendClientMessage(playerid, -1, "This vehicle is faction restricted.");
}
}
}
return 1;
}
Re: OnPlayerEnterVehicle | Question -
GeekSiMo - 17.07.2014
Use This !!!
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
Re: OnPlayerEnterVehicle | Question -
sammp - 17.07.2014
change
pawn Код:
if(PlayerInfo[playerid][pFaction] != 1)
to
pawn Код:
if(PlayerInfo[playerid][pFaction] != 1 && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
Re: OnPlayerEnterVehicle | Question -
Cole_William - 17.07.2014
I tried it like this
Код:
if(PlayerInfo[playerid][pFaction] != 1 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
ClearAnimations(playerid);
SendClientMessage(playerid, COLOR_GREY, "This vehicle is faction restricted.");
}
But it now allows passengers and drivers to enter.... Can you help me a bit more?
I tried both states
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
Re: OnPlayerEnterVehicle | Question -
Dignity - 17.07.2014
https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle
Quote:
This callback is called when a player BEGINS to enter a vehicle, not when they HAVE entered it. See OnPlayerStateChange.
|
Use this:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid = GetPlayerVehicleID(playerid);
switch(newstate)
{
case PLAYER_STATE_DRIVER:
{
for(new i = 0; i < 12; i++)
{
if(vehicleid == LSPDVehicles[i] && PlayerInfo[playerid][pFaction] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, -1, "This vehicle is faction restricted.");
break;
}
}
}
}
return true;
}