Author Topic: Saving score  (Read 1110 times)

0 Members and 4 Guests are viewing this topic.

Offline Mercury92

  • Camper
  • ***
  • Posts: 284
Saving score
« on: April 07, 2008, 10:05:16 am »
Hey, I have next problem with saving score.
for e.g: When players are moving to another teams, then team (Alpha,Bravo) scores will reset. How to avoid that, How can I save scores and then load.
Additional information:
Game mode: INF
[saw]  on 1.5.1

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Saving score
« Reply #1 on: April 07, 2008, 10:40:09 am »
I thought this was fixed in the last version? oh well..
This is not too difficult, i can help you on the way, but i would consider this a good exercise to learn a bit of scripting. What you need to do is store the scores of all player in game, use an Array for that. Every time a player gets point you will need to update that array. This will be: OnPlayerKill and OnFlagScore. You can count the points yourself but you can also use GetPlayerStat to find out what the current score is of each player.
Now as soon as a player changes teams he will lose his score you say? No problem, you have them stored in you array. So when OnJoinTeam you copy the right amount from the array to the score of the player, using SetScore. Tadaaa.
Just don't forget to set the score in your array back to zero if a player leaves or joins the game. GOOD LUCK :D

Maybe someone will code this for you, but you wouldn't learn anything  ;)
Come join: EliteCTF
Listen to: My Music

Offline Mercury92

  • Camper
  • ***
  • Posts: 284
Re: Saving score
« Reply #2 on: April 07, 2008, 11:28:31 pm »
So, When All players are moving to Bravo for e.g Then team scores will be loss.  JFK Could not help me. (We talked by PM)

So? Any help?!
[saw]  on 1.5.1

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Saving score
« Reply #3 on: April 08, 2008, 06:34:25 am »
To clarify, i thought merc was talking about player-scores, he was talking about team-scores. That should be even easier.
Here's the code that merc sent me:

Code: [Select]
var
  score: array[1..2] of integer;

procedure MoveAllToBravo();
var i: Integer;
begin
  score[1] := AlphaScore; // saving alpha score
  score[2] := BravoScore; // saving bravo score

(Moving all to Bravo team)
 
//Restoring score
  AlphaScore := score[1];
  BravoScore := score[2];
end;

I don't see why it shouldn't work...
Come join: EliteCTF
Listen to: My Music

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Saving score
« Reply #4 on: April 08, 2008, 02:34:53 pm »
To clarify, i thought merc was talking about player-scores, he was talking about team-scores. That should be even easier.
Here's the code that merc sent me:

Code: [Select]
var
  score: array[1..2] of integer;

procedure MoveAllToBravo();
var i: Integer;
begin
  score[1] := AlphaScore; // saving alpha score
  score[2] := BravoScore; // saving bravo score

(Moving all to Bravo team)
 
//Restoring score
  AlphaScore := score[1];
  BravoScore := score[2];
end;

I don't see why it shouldn't work...
AlphaScore and BravoScore variables arn't the same variables that the server uses for the team scores (i think), they are only some other variables that are set along with the real value.. Setting AlphaScore and BravoScore will do nothing except change the variable. (complete guess, but makes sense, at least to me ^^)
To actually change the scores, you godda use procedure SetTeamScore(Team: Byte; Score: Integer);.

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Saving score
« Reply #5 on: April 08, 2008, 03:46:07 pm »
To actually change the scores, you godda use procedure SetTeamScore(Team: Byte; Score: Integer);.
lol no wonder it didnt work =P

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Saving score
« Reply #6 on: April 08, 2008, 06:05:14 pm »
I could have sworn I posted this before, in the other thread... Ugh, I fail.

Code: [Select]
procedure ChangeTeams;
var
  i: Integer; // used for loops
  j, k: Integer; // used for team scores
  holder: Array[1..32] of Integer; // store scores
begin

  // first, save the score in an array
  for i := 1 to 32 do
    if GetPlayerStat(i, 'Active') = true then
      holder[i] := GetPlayerStat(i, 'Kills');

  // And team scores
  j := AlphaScore;
  k := BravoScore;

  // then, move all to bravo
  for i := 1 to 32 do
    if GetPlayerStat(i, 'Active') = true then
      Command('/setteam2 ' + inttostr(i));

  // Move random player back to alpha
  while AlphaPlayers < 1 do
    Command('/setteam1 ' + inttostr(Random(1, 32)));

  // Set the scores again
  for i := 1 to 32 do
    if GetPlayerStat(i, 'Active') then
      SetScore(i, holder[i]);

  // Set team scores
  SetTeamScore(1, j);
  SetTeamScore(2, k);

end;