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

Best way to store "points" on each client.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cream Tea
New Member
Join Date: Oct 2016
Old 03-12-2018 , 05:26   Best way to store "points" on each client.
Reply With Quote #1

Hello, I've been trying for two days to figure this out and still can't so I'm hoping somebody here might be able to direct me.

I'm trying to store points for each client that go up each round, similar to Vs Saxton Hale but not stored as a cookie (So it resets when the map changes).

So far I've come up with having an array variable just called points, declared as
Code:
new points[32];
And then I've hooked onto the event "arena_round_start", which adds up everybody's points by one each round like this.
Code:
        for(new i = 1; i <= GetClientCount(); i++) {
                if(IsClientInGame(i) && !IsFakeClient(i)) {
                        points[i]++;
                }
        }
The problem is when I try setting stuff depending on who has the most points, I feel like it's doing it randomly and not actually on the value of the points.

Am I doing this completely wrong?
Cream Tea is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 03-12-2018 , 06:10   Re: Best way to store "points" on each client.
Reply With Quote #2

Theres nothing glaringly obvious to me in your code and you haven't given much details, but if you really want to find out whats going on I suggest doing some debug prints to see whats happening.

e.g. just underneath points[i]++ add:
PrintToChatAll( "Gave %N a point!", i );
hmmmmm is offline
pride95
Senior Member
Join Date: Aug 2015
Old 03-12-2018 , 07:22   Re: Best way to store "points" on each client.
Reply With Quote #3

PHP Code:

new points[MAXPLAYERS 1];

for (
int i 1<= MaxClientsi++) 
Basic sourcemod.
pride95 is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-12-2018 , 07:51   Re: Best way to store "points" on each client.
Reply With Quote #4

Quote:
Originally Posted by pride95 View Post
PHP Code:

new points[MAXPLAYERS 1];

for (
int i 1<= MaxClientsi++) 
Basic sourcemod.
nice basically mixing syntaxes
sdz is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-12-2018 , 16:33   Re: Best way to store "points" on each client.
Reply With Quote #5

PHP Code:
int g_iClientPoints[MAXPLAYERS 1];

for (
int client 1client <= MaxClientsclient++) 
__________________
Neuro Toxin is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-12-2018 , 23:25   Re: Best way to store "points" on each client.
Reply With Quote #6

The main issue with the code in the OP is that the conditional within the for loop was using GetClientCount().

Used player indexes aren't guaranteed to be contiguous. If 6 players join an empty server, then those players would be in slots 1-6. If the player in slot 4 disconnected, then the used slots would be 1, 2, 3, 5, and 6.

So let's say that your server has 24 slots, and only 17 people are connected. This is what your code would be doing:

Click image for larger version

Name:	slots.png
Views:	79
Size:	15.4 KB
ID:	168864
(click to enlarge)
__________________
ddhoward is offline
Cream Tea
New Member
Join Date: Oct 2016
Old 03-13-2018 , 13:37   Re: Best way to store "points" on each client.
Reply With Quote #7

Well thanks I didn't even realise there was a MaxClients value, also ddhoward I was thinking perhaps that was the case. Thank you too.

The points seem to be working, now I just got to finish the sorting bit.
Cream Tea 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 14:05.


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