;PLAYER TOP 10 HIGHSCORES BUILDER
CurrUser=#PARAM1

SetUserFlag(22,26,CurrUser)
SetUserFlag(0,26,1)

CurrTop1=GetUserFlag(1,26)
CurrTop2=GetUserFlag(2,26)
CurrTop3=GetUserFlag(3,26)
CurrTop4=GetUserFlag(4,26)
CurrTop5=GetUserFlag(5,26)
CurrTop6=GetUserFlag(6,26)
CurrTop7=GetUserFlag(7,26)
CurrTop8=GetUserFlag(8,26)
CurrTop9=GetUserFlag(9,26)
CurrTop10=GetUserFlag(10,26)

CurrTop11=GetUserFlag(11,26)
CurrTop12=GetUserFlag(12,26)
CurrTop13=GetUserFlag(13,26)
CurrTop14=GetUserFlag(14,26)
CurrTop15=GetUserFlag(15,26)
CurrTop16=GetUserFlag(16,26)
CurrTop17=GetUserFlag(17,26)
CurrTop18=GetUserFlag(18,26)
CurrTop19=GetUserFlag(19,26)
CurrTop20=GetUserFlag(20,26)

TempTop1=CurrTop1
TempTop2=CurrTop2
TempTop3=CurrTop3
TempTop4=CurrTop4
TempTop5=CurrTop5
TempTop6=CurrTop6
TempTop7=CurrTop7
TempTop8=CurrTop8
TempTop9=CurrTop9
TempTop10=CurrTop10

TempTop11=CurrTop11
TempTop12=CurrTop12
TempTop13=CurrTop13
TempTop14=CurrTop14
TempTop15=CurrTop15
TempTop16=CurrTop16
TempTop17=CurrTop17
TempTop18=CurrTop18
TempTop19=CurrTop19
TempTop20=CurrTop20

CurrTop1Raw=GetUserFlag(CurrTop1,28)
CurrTop2Raw=GetUserFlag(CurrTop2,28)
CurrTop3Raw=GetUserFlag(CurrTop3,28)
CurrTop4Raw=GetUserFlag(CurrTop4,28)
CurrTop5Raw=GetUserFlag(CurrTop5,28)
CurrTop6Raw=GetUserFlag(CurrTop6,28)
CurrTop7Raw=GetUserFlag(CurrTop7,28)
CurrTop8Raw=GetUserFlag(CurrTop8,28)
CurrTop9Raw=GetUserFlag(CurrTop9,28)
CurrTop10Raw=GetUserFlag(CurrTop10,28)

CurrTop11Raw=GetUserFlag(CurrTop11,28)
CurrTop12Raw=GetUserFlag(CurrTop12,28)
CurrTop13Raw=GetUserFlag(CurrTop13,28)
CurrTop14Raw=GetUserFlag(CurrTop14,28)
CurrTop15Raw=GetUserFlag(CurrTop15,28)
CurrTop16Raw=GetUserFlag(CurrTop16,28)
CurrTop17Raw=GetUserFlag(CurrTop17,28)
CurrTop18Raw=GetUserFlag(CurrTop18,28)
CurrTop19Raw=GetUserFlag(CurrTop19,28)
CurrTop20Raw=GetUserFlag(CurrTop20,28)

TempTop1Raw=CurrTop1Raw
TempTop2Raw=CurrTop2Raw
TempTop3Raw=CurrTop3Raw
TempTop4Raw=CurrTop4Raw
TempTop5Raw=CurrTop5Raw
TempTop6Raw=CurrTop6Raw
TempTop7Raw=CurrTop7Raw
TempTop8Raw=CurrTop8Raw
TempTop9Raw=CurrTop9Raw
TempTop10Raw=CurrTop10Raw

TempTop11Raw=CurrTop11Raw
TempTop12Raw=CurrTop12Raw
TempTop13Raw=CurrTop13Raw
TempTop14Raw=CurrTop14Raw
TempTop15Raw=CurrTop15Raw
TempTop16Raw=CurrTop16Raw
TempTop17Raw=CurrTop17Raw
TempTop18Raw=CurrTop18Raw
TempTop19Raw=CurrTop19Raw
TempTop20Raw=CurrTop20Raw

Label UserCheck
If CurrUser=0
	Goto BuildComplete
Endif

If GetUserAccess(CurrUser)>0
	Goto BuildLoop
Endif

If GetUserName(CurrUser)="Jason"
	Goto BuildLoop
Endif

