Home   Help Search Login Register  

Author Topic: AddAction Radio  (Read 1991 times)

0 Members and 1 Guest are viewing this topic.

Offline Captain

  • Members
  • *
AddAction Radio
« on: 11 Jun 2007, 10:50:18 »
Thankyou Mr Peanut, I hope to submit this to the Missions Depot at some point. It's based on the BAS_f Framework and uses IgorDrugov'(sp?) Platoon Control Panel among other scripts. It's a small scale coop mission for about 6 player as Igor' PCP has issues on a dedicated server, that and I have few real life ArmA players to LAN with.  So for the same mission but a different script (of which I have no reference script) I was hoping you could whip up a small script that would check when unit A was within 5 meters of unit B and that unit B has the item "MAP_Radio" in his inventory, all things being true unit A should then have an addaction assigned that says something like "Platoon Control", once clicked it should launch this line...

Code: [Select]
[] exec "PCP\Client\DlgControl.sqs"
I'm sorry I'm a bit scripting crap. I know how to use them and have modified many but trying to write them myself... well it's like a monkey attempting shakespeare.  :(

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: AddAction Radio
« Reply #1 on: 12 Jun 2007, 16:40:36 »
It will work only for units in the same group. In init for each playable unit:
Code: [Select]
nul = [this] execVM "radiocheck.sqf"If you need it to JIP combatible then you need to add that code line to your init.sqf/sqs instead.

Script radiocheck.sqf
Code: [Select]
if (isPlayer _this) then
{
   _grp = group player;
   while {TRUE && alive player} do
   {
      waitUntil {{player distance _x < 5  && alive _x && "MAP_RADIO" in weapons _x && _x != player  && alive player} count units _grp > 0};
      radioID = player addAction["Use Radio","PCP\Client\DlgControl.sqs", [], 0, false, false, ""];
      waitUntil {{player distance _x < 5  && alive _x && "MAP_RADIO" in weapons _x && _x != player  && alive player} count units _grp < 1};
      player removeAction radioID;
    };
};

Hopefully, the dialog will open quickly enough to prevent multiple instances i.e. player clicks on the actio nagain beore dialog has opened.

     
« Last Edit: 14 Jun 2007, 19:29:04 by Mr.Peanut »
urp!

Offline Captain

  • Members
  • *
Re: AddAction Radio
« Reply #2 on: 13 Jun 2007, 13:02:22 »
hmmm, no joy Mr.Peanut. I get an 'Error invalid number in expression C:\Docum..........\ArmA\MPMissions\missionname\radiocheck.sqf Line1' :dunno:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: AddAction Radio
« Reply #3 on: 13 Jun 2007, 15:20:38 »
Arf! I see one problem! I was assuming that each unit would be filled by a player.

Change init line to:
Code: [Select]
nul = this execVM "radiocheck.sqf"
And change first line in the script to:
Code: [Select]
if (isPlayer _this) then
I do not think this is the bug causing the error message but it is a bug none the less. Have made these changes to my previous post.
« Last Edit: 14 Jun 2007, 19:26:57 by Mr.Peanut »
urp!