Looping problem
#1

So the problem is this that my loop for gate works only for one id. Can someone help me?
PHP код:
forward GateCheck();
public 
GateCheck()
{
    foreach(
Playeri) if(pInfo[i][gTeam] != ROBBERS || pInfo[i][pLevel] >= 2)
    if(
IsPlayerConnected(i))
    {
                if(
IsPlayerInRangeOfPoint(i6.01544.68457, -1630.9261513.12690))
                {
                    if(
pInfo[i][gTeam] != LSPD) continue;
                    if(
pInfo[i][gTeam] == LSPD)
                    {
                        if(
gStatus == false)
                        {
                             
SetObjectRot(pgate, -4.260001.4999990.00000);
                            
gStatus true;
                        }
                    }
                }
                if(!
IsPlayerInRangeOfPoint(i6.01544.68457, -1630.9261513.12690))
                {
                    
                        if(
gStatus == true)
                        {
                             
SetObjectRot(pgate0.2400090.2400090.00000);
                            
gStatus false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.01587.3921,-1637.1376,13.3828))
                {
                    if(
pInfo[i][gTeam] != LSPD) continue;
                    if(
pInfo[i][gTeam] == LSPD)
                    {
                        if(
gStatus21 == false)
                        {
                             
MoveObject(pgate21580.91174, -1637.8855015.04516,2.9);
                            
gStatus21 true;
                        }
                       }
                }
                 if(!
IsPlayerInRangeOfPoint(i6.01587.3921,-1637.1376,13.3828))
                {
                        if(
gStatus21 == true)
                        {
                             
MoveObject(pgate2,  1582.39185, -1637.8836715.0422,2.9);
                            
gStatus21 false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.01596.15857, -1637.8836715.23570))
                {
                    if(
pInfo[i][gTeam] != LSPD) continue;
                    if(
pInfo[i][gTeam] == LSPD)
                    {
                        if(
gStatus22 == false)
                        {
                              
MoveObject(pgate31596.15857, -1637.883679.59650,2.9);
                             
gStatus22 true;
                        }
                       }
                }
                if(!
IsPlayerInRangeOfPoint(i6.01596.15857, -1637.8836715.23570))
                {
                    
                        if(
gStatus22 == true)
                        {
                             
MoveObject(pgate31596.15857, -1637.8836715.23570,2.9);
                            
gStatus22 false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.0,  1262.8844,-2047.8555,59.3449))
                {
                        if(
pInfo[i][pLevel] < 2) continue;
                        if(
pInfo[i][pLevel] >= 2)
                        {
                            if(
gStatus11 == false)
                            {
                                
MoveObject(adgate,  1264.16260, -2048.5886255.25351,2.9);
                                
gStatus11 true;
                            }
                        }
                }
                if(!
IsPlayerInRangeOfPoint(i6.0,  1262.8844,-2047.8555,59.3449))
                   {
                       
                           if(
gStatus11 == true)
                        {
                                
MoveObject(adgate,  1264.16260, -2048.5886260.83170,2.9);
                                
gStatus11 false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.0,  1133.2192,-2080.8923,69.5591))
                {
                    if(
pInfo[i][pLevel] < 2) continue;
                    if(
pInfo[i][pLevel] >= 2)
                       {
                        if(
gStatus12 == false)
                        {
                            
MoveObject(adgate2,   1133.51819, -2081.3049365.25336,2.9);
                            
gStatus12 true;
                        }
                    }
                }
                if(!
IsPlayerInRangeOfPoint(i6.0,  11133.2192,-2080.8923,69.5591))
                  {
                      
                          if(
gStatus12 == true)
                          {
                                    
MoveObject(adgate2,  1133.51819, -2081.3049370.72000,2.9);
                                    
gStatus12 false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.02606.91016, -2401.9213915.22000))
                {
                    if(
pInfo[i][gTeam] != Army) continue;
                    if(
pInfo[i][gTeam] == Army)
                    {
                        if(
gStatus3 == false)
                        {
                            
MoveObject(agate,  2606.91016, -2401.9213920.68000,2.9);
                            
gStatus3 true;
                        }
                    }
                }
                if(!
IsPlayerInRangeOfPoint(i6.0,2606.91016, -2401.9213915.22000))
                {
                    
                        if(
gStatus3 == true)
                        {
                            
MoveObject(agate2606.91016, -2401.9213915.22000,2.9);
                             
gStatus3 false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.02666.26099, -2504.0737315.24000))
                {
                    if(
pInfo[i][gTeam] != Army) continue;
                    if(
pInfo[i][gTeam] == Army)
                    {
                        if(
gStatus20 == false)
                        {
                            
MoveObject(agate2,  2666.26099, -2504.0737320.68000,2.9);
                            
gStatus20 true;
                        }
                    }
                }
                if(!
IsPlayerInRangeOfPoint(i6.0,2666.26099, -2504.0737315.24000))
                {
                    
                        if(
gStatus20 == true)
                        {
                               
MoveObject(agate22666.26099, -2504.0737315.24000,2.9);
                              
gStatus20 false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.0,1027.43433, -368.4650975.28000))
                {
                    if(
pInfo[i][gTeam] != SWAT) continue;
                    if(
pInfo[i][gTeam] == SWAT)
                    {
                        if(
gStatus4 == false)
                        {
                            
MoveObject(sgate1027.43433, -368.4650980.76000,2.9);
                            
gStatus4 true;
                        }
                    }
                }
                if(!
IsPlayerInRangeOfPoint(i6.0,1027.43433, -368.4650975.28000))
                {
                    
                        if(
gStatus4 == true)
                        {
                               
MoveObject(sgate1027.43433, -368.4650975.28000,2.9);
                              
gStatus4 false;
                        }
                }
                if(
IsPlayerInRangeOfPoint(i6.02440.59521, -969.1334880.70480))
                {
                    if(
pInfo[i][gTeam] != Terrorist) continue;
                    if(
pInfo[i][gTeam] == Terrorist)
                    {
                        if(
gStatus6 == false)
                        {
                             
MoveObject(tgate2440.59521, -969.1334886.16000,2.9);
                             
gStatus6 true;
                        }
                    }
                }
                if(!
IsPlayerInRangeOfPoint(i6.02440.59521, -969.1334880.70480))
                {
                    
                        if(
gStatus6 == true)
                        {
                            
MoveObject(tgate2440.59521, -969.1334880.70480,2.9);
                               
gStatus6 false;
                        }
                }
    }
    return 
1;

Reply
#2

Try this, With foreach you don't have to check whether the player is connect or not because foreach check it already, Also i recommend updating your foreach.

Another thing, What are you trying to do here?:

PHP код:
if(pInfo[i][gTeam] != LSPD) continue; 
You already checked if the player is LSPD, you don't have to check for twice.

PHP код:
public GateCheck() 

    foreach(
Playeri) {
    if(
pInfo[i][gTeam] != ROBBERS || pInfo[i][pLevel] >= 2
    { 
                if(
IsPlayerInRangeOfPoint(i6.01544.68457, -1630.9261513.12690)) 
                { 
                    if(
pInfo[i][gTeam] != LSPD) continue; 
                    if(
pInfo[i][gTeam] == LSPD
                    { 
                        if(
gStatus == false
                        { 
                             
SetObjectRot(pgate, -4.260001.4999990.00000); 
                            
gStatus true
                        } 
                    } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.01544.68457, -1630.9261513.12690)) 
                { 
                     
                        if(
gStatus == true
                        { 
                             
SetObjectRot(pgate0.2400090.2400090.00000); 
                            
gStatus false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.01587.3921,-1637.1376,13.3828)) 
                { 
                    if(
pInfo[i][gTeam] != LSPD) continue; 
                    if(
pInfo[i][gTeam] == LSPD
                    { 
                        if(
gStatus21 == false
                        { 
                             
MoveObject(pgate21580.91174, -1637.8855015.04516,2.9); 
                            
gStatus21 true
                        } 
                       } 
                } 
                 if(!
IsPlayerInRangeOfPoint(i6.01587.3921,-1637.1376,13.3828)) 
                { 
                        if(
gStatus21 == true
                        { 
                             
MoveObject(pgate2,  1582.39185, -1637.8836715.0422,2.9); 
                            
gStatus21 false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.01596.15857, -1637.8836715.23570)) 
                { 
                    if(
pInfo[i][gTeam] != LSPD) continue; 
                    if(
pInfo[i][gTeam] == LSPD
                    { 
                        if(
gStatus22 == false
                        { 
                              
MoveObject(pgate31596.15857, -1637.883679.59650,2.9); 
                             
gStatus22 true
                        } 
                       } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.01596.15857, -1637.8836715.23570)) 
                { 
                     
                        if(
gStatus22 == true
                        { 
                             
MoveObject(pgate31596.15857, -1637.8836715.23570,2.9); 
                            
gStatus22 false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.0,  1262.8844,-2047.8555,59.3449)) 
                { 
                        if(
pInfo[i][pLevel] < 2) continue; 
                        if(
pInfo[i][pLevel] >= 2
                        { 
                            if(
gStatus11 == false
                            { 
                                
MoveObject(adgate,  1264.16260, -2048.5886255.25351,2.9); 
                                
gStatus11 true
                            } 
                        } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.0,  1262.8844,-2047.8555,59.3449)) 
                   { 
                        
                           if(
gStatus11 == true
                        { 
                                
MoveObject(adgate,  1264.16260, -2048.5886260.83170,2.9); 
                                
gStatus11 false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.0,  1133.2192,-2080.8923,69.5591)) 
                { 
                    if(
pInfo[i][pLevel] < 2) continue; 
                    if(
pInfo[i][pLevel] >= 2
                       { 
                        if(
gStatus12 == false
                        { 
                            
MoveObject(adgate2,   1133.51819, -2081.3049365.25336,2.9); 
                            
gStatus12 true
                        } 
                    } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.0,  11133.2192,-2080.8923,69.5591)) 
                  { 
                       
                          if(
gStatus12 == true
                          { 
                                    
MoveObject(adgate2,  1133.51819, -2081.3049370.72000,2.9); 
                                    
gStatus12 false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.02606.91016, -2401.9213915.22000)) 
                { 
                    if(
pInfo[i][gTeam] != Army) continue; 
                    if(
pInfo[i][gTeam] == Army
                    { 
                        if(
gStatus3 == false
                        { 
                            
MoveObject(agate,  2606.91016, -2401.9213920.68000,2.9); 
                            
gStatus3 true
                        } 
                    } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.0,2606.91016, -2401.9213915.22000)) 
                { 
                     
                        if(
gStatus3 == true
                        { 
                            
MoveObject(agate2606.91016, -2401.9213915.22000,2.9); 
                             
gStatus3 false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.02666.26099, -2504.0737315.24000)) 
                { 
                    if(
pInfo[i][gTeam] != Army) continue; 
                    if(
pInfo[i][gTeam] == Army
                    { 
                        if(
gStatus20 == false
                        { 
                            
MoveObject(agate2,  2666.26099, -2504.0737320.68000,2.9); 
                            
gStatus20 true
                        } 
                    } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.0,2666.26099, -2504.0737315.24000)) 
                { 
                     
                        if(
gStatus20 == true
                        { 
                               
MoveObject(agate22666.26099, -2504.0737315.24000,2.9); 
                              
gStatus20 false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.0,1027.43433, -368.4650975.28000)) 
                { 
                    if(
pInfo[i][gTeam] != SWAT) continue; 
                    if(
pInfo[i][gTeam] == SWAT
                    { 
                        if(
gStatus4 == false
                        { 
                            
MoveObject(sgate1027.43433, -368.4650980.76000,2.9); 
                            
gStatus4 true
                        } 
                    } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.0,1027.43433, -368.4650975.28000)) 
                { 
                     
                        if(
gStatus4 == true
                        { 
                               
MoveObject(sgate1027.43433, -368.4650975.28000,2.9); 
                              
gStatus4 false
                        } 
                } 
                if(
IsPlayerInRangeOfPoint(i6.02440.59521, -969.1334880.70480)) 
                { 
                    if(
pInfo[i][gTeam] != Terrorist) continue; 
                    if(
pInfo[i][gTeam] == Terrorist
                    { 
                        if(
gStatus6 == false
                        { 
                             
MoveObject(tgate2440.59521, -969.1334886.16000,2.9); 
                             
gStatus6 true
                        } 
                    } 
                } 
                if(!
IsPlayerInRangeOfPoint(i6.02440.59521, -969.1334880.70480)) 
                { 
                     
                        if(
gStatus6 == true
                        { 
                            
MoveObject(tgate2440.59521, -969.1334880.70480,2.9); 
                               
gStatus6 false
                        } 
                } 
    } 
}
    return 
1

Reply
#3

But still if there are 2 cops then the gate will work for the one having lower Id. For ex there are ID 1 and 2 then it'll work for I'd 1
Reply
#4

BUMP
Reply
#5

Change those if's to else if.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)