Whats wrong? (Faction vehicles)
#1

Hello! I'have a problem with faction vehicles.
Faction id 1 members can drive all factions car,
and factions id higher than 1 can't drive their cars.

Pawno dont get error, and i dont see errors too. Please help!

Heres the code:


Sorry for bad english...

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(vehicleid == POLICE_VEHICLE[0]||POLICE_VEHICLE[1]||POLICE_VEHICLE[2]||POLICE_VEHICLE[3]||POLICE_VEHICLE[4]||POLICE_VEHICLE[5]\
	||POLICE_VEHICLE[6]||POLICE_VEHICLE[7]||POLICE_VEHICLE[8]||POLICE_VEHICLE[9]||POLICE_VEHICLE[10]||POLICE_VEHICLE[11])
   	{
	    if(PlayerInfo[playerid][szervezet] != 1) // Itt leellenцrzцd, hogy a jбtйkos tagja-e egy frakciуnak
       	{
         	ClearAnimations(playerid);
      	}
   	}
   	else if(vehicleid == MEDIC_VEHICLE[0]||MEDIC_VEHICLE[1]||MEDIC_VEHICLE[2]||MEDIC_VEHICLE[3])
   	{
	    if(PlayerInfo[playerid][szervezet] != 2) // Itt leellenцrzцd, hogy a jбtйkos tagja-e egy frakciуnak
       	{
         	ClearAnimations(playerid);
      	}
   	}
   	else if(vehicleid == REPORTER_VEHICLE[0]||REPORTER_VEHICLE[1]||REPORTER_VEHICLE[2]||REPORTER_VEHICLE[3]||REPORTER_VEHICLE[4])
   	{
	    if(PlayerInfo[playerid][szervezet] != 3) // Itt leellenцrzцd, hogy a jбtйkos tagja-e egy frakciуnak
       	{
         	ClearAnimations(playerid);
      	}
   	}
   	else if(vehicleid == CIA_VEHICLE[0]||CIA_VEHICLE[1]||CIA_VEHICLE[2]||CIA_VEHICLE[3]||CIA_VEHICLE[4]||CIA_VEHICLE[5]||CIA_VEHICLE[6])
   	{
	    if(PlayerInfo[playerid][szervezet] != 4) // Itt leellenцrzцd, hogy a jбtйkos tagja-e egy frakciуnak
       	{
         	ClearAnimations(playerid);
      	}
   	}
   	else if(vehicleid == GS_VEHICLE[0]||GS_VEHICLE[1]||GS_VEHICLE[2])
   	{
	    if(PlayerInfo[playerid][szervezet] != 5) // Itt leellenцrzцd, hogy a jбtйkos tagja-e egy frakciуnak
       	{
         	ClearAnimations(playerid);
      	}
   	}
   	else if(vehicleid == MAFFIA_VEHICLE[0]||MAFFIA_VEHICLE[1]||MAFFIA_VEHICLE[2]||MAFFIA_VEHICLE[3]||MAFFIA_VEHICLE[4]||MAFFIA_VEHICLE[5])
   	{
	    if(PlayerInfo[playerid][szervezet] != 6) // Itt leellenцrzцd, hogy a jбtйkos tagja-e egy frakciуnak
       	{
         	ClearAnimations(playerid);
      	}
   	}
   	else if(vehicleid == GOV_VEHICLE[0])
   	{
	    if(PlayerInfo[playerid][szervezet] != 7) // Itt leellenцrzцd, hogy a jбtйkos tagja-e egy frakciуnak
       	{
         	ClearAnimations(playerid);
      	}
   	}
   	return 1;
}
Reply
#2

Why do you have != #? This is checking to see if the faction is NOT the number you use. So for the police, for example, everyone except people in faction 1 can drive them. I think you mean to use ==.
Reply
#3

If u want to do more then 1 don't use == u have to use
>1 that means everything more then 1
Reply
#4

== means EXACTLY
!= means IS NOT
>= means EXACTLY OR HIGHER
<= means EXACTLY OR LOWER
> MEANS HIGHER
< MEANS LOWER

if(PlayerInfo[playerid][szervezet] != 3) means NOT 3 (all other numbers)
if(PlayerInfo[playerid][szervezet] == 3) means EXACTLY 3
if(PlayerInfo[playerid][szervezet] >= 3) means 3 or higher
if(PlayerInfo[playerid][szervezet] <= 3) means 3 or lower
if(PlayerInfo[playerid][szervezet] > 3) means only higher then 3
if(PlayerInfo[playerid][szervezet] < 3) means only lower then 3
Reply
#5

I know, but:


pawn Код:
if(vehicleid == POLICE_VEHICLE[0]||POLICE_VEHICLE[1]||POLICE_VEHICLE[2]||POLICE_VEHICLE[3]||POLICE_VEHICLE[4]||POLICE_VEHICLE[5]\
    ||POLICE_VEHICLE[6]||POLICE_VEHICLE[7]||POLICE_VEHICLE[8]||POLICE_VEHICLE[9]||POLICE_VEHICLE[10]||POLICE_VEHICLE[11])
    {
        if(PlayerInfo[playerid][szervezet] != 1) // That means if the player isn't in faction 1, right?
        {
            ClearAnimations(playerid);// If the player isnt in faction id 1, can't enter to the car
        }
    }
Reply
#6

I think your if statement needs to be like this:
pawn Код:
if(vehicleid == POLICE_VEHICLE[0] || vehicleid == POLICE_VEHICLE[1]...)
basically you need to have "vehicleid ==" for each check or else it is just checking to see if that vehicle exists.
Reply
#7

Omfg read wiki -.-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)