scripting:samples:hiscoretable
This script demonstrates use of the sysHiscores functions. A &command function is included demonstrating how to add scores to the table.
The script uses a module variable '$kScoreboardName' to identify the board.. you can change this to whatever you like and you can create multiple scoreboards just by using different names.
The example shows a board that stores times and the board is ordered so the lowest time is at the top of the score table.
$kScoreboardName = "SampleHiscore" function HiscoreDisplay( $boardName ) { osdcreate( OSDWINDOW,"HiscoresOSD", "" ) osdminheight( 300 ) osdadd( BIGWARNINGTEXT, 100, 0, 400, 0, "", "Hiscore Table" ) $loop = 0 $liney = 30 $colCount = 100 $colName = 180 $colScore = 400 while( $loop < 10 ) { $score = sysHiscoreGetScore( $boardName, $loop ) if ( $score > 0 ) { $rank = $loop + 1 osdadd( TEXT, $colCount, $liney, 0, 0, "", "$rank" ) $name = sysHiscoreGetName( $boardName, $loop ) osdadd( TEXT, $colName, $liney, 0, 0, "", "$name" ) $timemins = $score / 60 $timesecs = $score % 60 osdadd( TEXT, $colScore, $liney, 0, 0, "", "$timemins m $timesecs s" ) $liney += 20 $loop += 1 } else { $loop = 10 } } osdadd( EXITBUTTON, 100, 260, 400, 30, "", "Close" ) osdactivate() } Event( "&command", "testscoreadd" ) { // Create the board with max 10 entries. Mode 0 means lowest values at top (Mode 1 is the reverse) sysHiscoreTable( $kScoreboardName, 0, 10 ) $entry = sysHiscoreAdd( $kScoreboardName, 100, "Bruce") $entry = sysHiscoreAdd( $kScoreboardName, 10, "Bob") $entry = sysHiscoreAdd( $kScoreboardName, 200, "Jim") $entry = sysHiscoreAdd( $kScoreboardName, 50, "Frank") } Event( "&command", "testscoredisplay" ) { HiscoreDisplay( $kScoreboardName ) }
scripting/samples/hiscoretable.txt · Last modified: 2023/04/23 18:40 by mit