UserRawScore=Floor(GetUserStrength(CurrUser)+GetUserEndurance(CurrUser)+GetUserAgility(CurrUser)+GetUserWisdom(CurrUser))/4
If UserRawScore>=CurrTop1Raw
	TempTop1=CurrUser
	TempTop1Raw=UserRawScore
	Goto HighScoreReSort1
Elseif UserRawScore>=CurrTop2Raw
	TempTop2=CurrUser
	TempTop2Raw=UserRawScore
	Goto HighScoreReSort2
Elseif UserRawScore>=CurrTop3Raw
	TempTop3=CurrUser
	TempTop3Raw=UserRawScore
	Goto HighScoreReSort3
Elseif UserRawScore>=CurrTop4Raw
	TempTop4=CurrUser
	TempTop4Raw=UserRawScore
	Goto HighScoreReSort4
Elseif UserRawScore>=CurrTop5Raw
	TempTop5=CurrUser
	TempTop5Raw=UserRawScore
	Goto HighScoreReSort5
Elseif UserRawScore>=CurrTop6Raw
	TempTop6=CurrUser
	TempTop6Raw=UserRawScore
	Goto HighScoreReSort6
Elseif UserRawScore>=CurrTop7Raw
	TempTop7=CurrUser
	TempTop7Raw=UserRawScore
	Goto HighScoreReSort7
Elseif UserRawScore>=CurrTop8Raw
	TempTop8=CurrUser
	TempTop8Raw=UserRawScore
	Goto HighScoreReSort8
Elseif UserRawScore>=CurrTop9Raw
	TempTop9=CurrUser
	TempTop9Raw=UserRawScore
	Goto HighScoreReSort9
Elseif UserRawScore>=CurrTop10Raw
	TempTop10=CurrUser
	TempTop10Raw=UserRawScore
	Goto HighScoreReSort10
Elseif UserRawScore>=CurrTop11Raw
	TempTop11=CurrUser
	TempTop11Raw=UserRawScore
	Goto HighScoreReSort11
Elseif UserRawScore>=CurrTop12Raw
	TempTop12=CurrUser
	TempTop12Raw=UserRawScore
	Goto HighScoreReSort12
Elseif UserRawScore>=CurrTop13Raw
	TempTop13=CurrUser
	TempTop13Raw=UserRawScore
	Goto HighScoreReSort13
Elseif UserRawScore>=CurrTop14Raw
	TempTop14=CurrUser
	TempTop14Raw=UserRawScore
	Goto HighScoreReSort14
Elseif UserRawScore>=CurrTop15Raw
	TempTop15=CurrUser
	TempTop15Raw=UserRawScore
	Goto HighScoreReSort15
Elseif UserRawScore>=CurrTop16Raw
	TempTop16=CurrUser
	TempTop16Raw=UserRawScore
	Goto HighScoreReSort16
Elseif UserRawScore>=CurrTop17Raw
	TempTop17=CurrUser
	TempTop17Raw=UserRawScore
	Goto HighScoreReSort17
Elseif UserRawScore>=CurrTop18Raw
	TempTop18=CurrUser
	TempTop18Raw=UserRawScore
	Goto HighScoreReSort18
Elseif UserRawScore>=CurrTop19Raw
	TempTop19=CurrUser
	TempTop19Raw=UserRawScore
	Goto HighScoreReSort19
Elseif UserRawScore>=CurrTop20Raw
	TempTop20=CurrUser
	TempTop20Raw=UserRawScore
	Goto HighScoreReSort20
Else
	Goto BuildLoop
Endif

Label HighScoreResort20
Goto BuildLoop

Label HighScoreReSort19
TempTop20=CurrTop19
TempTop20Raw=CurrTop19Raw
Goto HighScoreReSort20

Label HighScoreReSort18
TempTop19=CurrTop18
TempTop19Raw=CurrTop18Raw
Goto HighScoreReSort19

Label HighScoreReSort17
TempTop18=CurrTop17
TempTop18Raw=CurrTop17Raw
Goto HighScoreReSort18

Label HighScoreReSort16
TempTop17=CurrTop16
TempTop17Raw=CurrTop16Raw
Goto HighScoreReSort17

Label HighScoreReSort15
TempTop16=CurrTop15
TempTop16Raw=CurrTop15Raw
Goto HighScoreReSort16

Label HighScoreReSort14
TempTop15=CurrTop14
TempTop15Raw=CurrTop14Raw
Goto HighScoreReSort15

