Jump to content
Sign in to follow this  
Flightster

Making an "addAction" repeat itself??

Recommended Posts

Hi guys,

I'm currently using Dr_Eyeball's team status dialog, and everything is working like it should.. The only problem I'm having is that whenever a player respawns, they no longer have the "Team status" dialog option in their action menu. How would I go about making it so that the action becomes available again on each respawn?

line in init.sqf:

_Action = player addAction ["Team Status", "Scripts\TeamStatusDialog\TeamStatusDialog.sqf", [["Page", "Team"], "AllowPlayerInvites", "HideOpposition"], 0, false, true,""];

TeamStatusDialog.sqf:

http://members.lycos.nl/bwf2004/teamstatusdialog.txt

This is what I have tried (doesn't work, but thanks for your attempt Dr_Eyeball :)), in my init.sqf file:

_Action = player addAction ["Team Status", "Scripts\TeamStatusDialog\TeamStatusDialog.sqf", [["Page", "Team"], "AllowPlayerInvites", "HideOpposition"], 0, false, true,""];

player addEventHandler ["killed", 
 {
   waitUntil {alive (_this select 0)};

    _action = (_this select 0) addAction ["Team Status",
   "Scripts\TeamStatusDialog\TeamStatusDialog.sqf",
   [["Page", "Team"], "AllowPlayerInvites", "HideOpposition"], 
   0, false, true, ""];
 }];

Share this post


Link to post
Share on other sites

HI

if you use the CBA you can do this:

[['Team Status', 'Scripts\TeamStatusDialog\TeamStatusDialog.sqf', [['Page', 'Team'], 'AllowPlayerInvites', 'HideOpposition'], 0, false, true, 'teamSwitch',""]] call CBA_fnc_addPlayerAction;

/*
Function: CBA_fnc_addPlayerAction

Description:
Adds persistent action to player (which will also be available in vehicles
and after respawn or teamswitch).

Remove action with <CBA_fnc_removePlayerAction>. *Do not* use standard
removeAction command with these player-action indices!

Parameters:
_actionArray - Array that defines the action, as used in addAction command [Array]

Returns:
Index of action if added. -1 if used on a dedicated server [Number]

Example:
(begin example)
	_actionIndex = [["Teleport", "teleport.sqf"]] call CBA_fnc_addPlayerAction;
(end)

Author:
Sickboy

*/
#include "script_component.hpp"

PARAMS_1(_actionArray);
TRACE_1(_this);

private "_return";

_return = if (isDedicated) then
{
WARNING("Function ran on a dedicated server. Function only usable on a client. Action: " + str _actionArray);
-1; // Invalid action number.
} else {
_index = GVAR(nextActionIndex);
[GVAR(actionList), _index, _actionArray] call CBA_fnc_hashSet;
GVAR(actionListUpdated) = true;
INC(GVAR(nextActionIndex));
_index;
};

_return;

CU

Edited by fbbull

Share this post


Link to post
Share on other sites
Do you have something else that overwrites the EventHandler perhaps?

The only thing that might be doing this is my layout saving, but I'm really not sure..

This is my savelayout.sqf:

hint "Custom Loadout Saved";

while {true} do {
   waitUntil {!alive player};
   _p = player;
   _weapons = weapons _p;
   _magazines = magazines _p;
   waitUntil {alive player};
   _p = player;
   removeAllWeapons _p;
   {_p addMagazine _x;} forEach _magazines;
   {_p addWeapon _x;} forEach _weapons;
   _primw = primaryWeapon _p;
   if (_primw != "") then {
       _p selectWeapon _primw;
       // Fix for weapons with grenade launcher
       _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
       _p selectWeapon (_muzzles select 0);
   };
};

@fbbull: I'm a beginner, so I have no clue on how to use the CBA.. I read the wiki, but I can't find anything (call me stupid, lol) that tells me exactly what to do.

Share this post


Link to post
Share on other sites

Respawning does not mean removing all damage from player and send him back to the respawn marker. It means creating a completely new entitiy, which then of course won't have: the previous weapon configuration, the previous varname, the assigned actions, and probably not the previously assigned eventhandlers.

In my missions I always do it the way you wrote above:

I create a separate playerInit.sqf which is called by the Init.sqf. The playerInit.sqf roughly consists of the code

While{true} do{
  WaitUntil{not alive player};
  // save layout
  WaitUntil{alive player};
  // give back weapons
  // give back actions
};

which always works a charm for me.

So try a mix of both your attempts:

while {true} do {
   waitUntil {!alive player};
   _p = player;
   _weapons = weapons _p;
   _magazines = magazines _p;
   waitUntil {alive player};
   _p = player;
   removeAllWeapons _p;
   {_p addMagazine _x;} forEach _magazines;
   {_p addWeapon _x;} forEach _weapons;
   _primw = primaryWeapon _p;
   if (_primw != "") then {
       _p selectWeapon _primw;
       // Fix for weapons with grenade launcher
       _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
       _p selectWeapon (_muzzles select 0);
   };
  _Action = player addAction ["Team Status", "Scripts\TeamStatusDialog\TeamStatusDialog.sqf", [["Page", "Team"], "AllowPlayerInvites", "HideOpposition"], 0, false, true,""];
  // any other actions.....
};

Share this post


Link to post
Share on other sites
Respawning does not mean removing all damage from player and send him back to the respawn marker. It means creating a completely new entitiy, which then of course won't have: the previous weapon configuration, the previous varname, the assigned actions, and probably not the previously assigned eventhandlers.

In my missions I always do it the way you wrote above:

I create a separate playerInit.sqf which is called by the Init.sqf. The playerInit.sqf roughly consists of the code

While{true} do{
  WaitUntil{not alive player};
  // save layout
  WaitUntil{alive player};
  // give back weapons
  // give back actions
};

which always works a charm for me.

So try a mix of both your attempts:

while {true} do {
   waitUntil {!alive player};
   _p = player;
   _weapons = weapons _p;
   _magazines = magazines _p;
   waitUntil {alive player};
   _p = player;
   removeAllWeapons _p;
   {_p addMagazine _x;} forEach _magazines;
   {_p addWeapon _x;} forEach _weapons;
   _primw = primaryWeapon _p;
   if (_primw != "") then {
       _p selectWeapon _primw;
       // Fix for weapons with grenade launcher
       _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
       _p selectWeapon (_muzzles select 0);
   };
  _Action = player addAction ["Team Status", "Scripts\TeamStatusDialog\TeamStatusDialog.sqf", [["Page", "Team"], "AllowPlayerInvites", "HideOpposition"], 0, false, true,""];
  // any other actions.....
};

That worked like a charm! :yay:

Well,

My map's done now.. I know I asked a lot of stupid questions, but thank you so much for all your help guys! I'm gonna be adding a "special thanks to:" in my intro :D

Share this post


Link to post
Share on other sites

Gratulations for your first mission.

None of your questions were stupid, asking such things in this forum is still the best way to learn how it works.

Keep doing it.

Share this post


Link to post
Share on other sites

That's very true, and I'm glad to say that all that code doesn't scare me as much now as it did before :D

Defenitly something I'd like to spend my time on in the future :)

Thanks again

Share this post


Link to post
Share on other sites

Flightster, you're (or were) not alone in that problem. I read the original Arma thread on Team Status Dialog and it ends with the "respawn" problem not resolved.

I d/led v1.3 (Arma) of TSD and managed to find v1.1 imbedded in some Arma SimHQ missions. If you follow the install instructions for both, neither of them work correctly - ie, you lose the Team Status action as soon as you die.

Luckily, I had a working mission with the SimHQ Coop Pack and I sort of reverse-engineered it to figure out that the key was some third-party script added by some author - which, AFAIK, had nothing to do with re-adding the "action".

So, at this time I have v1.1 working fine. I'll probably just stick with v1.1 now that I have the needed code isolated and working.

But just FYI, the "respawn" problem was a known problem.

I'm now adding the code to a bunch of co-op missions. This script has got to be the most useful script I've ever found for Arma. It can make seemingly impossible missions (say when you're playing alone with AI) winnable - Kudos to Dr_Eyeball!!

Share this post


Link to post
Share on other sites

This what I do to readd action :

_trig = createTrigger ["emptydetector", [0, 0, 0]];
_trig setTriggerArea [0, 0, 0, false];
_trig setTriggerActivation ["none", "present", true];
_trig setTriggerStatements
[
"alive player",
"OPT_ACTIDX_OPTIONS = player addAction [localize 'STR_ACT_OPTIONS', 'act_options.sqf', [], 0, true, true, '', 'call compile format [''_res = false; {if (_target in list _x) exitWith {_res = true}} forEach ZRSTR_BASES_%1; _res'', playerSide]']",
"player removeAction OPT_ACTIDX_OPTIONS"
];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×