GetScoreBoard: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
(Created page with "<poem style="border: 2px solid #d6d2c5; background-color: #f9f4e6; padding: 1em;"> This function was added in v1.8 beta 5(not released as of 30.Dec.2024) and will not work on previous versions. </poem> {{Welcome|desc=Gets the scoreboard along with ping of players.| params=<source>process_scoreboard</source> ::process_scoreboard : A one parameter function like <source inline>function(data)</source> which will be called when scoreboard table arrives from server. On succes...")
 
No edit summary
 
Line 8: Line 8:
GetScoreBoard(function(data){  
GetScoreBoard(function(data){  
foreach(val in data)print("ID:"+val.ID+", Score: "+val.Score+", Ping: "+val.Ping+"\n");
foreach(val in data)print("ID:"+val.ID+", Score: "+val.Score+", Ping: "+val.Ping+"\n");
}</source>
});</source>
Output:
Output:
<source inline>ID:0, Score: 200, Ping: 1</source>|
<source inline>ID:0, Score: 200, Ping: 1</source>|
retvals=true on success, false if scoreboard was already requested but it's not yet arrived.|}}
retvals=true on success, false if scoreboard was already requested but it's not yet arrived.|}}

Latest revision as of 15:13, 30 December 2024

This function was added in v1.8 beta 5(not released as of 30.Dec.2024) and will not work on previous versions.


Description:
Gets the scoreboard along with ping of players.


Parameters:

process_scoreboard
process_scoreboard : A one parameter function like function(data) which will be called when scoreboard table arrives from server. On successful arrival, data will be an array of tables containing keys: ID,Score and Ping


Return Values:
true on success, false if scoreboard was already requested but it's not yet arrived.


Example

GetScoreBoard(function(data){ 
foreach(val in data)print("ID:"+val.ID+", Score: "+val.Score+", Ping: "+val.Ping+"\n");
});

Output: ID:0, Score: 200, Ping: 1