Label HighScoreReSort13
TempTop14=CurrTop13
TempTop14Raw=CurrTop13Raw
Goto HighScoreReSort14

Label HighScoreReSort12
TempTop13=CurrTop12
TempTop13Raw=CurrTop12Raw
Goto HighScoreReSort13

Label HighScoreReSort11
TempTop12=CurrTop11
TempTop12Raw=CurrTop11Raw
Goto HighScoreReSort12

Label HighScoreReSort10
TempTop11=CurrTop10
TempTop11Raw=CurrTop10Raw
Goto HighScoreReSort11

Label HighScoreReSort9
TempTop10=CurrTop9
TempTop10Raw=CurrTop9Raw
Goto HighScoreReSort10

Label HighScoreReSort8
TempTop9=CurrTop8
TempTop9Raw=CurrTop8Raw
Goto HighScoreReSort9

Label HighScoreReSort7
TempTop8=CurrTop7
TempTop8Raw=CurrTop7Raw
Goto HighScoreReSort8

Label HighScoreReSort6
TempTop7=CurrTop6
TempTop7Raw=CurrTop6Raw
Goto HighScoreReSort7

Label HighScoreReSort5
TempTop6=CurrTop5
TempTop6Raw=CurrTop5Raw
Goto HighScoreReSort6

Label HighScoreReSort4
TempTop5=CurrTop4
TempTop5Raw=CurrTop4Raw
Goto HighScoreReSort5

Label HighScoreReSort3
TempTop4=CurrTop3
TempTop4Raw=CurrTop3Raw
Goto HighScoreReSort4

Label HighScoreReSort2
TempTop3=CurrTop2
TempTop3Raw=CurrTop2Raw
Goto HighScoreReSort3

Label HighScoreReSort1
TempTop2=CurrTop1
TempTop2Raw=CurrTop1Raw
Goto HighScoreReSort2

Label BuildLoop
SetUserFlag(1,26,TempTop1)
SetUserFlag(2,26,TempTop2)
SetUserFlag(3,26,TempTop3)
SetUserFlag(4,26,TempTop4)
SetUserFlag(5,26,TempTop5)
SetUserFlag(6,26,TempTop6)
SetUserFlag(7,26,TempTop7)
SetUserFlag(8,26,TempTop8)
SetUserFlag(9,26,TempTop9)
SetUserFlag(10,26,TempTop10)
SetUserFlag(11,26,TempTop11)
SetUserFlag(12,26,TempTop12)
SetUserFlag(13,26,TempTop13)
SetUserFlag(14,26,TempTop14)
SetUserFlag(15,26,TempTop15)
SetUserFlag(16,26,TempTop16)
SetUserFlag(17,26,TempTop17)
SetUserFlag(18,26,TempTop18)
SetUserFlag(19,26,TempTop19)
SetUserFlag(20,26,TempTop20)

SetUserFlag(TempTop1,28,TempTop1Raw)
SetUserFlag(TempTop2,28,TempTop2Raw)
SetUserFlag(TempTop3,28,TempTop3Raw)
SetUserFlag(TempTop4,28,TempTop4Raw)
SetUserFlag(TempTop5,28,TempTop5Raw)
SetUserFlag(TempTop6,28,TempTop6Raw)
SetUserFlag(TempTop7,28,TempTop7Raw)
SetUserFlag(TempTop8,28,TempTop8Raw)
SetUserFlag(TempTop9,28,TempTop9Raw)
SetUserFlag(TempTop10,28,TempTop10Raw)
SetUserFlag(TempTop11,28,TempTop11Raw)
SetUserFlag(TempTop12,28,TempTop12Raw)
SetUserFlag(TempTop13,28,TempTop13Raw)
SetUserFlag(TempTop14,28,TempTop14Raw)
SetUserFlag(TempTop15,28,TempTop15Raw)
SetUserFlag(TempTop16,28,TempTop16Raw)
SetUserFlag(TempTop17,28,TempTop17Raw)
SetUserFlag(TempTop18,28,TempTop18Raw)
SetUserFlag(TempTop19,28,TempTop19Raw)
SetUserFlag(TempTop20,28,TempTop20Raw)
Timer(410,25,CurrUser-1,0,0)
Goto End

Label BuildComplete
SetUserFlag(0,26,0)
;SendMessageToAll("High Scores have been updated!",#MSG_SERVER)
;SendMessageToAll(GetUserName(GetUserFlag(1,26))+" is the current leader.",#MSG_SERVER)

Label End


Continue = 1