Raised This Month: $51 Target: $400
 12% 

Solved For loop stopping at iteration 6


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Nezur0s
Junior Member
Join Date: Feb 2020
Old 03-22-2020 , 06:21   For loop stopping at iteration 6
Reply With Quote #1

Hello I have in my plugin this for loop
PHP Code:
int Cts[MAXPLAYERS 1];
     
int number 0;
     for (
int i 1MAXPLAYERS 1;i++)
     {
         
PrintToChatAll("Client Number %d",i);
         if (
IsClientConnected(i))
         {
              if (
IsPlayerAlive(i))
              {
                  if (
GetClientTeam(i) == CS_TEAM_CT)
                {
                
Cts[number] = i;
                
number++;
                }
              }
         }
     }
PrintToChatAll("Loop Next"); // only executes half the time in online server 
It's supposed to get all Ct Team clients and put them in Cts array
When i am in my own lan server with bots this loop seems to work just fine
When i try it in a real server with a small number of players (for some reasons it does this more when there are less players) it seems to work half the time and in the other half it stops at client index 6 and the rest of the code under it doesn't get executed. (I am not the server owner and can't get the console output to know the error)

Last edited by Nezur0s; 03-23-2020 at 07:19.
Nezur0s is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode