Help!
#4

imagine you create 4 cars
pawn Код:
Car[45]=Create(cheetah);
Car[46]=Create(sultan);
Car[47]=Create(ingernus);
Car[48]=Create(nrg);
and you got an array with the same size as the amount of created vehicles, then each one should be set to a special allowed faction, or none at all:
pawn Код:
VehicleAllowed[45]=1;//only faction 1 is allowed to drive, all other factions gets kicked out
VehicleAllowed[46]=2;//only faction 2
VehicleAllowed[47]=2;
VehicleAllowed[48]=0;//no faction here, all players may drive, no need to add that line btw, any cell is 0 at start
.. you are using different faction variables for each player, so a isfd[playerid] can be true, while ispolice[playerid] also can be true. thats not the case i bet, since a player is supposed to work in 1 job at a time only.
checking for a player (being in a certain faction, ergo allowed/forbidden to drive), is best done with a pre-buffered array, the "vehicles allowances". who (faction) may drive it? or may ALL players drive? thats defined by setting a faction to either 1(isfd), 2(ispolice) or 3(istau) at each created vehicle, using its VehicleAllowed[vehicleid].
look at this line. isfd[playerid] is 1 as fireman. vehicle allowance of VehicleAllowed[45]=1 (the cheetah), so they match...
pawn Код:
if(isfd[playerid]==VehicleAllowed[GetPlayerVehicleID(playerid)] && Taxijob[playerid]==0)
    {
by using th SAME variable (like Faction[playerid]), you could set it to any value, so only one single check for any vehicle would be required. it also restricts a player to be in one single faction only. if you can sacrifice that, you will gain an elegant solution
if you want players to be in more than just 1 faction, then you need to add 1 or 2 more checks. slightly modified:
pawn Код:
if(ispolice[playerid]==VehicleAllowed[GetPlayerVehicleID(playerid)] && Taxijob[playerid]==0)
    {
Reply


Messages In This Thread
Help! - by vincee - 02.01.2012, 15:35
Re: Help! - by Babul - 02.01.2012, 15:59
Re: Help! - by vincee - 02.01.2012, 16:07
Re: Help! - by Babul - 02.01.2012, 16:49
Re: Help! - by vincee - 02.01.2012, 17:35

Forum Jump:


Users browsing this thread: 1 Guest(s)