Home   Help Search Login Register  

Author Topic: Checking In game Status  (Read 4020 times)

0 Members and 1 Guest are viewing this topic.

Offline FADM Stern GNSF

  • Members
  • *
Checking In game Status
« on: 31 Mar 2009, 20:51:51 »
Does anyone know if there is a way in Arma to get in game stats when the happen (like the end debrief screen that shows you killed 2 rifleman, 1 sniper, etc). Is there any way of accessing this data when the game is running.

For example, is the a way to check if "player 1 killed enemy 12". I know we can check for enemy 12 being dead, but can we tell tell WHO killed him. I know the game tracks this for the after mission screen, I just need to know if there is a way to check this during the game. I have researched all the Arma command set and cant find anything that looks like it will do this.

I would greatly appreciate anyone that can help me in any way, even anyone who has idea's how to do this.

« Last Edit: 01 Apr 2009, 21:56:56 by FADM Stern GNSF »

Offline Rommel92

  • Members
  • *
Re: Checking In game Stata
« Reply #1 on: 31 Mar 2009, 21:15:25 »
Maybe you could find the dialog its in and show it, but I doubt the data is there until after the game ends.  :dry:

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Checking In game Stata
« Reply #2 on: 31 Mar 2009, 21:56:44 »
Probably with armalib.

Or count the kills yourself during the mission,
if thats what you are looking for.

Mandoble has written a nice script to even detect normally not counted kills.

Offline ModestNovice

  • Members
  • *
Re: Checking In game Stata
« Reply #3 on: 01 Apr 2009, 05:45:49 »
you can track who kills who through a killed event handler.

so, in the mission you must create a file called init.sqf

in the init.sqf you put this:

Code: [Select]
if (isServer) then
{
     Killed_Array = [];
     publicVariable "Killed_Array";
}
else
{
     _Player_Killed =
     {
          _killed_player = _this select 0;
          _killer = _this select 1;

          Killed_Array = Killed_Array + [str _killed_player + "was killed by " + str _killer];
          publicVariable "Killed_Array";
     };

player addEventHandler ["killed", {_this spawn _Player_Killed}];
};

« Last Edit: 01 Apr 2009, 05:48:39 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline FADM Stern GNSF

  • Members
  • *
Re: Checking In game Stata
« Reply #4 on: 01 Apr 2009, 15:39:11 »
Thank you very much for the help DaChevs, as after digging in the eventHandler list I saw this. It sure makes it a lot easier seeing a code example as you have listed, and I great ly appreciate that.

One question I have left is the fact that the "hit" and "Kill" EH is local. I am hoping there is a way to make it global so the results are as I expect. This is what I mean;

All games I play are Multiplayer, so lets say 4 people are playing. All will have the mission (which would contain the scripting), but how to sync all machines. From what I read on the forum (dont know if its right), the script runs for the machine for the "victum", which in my case should be all, as ALL the victums will be AI (unless a team kill, which I can check for later). I want to create an array, actually just as you have done, to assemble a text list of all the "XX was killed by YY", BUT need ALL human Machines (4 in this case) to have the exact same list created.

After readin some posts on EH, Im not sure if this would happen, or if I would have to "lump together" all the arrays for ALL machine (please bear with me and my limited knowledge). If I can manage to make an array on ALL players machines, then most of my work is done, and all that would be left would be to dump it to a file on that persons machine (at game termination).

Thank you for all your help, and if I get this actually done and working, I can pretty it up and post it for any other people wanting to do this im MP games.

Update:

I tried the above but had no luck with it working for me. After looking at the code, I think I may know why.
While ALL games I will be making are Multiplayer, they are ALWAYS hosted by one of the players (dont use a dedicated server). Since I test them myself (I go in as host), I think that I will never see anything due to the fact the the script would see ME as the host.

if (isServer) then
{
     Killed_Array = [];
     publicVariable "Killed_Array";
}

