OnPlayerEnterVehicle faction check
#1

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;
}
Reply
#2

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)