PDA

View Full Version : To get a DF mission to display the "score"?



No601_Swallow
Jan-29-2014, 09:54
Sorry again to be asking for help and contributing nothing. But I'm seriously crap at scripting.

I want my DF server to display the ongoing "score" after each aircraft is shot down. (This is just for my sqn's little team deathmatch knockabout sessions before we fly our ops, but I'd like to make it a bit more competitive).

What I'd like is for the script to keep a count of the red or blue aircraft that are destroyed, and then, after each aircraft is destroyed, display those counts in the HUD, eg. "Red: 3; Blue: 4".

This is all that I've got so far (mostly lifted from one of Bolox's scripts, I think):


using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;


public class Mission : AMission
{
int cRed = 0;
int cBlue = 0;




public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> initiatorList)
{
if (actor is AiAircraft)
{
if (actor.Army() == 1)
{
cRed++;
GamePlay.gpHUDLogCenter("Red Team:" cRed "Blue Team:" cBlue);
}

if (actor.Army() == 2)
{
cBlue++;
GamePlay.gpHUDLogCenter("Red Team:" cRed "Blue Team:" cBlue);
}
}
}



}

Obviously, it doesn't work, and probably it's completely wrong. But since I really don't understand how to manipulate counter function thingies (hell, I don't even really understand chucking text up using the gpHUDLogCenter), I don't have a clue why.:(

Any help or hints would be greatly appreciated!

Cheers!

bolox
Jan-29-2014, 15:31
First off I've no idea about MP stuff.
But this 'works ' in sp

using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;

public class Mission : AMission
{
int cRed = 0;
int cBlue = 0;




public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> initiatorList)
{
if (actor is AiAircraft)
{
if (actor.Army() == 1)
{
cRed++;
GamePlay.gpHUDLogCenter(String.Format("Red Team - {0} ", cRed)+String.Format(" Blue Team - {0} ", cBlue));
//GamePlay.gpHUDLogCenter("Red Team:" cRed "Blue Team:" cBlue);
}

if (actor.Army() == 2)
{
cBlue++;
//GamePlay.gpHUDLogCenter("Red Team:" cRed "Blue Team:" cBlue);
GamePlay.gpHUDLogCenter(String.Format("Red Team - {0} ", cRed)+String.Format(" Blue Team - {0} ", cBlue));
}
}
}



}

You were trying to put an integer (cRed) in a string hudlog message

Salmo
Jan-29-2014, 17:55
Your counter function is correct, your HUD display line needs some small changes. Notice how the integer counter is converted to a string for the display & you use the + operator to concatenate strings ....


using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;


public class Mission : AMission
{
int cRed = 0;
int cBlue = 0;

public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> initiatorList)
{
if (actor is AiAircraft)
{
if (actor.Army() == 1)
{
cRed++;
GamePlay.gpHUDLogCenter("Red Team: " + cRed.ToString() + " Blue Team: " + cBlue.ToString());
}

if (actor.Army() == 2)
{
cBlue++;
GamePlay.gpHUDLogCenter("Red Team: " + cRed.ToString() + " Blue Team: " + cBlue.ToString());
}
}
}
}

No601_Swallow
Jan-30-2014, 04:06
Gents, that's just brilliant!:thumbsup::thumbsup::thumbsup:

In my dreams, I picture a forum filled with helpful knowledgeable enthusiasts who share their expertise freely and generously... And lo and behold! It's the ATAG FMB forum! Ashtonishing, really!

And that tough little CloD cactus-flower (or whatever) opens its petals a little further... In my own squadron (http://www.tangmerepilots.co.uk/), recently, thanks to all the TF work, as well as little workarounds we've discovered, even die-hard Clod-o-phobes have been coming round, and slowly we're discovering more and more cool things to do! And usually it's worth all the scripting/mission-building tooth-gnashing and hair-tearing!

Many thanks again, Bolox and Salmo. :salute:

Osprey
Feb-14-2014, 03:05
.....and doesn't this just expose the damage that all that negative propaganda did to COD. It is waaaay ahead of its time, the power of the scripting in the FMB is immense.