Two Player Score Displays? [SOLVED]

Started by Play_Pretend, Sun 16/12/2007 22:34:13

Previous topic - Next topic

Play_Pretend

Hey all...I've read the manual and searched the threads and experimented, and I'm still lost.  :(  I'm trying to display two GUIs, to continuously show two player scores on the screen, for a game show.  For example, I've tried using this:

    int scorered = (scorered + 18);
    rscore.Text = String.Format("%d", scorered);

To add 18 points to the Red Team's score.  The GUI text does change to 18.  But then if I repeat the command to add another say, 44 points, it just changes it to 44, instead of adding them together to make 62.  Is the String.Format command just resetting it to the new value every time?

How can I make both scores show continuously in their GUI windows, and then be able to add points to either depending on who answers the question correctly?  Please help, I've been tearing my hair out over this for five hours now. :)

Ashen

#1
If that's exactly what you're doing, you're redeclaring the varaible each time - meaning it's set to 0 Plus the new score, not the old score plus the new score. Declare the variable (int scorered;) at the top of the script, and just add to it when points are scored, and it should work fine. That's just basic variable handling, nothing to do with String.Format.

Having both scores displayed should just be a case of having a line to set each, e.g.:
Code: ags

rscore.Text = String.Format("%d", scorered);
bscore.Text = String.Format("%d", bluescore);


You can either call that every time points are added, or stick it in repeatedly_execute to have it automaticaly update.
I know what you're thinking ... Don't think that.

Play_Pretend

Ah!  Sweet!  I get it...okay, I deleted the String.Format lines from the questions, and just plugged in those two like you said in Repeatedly Execute.  I stuck the two redscore and bluescore ints at the very top of the Global Script.  Then I just use the

   scorered = (scorered + 44);

Or whatever line whenever someone gets a correct answer, and it works like a charm!  Thanks a ton Ashen!!! :)

Ahhh...blood pressure...falling...

monkey0506

Just FYI, you don't have to do "scorered = (scorered + 44);", you can use the syntax "scorered += 44;" instead. It's a bit simpler way of increasing the current value of a variable.

SMF spam blocked by CleanTalk