SA-MP Forums Archive
OnPlayerEnterVehicle faction check - 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 faction check (/showthread.php?tid=482020)



OnPlayerEnterVehicle faction check - Gecko75 - 18.12.2013

hi- I'm currently using OnPlayerenterVehicle, but this check I have, isn't working.
Код:
if(IsFactionVehicle(vehicleid) && PlayerInfo[playerid][pFac] != GetVehFaction(vehicleid))
	    {
			new car[128];
	        if(AdminDuty[playerid] == 1) return 1;
	        if(CarPerm[playerid] == 1) return 1;
    		new Float:pos[3];
		   	GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
	    	SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
	    	format(car,sizeof(car),"You can't enter this vehicle. (%s Vehicle)", FacInfo[GetVehFaction(vehicleid)][facDep]);
	    	SendClientMessage(playerid, COLOR_WHITE, car);
		}
It's set so if you're on aduty, it will let you in. But no matter what, if you're not in the faction, you can still enter it.
Can't understand why.

GetVehFaction code:
Код:
stock GetVehFaction(vehicleid)
{
	new faction;
	for(new i=0; i<MAX_FCARS; i++)
	{
	    for(new f=0; f<MAX_FACTIONS; f++)
		{
	    	if(vehicleid == FacInfo[f][fCars][i]) return 1;
	    	{
	    	    faction = f;
			}
		}
	}
	return faction;
}
IsFactionVehicle code:

Код:
stock IsFactionVehicle(vehicleid)
{
	for(new i=0; i<MAX_FCARS; i++)
	{
	    for(new f=0; f<MAX_FACTIONS; f++)
		{
	    	if(vehicleid == FacInfo[f][fCars][i]) return 1;
	        if(f == 0) return 0;
		}
	}
	return 0;
}



Re: OnPlayerEnterVehicle faction check - BlackWolf120 - 18.12.2013

Got a question: Does the whole check fail actually or is it simply possible to enter the vehicle?
Does the "Cant enter" message appear?


Re: OnPlayerEnterVehicle faction check - Gecko75 - 19.12.2013

The check fails, I guess. The return message doesn't pop up, and it just lets you in the car no matter what.