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

GetClientFrags Errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 07-03-2016 , 09:29   GetClientFrags Errors
Reply With Quote #1

Having a really weird error with SourceMod I cannot figure out. All I am trying to do is cycle through all players, get their score, and at the end of the loop, the highest score is saved to a variable. See code below, thanks for your help.

Returns Error Client <whatever index> is not in-game, when they are:
PHP Code:
new iHighFrags 0;
new 
iClientFrags 0;

for (
int i 1<= MaxClientsi++)
{
    
iClientFrags GetClientFrags(i);
    if (
IsClientInGame(i) && iClientFrags iHighFrags)
    {
        
iHighFrags iClientFrags;
    }


Returns Error client <whatever index> is invalid, when it isn't
PHP Code:
new iHighFrags 0;
new 
iClientFrags 0;

for (
int i 1<= MaxClientsi++)
{
    
iClientFrags GetClientFrags(GetClientUserId(i));
    if (
IsClientInGame(i) && iClientFrags iHighFrags)
    {
        
iHighFrags iClientFrags;
    }

scorpius2k1 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 07-03-2016 , 09:51   Re: GetClientFrags Errors
Reply With Quote #2

PHP Code:
int iHighFrags 0iClientFrags 0;
for (
int i 1<= MaxClients; ++i)
{
    if (!
IsClientInGame(i))
        continue;

    
iClientFrags GetClientFrags(i);
    if (
iClientFrags iHighFrags)
        
iHighFrags iClientFrags;

__________________

Last edited by WildCard65; 07-03-2016 at 09:51.
WildCard65 is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 07-03-2016 , 16:58   Re: GetClientFrags Errors
Reply With Quote #3

Wildcard's will fix your problem, but to help explain the issue, GetClientFrags requires the player to be in game, so that in game check should come before it.
__________________
ThatOneGuy is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 07-04-2016 , 08:53   Re: GetClientFrags Errors
Reply With Quote #4

Quote:
Originally Posted by ThatOneGuy View Post
Wildcard's will fix your problem, but to help explain the issue, GetClientFrags requires the player to be in game, so that in game check should come before it.
Right, exactly my point --- I have a test server setup with only 2 players, in-game 100%, and I get those errors reported. I will do some testing with WildCards code and report back.
scorpius2k1 is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 07-04-2016 , 09:10   Re: GetClientFrags Errors
Reply With Quote #5

Tested, and yes, WildCard65's code "fixes" the error. But now I don't get any value to iClientFrags. I tried another very simple piece of code, and get this error (I am the only one in the server). Why is SourceMod giving me this error? I am on the latest build, Linux, SourceMod 1.8.0.5916. On a side note, the code runs when the map time runs out (gets to 0). This is in HL2DM and I am thinking might be a bug.

ERROR:
Code:
L 07/04/2016 - 07:55:23: [SM] Exception reported: Client 2 is not in game
CODE:
PHP Code:
new iClientFrags 0;

for (
int i 1<= MaxClientsi++)
{
    if(
IsClientInGame(i)) // VALIDATED CLIENT, I AM IN GAME, NEXT LINE OF CODE RUNS
    
{
        
iClientFrags GetClientFrags(i); // THIS IS THE LINE THAT GIVES AN ERROR ==> [SM] Exception reported: Client 2 is not in game
    
}

Ideas?
scorpius2k1 is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 07-04-2016 , 09:32   Re: GetClientFrags Errors
Reply With Quote #6

I just wanted to confirm; if the map time is 1 or greater, ALL code I mentioned here throws no errors. For some reason, after the map timelimit is reached, those errors happen with GetClientFrags. Apparently it runs into an error if maptime is over. What I did to fix is run my code 1 second before the map time runs out and all is well. I hope others will try this and see if they have the same error, if so, may need a bugfix. Again, I have this error in HL2DM, but may exist in others too. Thank you all for your time.

Last edited by scorpius2k1; 07-04-2016 at 09:42.
scorpius2k1 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 07-04-2016 , 10:50   Re: GetClientFrags Errors
Reply With Quote #7

Quote:
Originally Posted by scorpius2k1 View Post
I just wanted to confirm; if the map time is 1 or greater, ALL code I mentioned here throws no errors. For some reason, after the map timelimit is reached, those errors happen with GetClientFrags. Apparently it runs into an error if maptime is over. What I did to fix is run my code 1 second before the map time runs out and all is well. I hope others will try this and see if they have the same error, if so, may need a bugfix. Again, I have this error in HL2DM, but may exist in others too. Thank you all for your time.
Only time you get the not in game error from GetClientFrags in the following cases:
1) SM's internal player class has m_IsInGame as false
2) The client's edict "unknown" is NULL
https://github.com/alliedmodders/sou...ager.cpp#L2221
__________________

Last edited by WildCard65; 07-04-2016 at 10:51.
WildCard65 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 01:54.


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