I am really new at this, so placed a line in the script to try to output the data, but again, I think that it sees me as the host, so never executes anything in the "else" section.

Im going to try to see if I can get lucky and stumble on a fix, but if you can give me any ideas I would be gratefull

Thank you
« Last Edit: 02 Apr 2009, 19:32:11 by FADM Stern GNSF »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Checking In game Status
« Reply #5 on: 03 Apr 2009, 02:54:32 »
The common answer to the question of how to only run code on the server is:
Code: [Select]
if (isServer) then { };
Which is great but then scripters assume that the way to run code only on a client is:
Code: [Select]
if (not isServer) then { };
which will only work on a dedicated server, since sometimes the client is also the server (SP or hosted MP). The correct way to work these things out (assuming code in init.sqf or execVMed from an object init, or we need to start worrying about the effects of JIP):
Code: (only run on server) [Select]
if (isServer) then { };
Code: (only run on client) [Select]
if (not isNull player) then { };
Code: (only run on dedicated server) [Select]
if (isServer and isNull player) then { };
Code: (only run on dedicated client) [Select]
if (not isServer) then { };
Generally, you will only want to run things based on whether it is a client (such as particle effects) or if it is a server (such as commanding the enemy AI). Because these two states can overlap, you need to use two separate clauses, rather than a simple else.
« Last Edit: 03 Apr 2009, 03:01:29 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Checking In game Status
« Reply #6 on: 03 Apr 2009, 02:58:37 »
ahh true true.

Yeah the MP Handling of Killed_Array should update the variable for all JIP players. If not just let me know, and I will make it ;).

Sry I havent hopped on here for a bit, as to your pm. To show the contents of Killed_Array simply use:
Code: [Select]
hint str Killed_Array;
DaChevs
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Checking In game Status
« Reply #7 on: 03 Apr 2009, 03:06:43 »
You don't need to update the variable specially for JIP players. JIP players are automatically synced with the last publicVariabled values, however this value will not be synced until a few seconds after a JIP player starts up scripts. Thus,
Code: (Avoid using a networked value on a dedicated client until we know it has been successfully synced) [Select]
if (not isServer) then
{
  waitUntil { not isNil "Killed_Array" }; // Wait until the value is synced
};
// Now safe to use the synced value of Killed_Array
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Checking In game Status
« Reply #8 on: 03 Apr 2009, 03:19:11 »
ahhhhh, sweet, very useful.

Thanks Spooner, this helps me alot as in my mod Ive lots of arrays, and I always thought I had to update JIP players through onplayerConnected. So saves me a hastle, thanks man :).
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline FADM Stern GNSF

  • Members
  • *
Re: Checking In game Status
« Reply #9 on: 03 Apr 2009, 22:36:34 »
Well I want to thank you all very much, as I may be able to program php, but the syntax in arma sure takes some getting used to (must be my old brain). I have used a simple form of the script that DaChevs listed just to try to get familiar with the syntax, and created a small script that would let me "see" how I was making out. (tried the one as you listed it, but couldnt make it work for me, so i thought going back to square one might help me understand). It is very basic, and simply shows "who killed who" in the form of a hint. I set it up so the hint shows the "players name[for real people] and AI[a name the game must assign]. Here is what I have;

---------ALL units (AI and human) have the follwoing call in the INIT spot for the unit - this addEventHandler ["killed", {_this exec "killed.sqs"}]

------ Placed in a file called killed.sqs.

     Killed_Array = [];
      publicVariable "Killed_Array";

          _killed_player = _this select 0;
          _killer = _this select 1;
        _killer_name = name _killer;
        _killed_name = name _killed_player;
        _killer_side = side _killer;
        _killed_side = side _killed_player;
        killed_now = [str _killed_name + " was killed by " + str _killer_name];
          Killed_Array = Killed_Array + killed_now;
          publicVariable "Killed_Array";
        hint format ["%1",Killed_Array];
-----

Now, while this works in the editor, and when I host a MP game, it only shows on my machine, not any other human players machine.

Here is what I am actually trying to do, which is esentially to create a "debrief.txt" type log file, detailing the game events. For my purposes, the follwoing can be stipulated;

- Our missions will NEVER have a JIP, only those at start will play.
- The human side (Bluefor) will consist of ONLY humans, and while some AI may be present [doing something on the side], NO AI will ever be controled by humans.

So, to make this debrief file, each time something is killed, the following needs to be saved somehow done;

Create a string --- Time of the game - Player-x (or object) was killed by Player-y - (flag Civilian kill or friendly kill)

Once I have that, I need to do one of the follwoing two things (if either is even possible)

1 - place this string as an entry in an array (must be size vaiable). The array will be appended [new entry] for every occurance. At the end of the game, this array would contain as many lines as kills, and detail ALL that happened in the game. This array would then need to somehow be written to a file (debrief.txt or similar file) on EACH real players machine (game like Black Shark, Falcon 4, Dangerous water all do this as part of the game, Ghost Recon does not).

OR

2 - Append the string to a text file like above)

Now, this file needs to be created on ALL human player machines, and the file should be IDENTICAL on all machines. I hope that helps explain a bit on what I am trying to do, and if anyone can help me with any part of this I would be very greatfull.

Thank you all very much
« Last Edit: 03 Apr 2009, 22:40:05 by FADM Stern GNSF »

Offline ModestNovice

  • Members
  • *
Re: Checking In game Status
« Reply #10 on: 05 Apr 2009, 22:10:58 »
creating a text file would require new commands.
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Checking In game Status
« Reply #11 on: 05 Apr 2009, 23:47:20 »
Creating a text file would require Armalib.

However, there is no need to create a new file in order to show the stats, so I think you are trying to complicate things unnecessarily.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline FADM Stern GNSF

  • Members
  • *
Re: Checking In game Status
« Reply #12 on: 06 Apr 2009, 22:50:02 »
You are  correct, and I am working on trying to get ArmAlib to work for me (seems I am having problems getting the DB file to create).

I am actually not trying to make this overly complicated, but the #1 requirement is to "create a txt file". Since Our group plays Multiplayer missions and reports the games on the web site (for points, rank, awards etc), a text file would make life so much easier. The other games we play do this (Dangerous Waters, Black Shark, Falcon 4), except Ghost recon. For GR (and Arma if I cant make this work) we have to take a screen shot of the after action screen, and use that to fill out the reports.

So, once I get Armalib working (hopefully someone that uses it will see my post and help), it would be a simple matter to "dump" each killed event into a database. Once that is done, I would be able to extract the data (probably via php on site) and convert it for the web site entry system (this is what I did with the log file created by Black Shark).

Thanks again for all of your help, as it seems each day I get a tiny bit closer to making it work. With all of your posts and suggestions, I am learning Arma scripting a lot faster than I was just trying to read the manuals and scripting docs. Nothing beets examples for clearing up the "fuzzyness" in this scripting language.

Thank you

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Checking In game Status
« Reply #13 on: 12 Apr 2009, 15:32:27 »
Sorry, I thought you just meant stats at the end of the game debriefing. Yes, for web stats you would either need to write to a file or database (I think the latter would be a lot better choice).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Rommel92

  • Members
  • *
Re: Checking In game Status
« Reply #14 on: 13 Apr 2009, 05:07:55 »
...Since Our group plays Multiplayer missions and reports the games on the web site (for points, rank, awards etc), a text file would make life so much easier...

Perhaps use the console.log to get the amount of infantry kills, tank kills etc and total end score of the player, it doesn't specify unit type, name or side, but just your overall score, after every game.
Depending on your server configuration, it may have a different name.

However if this is for a PvP based scenario (which is what it seems), then your original idea may be the way to go; but why a text file, just have a dialog show you all the data at the end so you can copy paste it.