SA-MP Forums Archive
Whats wrong? (Faction vehicles) - 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: Whats wrong? (Faction vehicles) (/showthread.php?tid=254806)



Whats wrong? (Faction vehicles) - MyxZ - 12.05.2011

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



Re: Whats wrong? (Faction vehicles) - randomkid88 - 13.05.2011

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 ==.


Re: Whats wrong? (Faction vehicles) - park4bmx - 13.05.2011

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


Re: Whats wrong? (Faction vehicles) - Mike Garber - 13.05.2011

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


Re: Whats wrong? (Faction vehicles) - MyxZ - 13.05.2011

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



Re: Whats wrong? (Faction vehicles) - randomkid88 - 13.05.2011

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.


Re: Whats wrong? (Faction vehicles) - Ozz - 13.05.2011

Omfg read wiki -.-