Raised This Month: $32 Target: $400
 8% 

[SOLVED] Function doesn't work for some players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thecount
Veteran Member
Join Date: Jul 2013
Old 06-13-2014 , 15:20   [SOLVED] Function doesn't work for some players
Reply With Quote #1

PHP Code:
public Action:Command_Reset(clientargs){
    for(new 
i=1;i<11;i++){
        
resetPoints(i);
    }
    return 
Plugin_Handled;
}

public 
resetPoints(any:client){
    for(new 
i=0;i<11;i++){
        if(
== 0||== 5||== 6|| == 4){
        }else{
            
playerElo[client][i] = 0;
        }
    }
    return 
0;

So like, it's supposed to reset values in this array for every client, but it only works for some players depending on the order they join the server. This is a big problem for the rest of the plugin and I would like help on it. Many thanks in advanced.

Last edited by thecount; 06-15-2014 at 17:27.
thecount is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 06-13-2014 , 15:41   Re: Function doesn't work for some players
Reply With Quote #2

Server only holds 10 people by the way. That's vital information I almost forgot.
thecount is offline
Antix1267
Junior Member
Join Date: Jun 2013
Old 06-13-2014 , 19:46   Re: Function doesn't work for some players
Reply With Quote #3

I assume the problem is somewhere in the resetPoints function, something breaks within the loop causing the function not to return a value -> causing the loop in Command_Reset to break as well -> doesn't update for other players.

Does ANYONE have an idea what exactly is wrong?

Last edited by Antix1267; 06-13-2014 at 19:48.
Antix1267 is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 06-14-2014 , 05:50   Re: Function doesn't work for some players
Reply With Quote #4

If that is all the code, maybe something wrong with declaration, although compiler would probably caught that.
xf117 is offline
Send a message via ICQ to xf117
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 06-14-2014 , 07:21   Re: Function doesn't work for some players
Reply With Quote #5

Just because the server holds 10 people, maybe those clientIDs are still spread out between 1 and MaxClients. Try this instead (note: I don't know what your array's second dimension is so I'm leaving that to iterate between 0 and 10).

PHP Code:
public Action:Command_Reset(clientargs){
    for(new 
i=1;i<=MaxClients;i++){
        if (
IsClientInGame(i)) {
            
resetPoints(i);
        }
    }
    return 
Plugin_Handled;
}

resetPoints(client){
    for(new 
i=0;i<11;i++){
        if(
!= && != && != && != 4){
            
playerElo[client][i] = 0;
        }
    }

__________________

Last edited by 11530; 06-14-2014 at 07:23.
11530 is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 06-15-2014 , 17:27   Re: Function doesn't work for some players
Reply With Quote #6

Figured out the problem was my function giving a return value that for some reason stopped the for statement. *shrug* Oh well. Thanks anyways.

Last edited by thecount; 06-17-2014 at 18:25.
thecount is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 06-16-2014 , 09:55   Re: Function doesn't work for some players
Reply With Quote #7

Quote:
Originally Posted by 11530 View Post
Just because the server holds 10 people, maybe those clientIDs are still spread out between 1 and MaxClients.
Would MaxClients be set to 10? Since something sets it before hand? (Sourcemod itself)
And plus, the only way a client id would be above MaxClients is if the MaxClients variable has changed and the slots accordingly. MAXPLAYERS on the other hand is game specific(? may just be set to 64)

Last edited by Mitchell; 06-16-2014 at 09:56.
Mitchell is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 06-17-2014 , 18:23   Re: Function doesn't work for some players
Reply With Quote #8

Quote:
Originally Posted by Mitchell View Post
Would MaxClients be set to 10? Since something sets it before hand? (Sourcemod itself)
And plus, the only way a client id would be above MaxClients is if the MaxClients variable has changed and the slots accordingly. MAXPLAYERS on the other hand is game specific(? may just be set to 64)
I don't even know what game this is. But no, MaxClients would be set to the server's maxplayers convar, and MAXPLAYERS is just hard-coded as 64 as that's the highest any Source game can handle.
__________________
11530 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:39.


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