User Tools

Site Tools


scripting:samples:hiscoretable

This is an old revision of the document!


$kScoreboardName = “SoloTimeTrial”

function HiscoreDisplay() {

osdcreate( OSDWINDOW,"HiscoresOSD", "" ) 
osdminheight( 300 ) 
osdadd( BIGWARNINGTEXT, 100, 0, 400, 0, "", "Hiscore Table" )
$loop = 0
$liney = 30

$colCount = 100
$colName =  180
$colScore = 400

sysHiscoreTable( $kScoreboardName, 0, 10 )

while( $loop < 10 )
{
	$score = sysHiscoreGetScore( $kScoreboardName, $loop )
	if ( $score > 0 )
	{
		$rank = $loop + 1
		osdadd( TEXT, $colCount, $liney, 0, 0, "", "$rank" )
		$name = sysHiscoreGetName( $kScoreboardName, $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” ) {

sysHiscoreTable( $kScoreboardName, 0, 10 )
$entry = sysHiscoreAdd( $kScoreboardName, 100, "Bruce")
*say Bruce added to hiscore, position $entry 
$entry = sysHiscoreAdd( $kScoreboardName, 10, "Bob")
*say Bob added to hiscore, position $entry 
$entry = sysHiscoreAdd( $kScoreboardName, 200, "Jim")
*say Jim added to hiscore, position $entry 
$entry = sysHiscoreAdd( $kScoreboardName, 50, "Frank")
*say Frank added to hiscore, position $entry 

}

Event( “&command”, “testscoredisplay” ) {

HiscoreDisplay()

}

scripting/samples/hiscoretable.1681752165.txt.gz · Last modified: 2023/04/17 12:22 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki