Raised This Month: $18 Target: $400


Post New Thread Reply   
Thread Tools Display Modes
Author Message
Junior Member
Join Date: Feb 2020
Old 03-29-2020 , 02:10   FindEntityByClassName
Reply With Quote #1

Hello when using FindEntityByClassName for example in this loop
PHP Code:
int ent MaxClients 1;
ent FindEntityByClassname(ent"trigger_multiple")) != -1)
How does this loop through all enteties with classname trigger_multiple.
Imagine it finding an entity at index 68 with classname trigger_multiple, When it reruns the loop it will still be index 68 so the loop will run forever with the same entity index
Nezur0s is offline
Junior Member
Join Date: Feb 2020
Old 03-29-2020 , 02:14   Re: FindEntityByClassName
Reply With Quote #2

Well Now that I noticed the word "The entity index After Which" in the API this means that if i choosed 65 it will search for the entity at index 66 and this makes sense. but then why did the creator of this make the starting entity MaxClients + 1 he should've only made it MaxClients am I right ?
Nezur0s is offline
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 03-29-2020 , 05:30   Re: FindEntityByClassName
Reply With Quote #3

The thing is that MaxClients is always client index (you could often see it in for loops) so you can try to start searching from MaxClients.
And don't confuse it with MAXPLAYERS (which always equals to 65 because it's a macros), they're not same.
MAGNAT2645 is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Old 03-29-2020 , 05:52   Re: FindEntityByClassName
Reply With Quote #4

Originally Posted by Nezur0s View Post
he should've only made it MaxClients am I right ?
You're right, when you pass -1 it starts at entity 0, so it should have been
PHP Code:
int ent MaxClients
to start at MaxClients + 1.
DJ Tsunami is offline
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-29-2020 , 06:15   Re: FindEntityByClassName
Reply With Quote #5

The first entity after the clients is always the player resource entity.
asherkin is offline
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-29-2020 , 06:17   Re: FindEntityByClassName
Reply With Quote #6


- While loop stop when FindEntityByClassname return -1

- You can start with variable int ent = -1;
but in your example, it just skip client indexs, 0 = console, 1 2 3 ...

- MaxClients is dynamic variable.
In old games you can set server max players, in server launch parameter -maxplayers 1 to 64.
It depends game, how many slot you can get, example TF2 have 32.
SourceTV add one extra slot also when enabled +1.

And If I remember right, CSGO game reserve all 65 slots for players but limit player count with different game modes (gamemodes.txt "maxplayers").
To stop this change of max players count, it can be force to keep max player count with -maxplayers_override
PHP Code:
public const int MaxClients;   /**< Maximum number of players the server supports (dynamic) */ 
I maybe telling lot of
Do not Private Message @me

Last edited by Bacardi; 03-29-2020 at 06:19.
Bacardi is offline

Thread Tools
Display Modes

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 15:30.

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