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

Solved What's wrong with my client loop?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Morning
Member
Join Date: May 2021
Old 01-29-2022 , 20:23   What's wrong with my client loop?
Reply With Quote #1

I'm trying to do a player loop to fill a global array. Well it works, but the rest of the function is not getting executed. I'm just having one of those moments... am i trying to do something crazy and stupid here?? Simplified code for illustration:

Code:
void Test()
{
	for(int i = 1; i <= MaxClients; i++)
		{
		if(GetClientTeam(i) == 1)
			{ 	
			PrintToConsole(0, "%N is spectating", i);
			}
		else if(GetClientTeam(i) != 1)
			{
			PrintToConsole(0, "%N is not spectating", i);	
			}
		}
	//////
	PrintToConsole(0, "Is there a good reason this code is not executing??");
	//////
}

Last edited by Morning; 01-31-2022 at 07:46.
Morning is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-29-2022 , 20:36   Re: What's wrong with my client loop?
Reply With Quote #2

You get error, when you use GetClientTeam() without checking first, IsClientInGame().

https://forums.alliedmods.net/showpo...58&postcount=5
Ignore "new" syntax in that post code, it is old style.




Look logs from sourcemod folder.
__________________
Do not Private Message @me

Last edited by Bacardi; 01-29-2022 at 20:40.
Bacardi is offline
Morning
Member
Join Date: May 2021
Old 01-29-2022 , 20:50   Re: What's wrong with my client loop?
Reply With Quote #3

Wow, I'm surprised such vital information has evaded me for so long I didn't realise all of those errors im my logs were because of that. I also have a lot of errors for IsFakeClient and IsPlayerAlive that I will have to fix.

Thanks a lot!
Morning is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 01-30-2022 , 05:26   Re: What's wrong with my client loop?
Reply With Quote #4

When you use any function from includes, check error notes if there are any.
For example, GetClientTeam:
Quote:
Invalid client index, client not in game, or no mod support.
It helps you understand what errors to expect from a function if it throws exceptions.
__________________
MAGNAT2645 is offline
Reply



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 09:59.


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