Jump to content

{ACS} Trouble with the Points board.in zandronum


doomjoshuaboy

Recommended Posts

hi guys
I'm having trouble with the scoreboard when playing a doom level. i added the first bot and its makes the same name then i added the second bot and its worked but not the same user.



and heres my code:

#library "TEMP"
#include "zcommon.acs"

#define DEATH_PENALTY 100

#define MAX_PLAYERS 32
int score[MAX_PLAYERS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int sorted[MAX_PLAYERS] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32};

script 4 ENTER
{
  int addPoints = CheckInventory("ScoreItem2");
  if (addPoints > 0)
  {
    score[PlayerNumber()] += addPoints;
    TakeInventory("ScoreItem2", addPoints);
  }
  SetHudSize(1920, 1080, true);
  int y = 595.2;
  int best = GetBestPlayerNumber();
  for (int i = PlayerCount() - 1; i >= 0; i--)
  {
    if (i == best)
    {
      HudMessage(i:(i+1), s:" ", n:i, s:": ", i:score[i]; HUDMSG_PLAIN, 103 + i, CR_GOLD, 9.1, y, 0);
    }
    else
    {
      HudMessage(i:(i+1), s:" ", n:i, s:": ", i:score[i]; HUDMSG_PLAIN, 103 + i, CR_GREEN, 9.1, y, 0);
    }
    y -= 16.0;
  }
  y -= 3.0;
  HudMessage(s:"Points:"; HUDMSG_PLAIN, 102, CR_WHITE, 9.1, y, 0);
  Delay(5);
  Restart;
}

script 5 DEATH
{
  score[PlayerNumber()] -= DEATH_PENALTY;
}

script 6 UNLOADING
{
  for (int k = 0; k < PlayerCount(); k++)
  {
    sorted[k] = k;
  }
  
  // good old bubble sort
  for (int i = 0; i < PlayerCount() - 1; i++)
  {
    bool change = false;
    for (int j = 0; j < PlayerCount() - 1; j++)
    {
      if (score[sorted[j]] < score[sorted[j+1]])
      {
        int x = sorted[j];
        sorted[j] = sorted[j+1];
        sorted[j+1] = x;
        change = true;
      }
    }
    if (!change) break;
  }
  
  Print(s:"Final scores");
  for (int l = 0; l < PlayerCount(); l++)
  {
    // at this point, players are no longer in the game, so we can't
    // print their real names. So we just print "player" and a number
    Print(i:(l+1), s:". player ", i:(sorted[l] + 1), s:": ", i:score[sorted[l]]);
  }
}

function int GetBestPlayerNumber(void)
{
  int best = 0;
  int maxscore = score[0];
  for (int i = 1; i < PlayerCount(); i++)
  {
    if (score[i] > maxscore)
    {
      best = i;
      maxscore = score[i];
    }
  }
  return best;
}

script 123 RESPAWN
{
GiveInventory("TemporaryProtectionGiver",1);
GiveInventory("MegaSphere",1);
}
cheers
Doomjoshuaboy

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...