Only highest id can toggle...weard for loop
#1

With this For Loop only the last joined person/highest id can trigger the shizzle inside this.
What is WRONG ?!?

for(new i=0; i<MAX_PLAYERS; i++)

Grts
Reply
#2

Show us your other code, You must be doing something wrong
Reply
#3

Ok ... here it goes

Код:
public Neartaxigate()
{
	for(new i=0; i<=MAX_PLAYERS; i++)
	{
	  if(IsPlayerConnected(i))
		{
			if(PlayerToPoint(10.0, i, 2259.7708,2032.0975,10.8160) && (GetVehicleModel(GetPlayerVehicleID(i)) == 420))
			{
				MoveObject(taxigate, 2258.822998, 2032.539185, 9.987190, 2.0);
			}
			else if(PlayerToPoint(10.0, i, 2259.7708,2032.0975,10.8160) )
			{
			GameTextForPlayer(i, "Gates only open for cab drivers!", 3000, 5);
			MoveObject(taxigate, 2262.921143, 2032.481201, 9.987190, 2.0);
			}
		}
	}
}
Reply
#4

Quote:
Originally Posted by Rizard
for(new i=0; i<MAX_PLAYERS; i++)
Then in your code you have got
Quote:
Originally Posted by Rizard
Код:
	for(new i=0; i<=MAX_PLAYERS; i++)
Try just using
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
Reply
#5

Srry for the litle differents (prob typing mistake)

i'll try this asap

Grts
Reply
#6

I changed the code into your proposel and tested it ... but it doesn't open for anyone anymore

But hang on for a while i might think it get solved over here, have my bro who's helping with the code ... if i get it solved i'll post how and if not u will hear from me again

Grts and thnx for the replies
Reply
#7

If you have several players within the radius the gate will be opening and closing all over the place.

Taxi members make it open, non taxi members make it close.. so if you have 1 of each within the area it'll most likely vibrate/not work
Reply
#8

here is the code that does work

Код:
public Neartaxigate()
{
	new bool:playerneartaxigate = false;
	for(new i; i < MAX_PLAYERS; i++)
	{
	  if(IsPlayerConnected(i))
	  {
		  if(PlayerToPoint(10.0, i, 2259.7708,2032.0975,10.8160))
		  {
			  if(GetVehicleModel(GetPlayerVehicleID(i)) == 420)
				{
					playerneartaxigate = true;
				}
				else
				{
					GameTextForPlayer(i, "Gates only open for cab drivers!", 3000, 5);
				}
			}
		}
	}
	
	if (playerneartaxigate)
	{
	  MoveObject(taxigate, 2258.822998, 2032.539185, 9.987190, 2.0);
	}
	else if(!playerneartaxigate)
	{
	  MoveObject(taxigate, 2262.921143, 2032.481201, 9.987190, 2.0);
	}
}
so i inserted a boolean that becomes true when any player is in radius with cab then on the end it checks the boolean and if its true the gates will open, otherwise it stays false and the gates will close

grtz
Reply
#9

Yup, that's the right way to do it. The same way I think I did with my AutoGates
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)