Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=======|Begin Scoreboard Script===========
- /*
- Line ID's for scoreboard textures
- Blue = 1-3
- Red = 4-6
- Green = 7-9
- Yellow = 10-12
- Make sure the digits are properly orientated from the player's view
- */
- Script "ScoreBoard" Open
- {
- Int BlueScoreCache;
- Int RedScoreCache;
- Int GreenScoreCache;
- Int YellowScoreCache;
- int Digit_1;
- int Digit_2;
- int Digit_3;
- While(True)
- {
- //First, check if any score has been updated.
- if
- (
- BlueScoreCache == GetTeamProperty(0,TPROP_PointCount)
- && RedScoreCache == GetTeamProperty(1,TPROP_PointCount)
- && GreenScoreCache == GetTeamProperty(2,TPROP_PointCount)
- && YellowScoreCache == GetTeamProperty(3,TPROP_PointCount)
- ){delay(1); Continue;}
- //one of the scores have been updated, update the textures in response
- for(int T = 0;T < 4; T++)
- {
- if(GetTeamProperty(T,TPROP_PointCount) > 999)
- {
- Digit_1 = getNthDigit(GetTeamProperty(T,TPROP_PointCount),10,1);
- Digit_2 = getNthDigit(GetTeamProperty(T,TPROP_PointCount),10,2);
- Digit_3 = getNthDigit(GetTeamProperty(T,TPROP_PointCount),10,3);
- }
- Else
- { //Scoreboards max out at 999 and will go no higher
- Digit_1 = 9;
- Digit_2 = 9;
- Digit_3 = 9;
- }
- SetLineTexture(1+(3*T),SIDE_FRONT,TEXTURE_MIDDLE,Strparam(s:TeamTex(T),i:Digit_1));
- SetLineTexture(2+(3*T),SIDE_FRONT,TEXTURE_MIDDLE,Strparam(s:TeamTex(T),i:Digit_2));
- SetLineTexture(3+(3*T),SIDE_FRONT,TEXTURE_MIDDLE,Strparam(s:TeamTex(T),i:Digit_3));
- }
- // Update the cache values and resume from the top
- BlueScoreCache = GetTeamProperty(0,TPROP_PointCount);
- RedScoreCache = GetTeamProperty(1,TPROP_PointCount);
- GreenScoreCache = GetTeamProperty(2,TPROP_PointCount);
- YellowScoreCache = GetTeamProperty(3,TPROP_PointCount);
- delay(1);
- }
- }
- Function Str TeamTex (int team)
- {
- Str output;
- Switch(team)
- {
- Case 0: output = "BLUESC"; Break;
- Case 1: output = "REDSC"; Break;
- Case 2: output = "GREESC"; Break;
- Case 3: output = "YELLSC"; Break;
- }
- return output;
- }
- // Carefule, there be maths down here, scary stuff
- function int getNthDigit (int number, int base, int n)
- {
- int result = ((number / pow(base, n - 1)) % base);
- return result;
- }
- function int GetTotalDigits (int number)
- {
- int result;
- if (number >= 100) {result = 3;}
- else if (number >= 10) {result = 2;}
- else {result = 1;}
- return result;
- }
- function int pow (int x, int n)
- {
- int y = 1;
- while (n-- > 0) y *= x;
- return y;
- }
- #define MATH_E 178145
- function int logN (int x, int base)
- {
- if (!base) base = MATH_E;
- int integer = 0;
- if (x < 1.0 && base < 1.0) return 0;
- while (x < 1)
- {
- integer -= 1;
- x = FixedMul (x, base);
- }
- while (x >= base)
- {
- integer += 1;
- x = FixedDiv (x, base);
- }
- int partial = 0.5;
- x = FixedMul (x, x);
- int decimal = 0;
- while (partial > 1) // Actually 0.0000152587890625
- {
- if (x >= base)
- {
- decimal += partial;
- x = FixedDiv (x, base);
- }
- partial = FixedMul (partial, 0.5);
- x = FixedMul (x, x);
- }
- return ((integer << 16) + decimal);
- }
- //=======|End Scoreboard Script===========
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement