Home   Help Search Login Register  

Author Topic: JIP Action Woes - SOLVED!  (Read 1483 times)

0 Members and 1 Guest are viewing this topic.

Offline somerville

  • Members
  • *
JIP Action Woes - SOLVED!
« on: 12 Aug 2008, 19:03:44 »
Hi,

I've been having a few problems with a mission I am making, -{SAHRANIVILLE}-, which is an RPG mission. Currently, I've had lots of help from BIS Forums, -{GOL}- clan, and numerous other individuals, and now I'm hoping you guys might be able to share some wisdom with me for my latest problem - JIP, and respawning with actions. Currently, the following script, actions.sqf, deals with adding actions to units:

Code: [Select]
_array = [c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22];

waitUntil {alive player};

if (side player == west) then
{
  {
  _x addaction ["Arrest Civilian", "arrest.sqs"];
  _x addaction ["Fine Civilian", "fine.sqf"];
  _x addaction ["Disarm Civilian", "disarm.sqf"];
  _x addAction ["Check Car Licence", "clicence.sqs"];
  _x addAction ["Check Gun Licence", "glicence.sqs"];
  } foreach _array;
  player addaction ["Stats", "stats.sqf"];
}
else
{
  player addaction ["Hands Up", "HandsUp.sqs"];
  player addaction ["Stats", "stats.sqf"];
  player addaction ["Dance!", "dance.sqs"];
};

This script is called from the init.sqf by the following code:

Code: [Select]
nul=[] execVM "actions.sqf";

Now, the problem we have here is that the actions don't appear for JIP players or those who have respawned. For the latter, a fellow project member proposed the following, was_killed.sqf:

Code: [Select]
_unit = _this select 0;

waitUntil {PlayerRespawnTime == 0};

if (side player == west) then
{
  _unit addaction ["Arrest Civilian", "arrest.sqs"];
  _unit addaction ["Fine Civilian", "fine.sqf"];
  _unit addaction ["Disarm Civilian", "disarm.sqf"];
  _unit addAction ["Check Car Licence", "clicence.sqs"];
  _unit addAction ["Check Gun Licence", "glicence.sqs"];
  player addaction ["Stats", "stats.sqf"];
}
else
{
  player addaction ["Hands Up", "HandsUp.sqs"];
  player addaction ["Stats", "stats.sqf"];
  player addaction ["Dance!", "dance.sqs"];
};

exit

... and this is called from init.sqf with the following code:

Code: [Select]
player addEventHandler ["killed", {_this execVM "was_killed.sqf"}];

Now, the problems here are that JIP still doesn't work, nor does respawning with the actions. The worry I have is that even if actions.sqf did work for JIP players, it would add duplicate actions to those who've already got them, if that makes sense. We did toy with the idea for JIP players of somehow recounting the array, then only applying the actions to 'null' players, since 'player' is always null when it first connects to the server.

I really hope you guys can share some wise words on this problem - I don't really want to have seperate scripts for the actions like in CrimeCity for OFP, or the original version of -{SAHRANIVILLE}-... any help is really appreciated here chaps :)
« Last Edit: 14 Aug 2008, 13:02:48 by somerville »

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re: JIP Action Woes
« Reply #1 on: 12 Aug 2008, 21:33:51 »
This seems to do the trick. In addition to working with JIP, it will keep track of and remove action menu items when
players and civilians die.

EDIT:To increase readability of the thread, I've made the long-winded "action.sqf" code that used to be here an attachment instead.

(It is assumed that "actions.sqf" is execVM:ed on all machines from the init.sqf)

EDIT: Removed the older version of the init.sqf
« Last Edit: 13 Jul 2009, 14:16:16 by savedbygrace »

Offline somerville

  • Members
  • *
Re: JIP Action Woes
« Reply #2 on: 13 Aug 2008, 19:45:53 »
Thanks for the fast and helpful Reply Killswitch :) I'm still having problems though. Here's what happens:

1) If both players started at the same time, then when the civilian respawned, they had Dance & Stats actions, but not handsup. West players didn't have Arrest, Fine, Check after the civilian respawned, but did before.

2) When the civilian JIP'd, they had all actions at the start and all actions when they respawned. The West unit had the Arrest, Fine, Check etc actions before the unit died, but not when the unit respawned.

So basically, I'm stuck. I ran actions.sqf by the following code:

Code: [Select]
nul=[] execVM "actions.sqf";

And I cut the following section from your below, and pasted it in my init.sqf before the bit which executes the actions.sqf:

Code: [Select]
T_INIT = false;
T_Server = false; T_Client = false; T_JIP = false;

T_MP=!(missionName=="");

if (isServer) then
{
  T_Server = true;
  if (!(isNull player)) then { T_Client = true };
  T_INIT = true;
} else {
  T_Client = true;
  if (isNull player) then
  {
      T_JIP = true;
      [] spawn { waitUntil { !(isNull player) }; T_INIT = true };
  } else {
      T_INIT = true;
  };
};

So yeah.. still a tad stuck here :( But thanks for the help so far chap! Hope you can help again :)

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re: JIP Action Woes
« Reply #3 on: 13 Aug 2008, 22:27:12 »
Thanks for the fast and helpful Reply Killswitch :) I'm still having problems though. Here's what happens:

1) If both players started at the same time, then when the civilian respawned, they had Dance & Stats actions, but not handsup. West players didn't have Arrest, Fine, Check after the civilian respawned, but did before.

2) When the civilian JIP'd, they had all actions at the start and all actions when they respawned. The West unit had the Arrest, Fine, Check etc actions before the unit died, but not when the unit respawned.

So basically, I'm stuck.

[...]

So yeah.. still a tad stuck here :( But thanks for the help so far chap! Hope you can help again :)

Ah, OK. Could you tell me a bit more about the mission?

1: Are all civilian units c1-c22 playable?
2: Is it correct that there are only either west or civilian side players?
3: What kind of respawn does the mission have ("instant","base","group" etc...)
4: Can there be any civilian AI units in the c1-c22 range running about during the mission, or are there only as many cX units as there are civilian players?
5: Do you have disabledAI=1; in the description.ext file?

In any case, I've attached a revised "actions.sqf" you might want to try. :scratch:
« Last Edit: 14 Aug 2008, 01:55:06 by Killswitch »

Offline somerville

  • Members
  • *
Re: JIP Action Woes
« Reply #4 on: 14 Aug 2008, 10:11:46 »
Hey Killswitch,

Once again, thanks for the prompt reply and help (Dude, do you sleep!? - Just kidding). To answer your questions:

1) All civilian units, C1 - C22, are playable.
2) There are currently only West or Civilian players - no SLA or RACS, and I don't plan to include them either :)
3) It's "base" respawn, the one where you respawn at a marker - "Respawn_West" and "Respawn_Civilian" are used.
4) I guess there could be AI for C1 - C22 that aren't being played, but the problem there is that there are units just standing about doing nothing, so I'd like to avoid this if it's possible?
5) Nope, no DisabledAI in description.ext :)

Edit: Eeeeep! Killswitch I could have your children! It works! I love you!
« Last Edit: 14 Aug 2008, 13:01:57 by somerville »