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

Get Player Scoreboard Position


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-21-2017 , 18:43   Get Player Scoreboard Position
Reply With Quote #1

Would anyone know how to write 2 simple stocks that would simply get the players current scoreboard position and total active players, for example return Fanks Position out of total active players:

-- Scoreboard (Name | Frags) --
John | 6
Frank | 4
Bob | 1
Ned | 0


PHP Code:
new iPosition GetClientScorePosition(client);
new 
iActive GetTotalActivePlayers(client);

PrintToChatAll(client"#%i out of %i players"iPositioniActive); 

-- Code Returns "Frank's" Stats ---
#2 out of 4 active players



Again, I am just looking to return the simple data that is going on live in the current round when those stocks are called.



Thanks, really appreciate the help!
scorpius2k1 is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 05-21-2017 , 18:57   Re: Get Player Scoreboard Position
Reply With Quote #2

Depends on the game, in general you need to sort players by frags, for csgo by score.
__________________

Last edited by zipcore; 05-21-2017 at 18:57.
zipcore is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-21-2017 , 19:16   Re: Get Player Scoreboard Position
Reply With Quote #3

Apologies, this would be for HL2DM
scorpius2k1 is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 05-21-2017 , 21:43   Re: Get Player Scoreboard Position
Reply With Quote #4

GetTotalActivePlayers would be checking for what? If they've gotten any kills? If they're moving around?
Bobakanoosh is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-22-2017 , 07:38   Re: Get Player Scoreboard Position
Reply With Quote #5

Quote:
Originally Posted by Bobakanoosh View Post
GetTotalActivePlayers would be checking for what? If they've gotten any kills? If they're moving around?
All clients in-game that are not spectating i.e.

PHP Code:
If(IsClientInGame(client) && !IsClientObserver(client)) { 
    
// code

scorpius2k1 is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 05-22-2017 , 13:08   Re: Get Player Scoreboard Position
Reply With Quote #6

Should work:

Code:
stock int GetTotalActivePlayers() {

	int count = 0;

	for(int i = 1; i < MaxClients; i++) {
	
		if(!IsValidClient(i))
			continue;
	
		if(!IsClientObserver(i))
			count++;
	
	}
	
	return count;
	
}
Code:
stock bool IsValidClient(int client, bool noBots=true) {

	if (client < 1 || client > MaxClients)
		return false;

	if (!IsClientInGame(client))
		return false;

	if (!IsClientConnected(client))
		return false;

	if (noBots)
		if (IsFakeClient(client))
			return false;

	if (IsClientSourceTV(client))
		return false;

	return true;

}

Last edited by Bobakanoosh; 05-22-2017 at 13:09.
Bobakanoosh is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 05-23-2017 , 09:29   Re: Get Player Scoreboard Position
Reply With Quote #7

Make an array of all the client scores and sort it by descending
Addicted. 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 23:23.


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