#1

Will this decrease MaxPass variable for each player effects by the code or only one time?
PHP код:
        for(new =0MAX_PLAYERS;i++)
        {
            if(
PilotID[i] == playerid && city[i] == 1)
            {
                
SetPlayerPos(i,1983.5895,-2496.0449,13.5391);
                
SetPlayerInterior(i0);
                
SetPlayerVirtualWorld(i0);
                
PilotID[i] = -1;
                
RequestPilot[i] = false;
                
city[i] = 0;
                
MaxPass[playerid]--;
            }
        } 
Reply
#2

I think it should work
Reply
#3

Hello!

MaxPass decrease the whole time so far the loop is finished.
If MAX_PLAYERS is 500, MaxPass will be going 500 decreasing.

(Sorry for my very bad english...)


- Mencent
Reply
#4

It will decrease MaxPass for playerid many times. If you want to decrease it by 1 for each player in the loop, change "playerid" to "i" to affect the player in the iteration:
Код:
MaxPass[i]--;
Reply
#5

But I want to deacrease MaxPass for playerid not the other players
Reply
#6

It will only decrease for playerid. Unless playerid can be in PilotID[i] multiple times, the if condition will only be met once. You could then add
break;
at the end of the if clause, so the loop will stop and wont continue unneccessarily.
Reply
#7

If you want to affect the playerid once, just place MaxPass(playerid)-- outside of the loop. I think it's pretty obvious.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)