Jump to content
Sign in to follow this  
celery

Private addAction and radio command

Recommended Posts

I'm trying to give an action only accessible to the unit that is bound to it in a multiplayer map. However, any other player next to him can also freely clickedy click his actions and eventually it will mess things up. Is there a way to add an action that others can't see and execute?

Another grief are the custom radio commands. How do I add them in a script and how do I assign them to specific players only?

Share this post


Link to post
Share on other sites

I noticed in the editor that group members seem to inherit the actions of a player. Not sure if this is a bug - I don't remember this behaviour from OFP. Are you talking about group members or just anybody who stands near enough to the player ?

Share this post


Link to post
Share on other sites

I'm talking about absolutely anyone, even on different sides. It's the same as addActioning an inanimate object that anyone near enough can execute, but I'd like to know a way to add it "discretely".

Share this post


Link to post
Share on other sites

Actually, I just realised there may be a workaround although it doesn't stop the actions being displayed...

player addAction ["an action","action.sqf",[player]] ;

action.sqf....

_pl = _this select 0

if (_pl == player) then {

//do the action

} else

{

player sidechat "That action doesn't belong to you!" ;

} ;

Share this post


Link to post
Share on other sites
Quote[/b] ]It's the same as addActioning an inanimate object

Ah - I think I see what you want to do. You want to have an object, eg a locked door, that only a certain player can open ? You could use a trigger to add the action or write this kind of code...

_done = false ;

for ({},{not _done},{true} do {

if (player_with_key distance theDoor < 3) then {

player_with_key addAction ...

_done = true ;

} ;

Sleep 0.5 ;

} ;

Does this help ?

Share this post


Link to post
Share on other sites

Let me explain the roots. I'm making a versus team map where one player is able to place a hidden camera and then take it again or remotely watch it. If another player is next to the camera man, they are able to see his actions and although I can make an identity check, it still looks unesthetic.

The bigger and more practical problem however is assigning an action by means of a radio command. The bulk of personalised commands reside in the command menu but they overlap each other. Radio triggers in the editor don't work very well, so adding one inside a script would rock.

Share this post


Link to post
Share on other sites

I know how to do it.. Very complicated though.. smile_o.gif i will right up a tutorial with pictures.. smile_o.gif or would a test mp mission help? or both tounge2.gif

Share this post


Link to post
Share on other sites

Just the most basic snippet with pointers will do!

Share this post


Link to post
Share on other sites

Hmm - I just tried it in the editor. Created a second unit an gave it an action. As you say, if you stand close enough you get to use their action ! Surely that has to be a bug ?

Share this post


Link to post
Share on other sites
Hmm - I just tried it in the editor. Created a second unit an gave it an action. As you say, if you stand close enough you get to use their action ! Surely that has to be a bug ?

Its always been like that, thats why we had made a work around for our clan training missions when we had a Drill instructor with certain options he could control and we didnt want the recuites to control these options for the training missions..

Weather Conditions

Time of Day/Night

Spectator

Map on/off

Compass On/Off

those type of things.. just got to get the spec script to work properly and all will be done.

Share this post


Link to post
Share on other sites

Add your action locally, for instance with:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (local player) then {player addaction [blabla]}

This will solve the issue of everybody having access to the action, but it won't change the fact that actions are executed locally. So you'll still need to cobble up something if you want your action to change stuff in the "matrix".

Share this post


Link to post
Share on other sites

Ok Ill Post what i know..

INIT.SQS

Quote[/b] ]

;by Nightmare [sWAF]

;Edited by Matt Rochelle [sWAF] for ArmA

;Nightmare@KVcomputer.de

;MRO204@hotmail.co.uk

;------------------------------------------------------------------

id200 = drill1 addaction ["Open Control Panel","Drillcontrol.sqs"]

;------------------------------------------------------------------

DRILLCONTROL.SQS

Quote[/b] ]

;by Nightmare [sWAF]

;Edited by Matt Rochelle [sWAF] for ArmA

;Nightmare@KVcomputer.de

;MRO204@hotmail.co.uk

;----------------------------------------------

?player == drill1 : goto "start"

goto "end"

#start

player removeaction 0

player removeaction 1

player removeaction 2

player removeaction 3

player removeaction 4

player removeaction 5

player removeaction 6

player removeaction 7

player removeaction 8

player removeaction 9

player removeaction 10

player removeaction 11

player removeaction 12

?player == drill1 : goto "drill1"

goto "end"

#drill1

drill1 removeaction id200

id300 = drill1 addaction ["Close Control Panel","Close1.sqs"]

id00 = drill1 addaction ["Spectator Camera","KEGcamera.sqs"]

id02 = drill1 addaction ["Disable/enable COMPASS for all recruits","compass.sqs"]

id03 = drill1 addaction ["Disable/enable MAP for all recruits","map.sqs"]

goto "end"

#end

exit

CLOSE1.sqs

Quote[/b] ]

;by Nightmare [sWAF]

;Edited by Matt Rochelle [sWAF] for ArmA

;Nightmare@KVcomputer.de

;MRO204@hotmail.co.uk

;----------------------------------------------

?player == drill1 : goto "start"

hint "You are not allowed to use that !"

goto "end"

#start

drill1 removeaction id00

drill1 removeaction id01

drill1 removeaction id02

drill1 removeaction id03

drill1 removeaction id04

drill1 removeaction id05

drill1 removeaction id06

drill1 removeaction id07

drill1 removeaction id08

drill1 removeaction id09

drill1 removeaction id300

id200 = drill1 addaction ["Open Control Panel","Drillcontrol.sqs"]

#end

exit

COMPASS.sqs

Quote[/b] ]

;by Nightmare [sWAF]

;Nightmare@KVcomputer.de

;----------------------------------------------

?player == drill1 : goto "start"

hint "You are not allowed to use that !"

goto "end"

#start

?compasson : goto "turnoff"

?compassoff : goto "turnon"

#turnoff

Player groupchat "Compass turned OFF for all recruits !"

Compassoff = true

publicVariable "Compassoff"

Compasson = false

publicVariable "Compasson"

goto "end"

#turnon

Player groupchat "Compass turned ON for all recruits !"

Compassoff = false

publicVariable "Compassoff"

Compasson = true

publicVariable "Compasson"

goto "end"

#end

exit

As you can see Drillcontrol is where you add your own scripts like if you want to start your camera ect.. and i posted the compass.sqs for an example if you want to test it. i hope you understand how its done.

Drill1 is the name of the man who gets the actions added to his menu.

Share this post


Link to post
Share on other sites

Tonight after work i will also show you how to access a radio command after you have clicked an action only available to you which will be accompanied with a demo mission.

Share this post


Link to post
Share on other sites

@Igor: Thanks for the input but the actions are still clearly visible to everyone.

@Matt: The actions are visible here too, the id check was already in my knowledge, the main problem is that the actions actually show in menus of other players in addition to the sole owner of those functions.

The radio dilemma is still unsolved. I think it's possible to assign radio calls inside a script but I have no idea what to write.

Share this post


Link to post
Share on other sites
Tonight after work i will also show you how to access a radio command after you have clicked an action only available to you which will be accompanied with a demo mission.

You don't have to do anything fancy, as a matter of fact I just need to see a snippet that assigns a radio command to a certain player that other players can't see and execute. I can add a "this dont concern you" message to unauthorised activators but this is a matter of keeping things polished.

Share this post


Link to post
Share on other sites

You'll have to add another condition specific to the unit or else every player is going to have the action, e.g.:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (local player and group player==TheSchmoozies) then {player addAction [blabla]}

Share this post


Link to post
Share on other sites
...

To only Make the radio commands work on some computer...

Make the Condition: allowrad && this

Then put in init.sqs:

allowrad=false;

And then on the player's computer that needs to have the action enabled, only execute: allowrad=true; on that player's computer, as the variable is local, it will remain false on other's computers and so only execute the OnActivation on this computer. You could aswell make 2 variables for different sides, testing the sides with ?(side player)==west: allowradwest=true; etc

Actions are always local so if you only add the action to 1 player, then he is the only one that will have the action, if you name ur players, you could do for instance: s1 addAction .... .

The problem that other's get the actions in their list when they are humping the player that has the action... I don't know a fix for, besides kicking idiots off that deliberatly try to screw the game by doing so.

?(local player) is not going to work as the player object is always local on every machine (except the server), so if you would addaction to all players, with a [player] in the parameters list and a ?(local player)&&(player==_this select 3) etc.. check in the script it will still run, as it's executed locally on their own machine when they run the action...

If you addaction to everyone, but only want someone or a few ppl to be able to use the actions you could also make an array (or just do the same as with the allowrad boolean):

init.sqs

allowact=[];

Then fill that array with player objects that are allowed to handle actions, depending on scripting events, eg: allowact=allowact + [s4]; , and make a: ?!(player in allowaction): exit;

etc. in the script that's connected with the action.

If your actions involve onsinglemapclick and need to do/activate things on the server, you might take a look at my NS Lite

Goodluck!

Share this post


Link to post
Share on other sites

I'm not entirely clear on what you want, but it sounds like you don't want all players to see a radio command.

Since a radio command is assigned by a trigger, then it'll show up for everyone.  To hide it for some people, you'll need to put this in init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

1 SetRadioMsg "null"

That should set the first radio message to nothing for everyone.  So let's say you only want the leader to be able to see it, then you could do this:

First, name the group, i.e. in the init field of the playable units put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

group1 = group this

Then in init.sqs put this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?Player != leader group1 : 1 SetRadioMsg "null"

Using that same code, you can change the radio command name as well:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

1 SetRadioMsg "Launch the Nuke"

Now, if you're talking about adding an action to the player's action menu, then that can definitely be added locally as some of the others have suggested.  But if it's a radio command via trigger, then what I've written above should point you in the right direction....I hope.

Share this post


Link to post
Share on other sites

You got that right KaRRiLLioN..

Using my idea you can do this.. [make sure you have two triggers on the map with what you want. Alpha, Bravo]

INIT.SQS

Quote[/b] ]

;by Nightmare [sWAF]

;Edited by Matt Rochelle [sWAF] for ArmA

;Nightmare@KVcomputer.de

;MRO204@hotmail.co.uk

;------------------------------------------------------------------

id200 = drill1 addaction ["Open Control Panel","Drillcontrol.sqs"]

1 SetRadioMsg "null"

2 SetRadioMsg "null"

?Player != leader group1 : 1 SetRadioMsg "null"

?Player != leader group1 : 2 SetRadioMsg "null"

;------------------------------------------------------------------

DRILLCONTROL.SQS

Quote[/b] ]

;by Nightmare [sWAF]

;Edited by Matt Rochelle [sWAF] for ArmA

;Nightmare@KVcomputer.de

;MRO204@hotmail.co.uk

;----------------------------------------------

?player == drill1 : goto "start"

goto "end"

#start

player removeaction 0

player removeaction 1

player removeaction 2

player removeaction 3

player removeaction 4

player removeaction 5

player removeaction 6

player removeaction 7

player removeaction 8

player removeaction 9

player removeaction 10

player removeaction 11

player removeaction 12

?player == drill1 : goto "drill1"

goto "end"

#drill1

drill1 removeaction id200

id300 = drill1 addaction ["Close Control Panel","Close1.sqs"]

id00 = drill1 addaction ["Enable Radio Airstrike","radair.sqs"]

id02 = drill1 addaction ["Enable Radio Tanks","ratanks.sqs"]

goto "end"

#end

exit

CLOSE1.SQS

Quote[/b] ]

;by Nightmare [sWAF]

;Edited by Matt Rochelle [sWAF] for ArmA

;Nightmare@KVcomputer.de

;MRO204@hotmail.co.uk

;----------------------------------------------

?player == drill1 : goto "start"

hint "You are not allowed to use that !"

goto "end"

#start

drill1 removeaction id00

drill1 removeaction id01

drill1 removeaction id02

drill1 removeaction id03

drill1 removeaction id04

drill1 removeaction id05

drill1 removeaction id06

drill1 removeaction id07

drill1 removeaction id08

drill1 removeaction id09

drill1 removeaction id300

id200 = drill1 addaction ["Open Control Panel","Drillcontrol.sqs"]

#end

exit

RADAIR.SQS

Quote[/b] ]

1 SetRadioMsg "Call in Airstrike"

RATANKS.SQS

Quote[/b] ]

1 SetRadioMsg "Call in Tanks"

i think thats about right if i were reading correct..

btw: i think its impossible to stop others seeing the action in your menu...

Share this post


Link to post
Share on other sites

Thank you Igor Drukov, your trick worked with the action menu! inlove.gif

I also got the radio hidden for unconcerned players with the "null" line, thanks for that too! Just out of curiousity though, how do I attach a command to e.g. "RADIO ALPHA" to a certain player without using triggers?

Share this post


Link to post
Share on other sites

Are you asking how to add an action to the player's action menu?  Or how to add an action to the radio menu, i.e. 0-0-1?

If you want to add an item to the radio menu, I think you have to have a trigger either pre-placed in the mission editor, or you can use createTrigger and then set the options for the trigger type, etc.  So, AFAIK, there's no way to add an item to the radio menu without using a trigger.

As for adding an action to the player's action menu, you use this:

object addaction ["Action Name","actionScript.sqs"]

If this is a mission where the player is respawning, then you'll probably want to create a trigger with a condition of Alive Player and an onActivation with the addaction command.  Object would be whatever object/man/unit you want to add the action to.

If it's a mission where there is no respawn, then you could add the action via the init field in the mission editor.

Another thing you need to be aware of with actions, is that once you board a vehicle, your action will likely vanish.  That's because ArmA only attaches the action to the soldier, not the vehicle the soldier boards.  In that case, a looping script of some sort that adds the action when the player is in another vehicle works well.

Anyway, I'm guessing you're after the information for a radio command, not an action menu item.  If you need more info on adding actions, I can put up more detailed stuff.

Hope this helps.

Share this post


Link to post
Share on other sites

Guys, I read it all, searched in OFPEC foruns, Official forun and also Wiki, but im not able to do that (single) addAction in MP but due to my lack of knowledge in scripting, maybe you can help acomplish what I need to do, and together with this I got a Script class.

So, if possible, type the script lines for scripts if needed and the also it´s respective lines for cond/Activ/Desactiv fields.

This is what I want to do in my MP mission:

I created a "prision" rolling vertically the "wire crawling training object" so that I build a square cage. the ideia is to when any player get close to it, it´s leader gets the action to "cut wire" wich I intend to deleteVehicle the wire.

this is what i did:

Created a trigger set to:

radius: a little bigger (1.5m) than the "cage"

detection:BlueFor present, repiatedly

Condition:this and ((local player and group player==Bravo) or (local player and group player==Delta)) - these two group leaders are "alowed" to perform the action only.

On Activation: leader player addAction ["Cut wire", "scripts\wire.sqs"];

On desactivation: leader player exec "scripts\wireyet.sqs"

It seems to work for 1 time, when I as leader, send a soldier next to it, the action appears just for me, the leader, I send him away from it, and again it works, the action disappear, but after the 2º time I send a unit next to it, the action apppear and besides not disappearing, each time the soldier come out and than get back, the same action is added once more, and again and again, so I had several times the same action.

I´m sure its due to the poor scripts I created, but hell, it´s hard for me to understand, the handling with variables in scripts, take a look:

wire.sqs

deleteVehicle wire1; deleteVehicle wire2; deleteVehicle wire3; deleteVehicle wire4;

this exec "scripts\wireyet.sqs"

exit;

wireyet.sqs

player removeAction 0;

exit;

I´m sure it´s wrong but tried with variables like the exemples here OFPEC Comref - addAction and here Wiki addAction reference, but trying tto follow these examples, with it´s variables make the add and remove actions didn´t work at all.

Hope you can help a script moron, and sorry for such big post.

In hours and hours of searching and reading posts all over the net, I was ablle to acomplish a big variety of things, just with, triggers and scripts lines, avoinding scripts.sqs and .sqf due to dificulties in making, (even a little) more complex and external scripts.

thanks in advance.

Charlis

Share this post


Link to post
Share on other sites
Are you asking how to add an action to the player's action menu?  Or how to add an action to the radio menu, i.e. 0-0-1?

If you want to add an item to the radio menu, I think you have to have a trigger either pre-placed in the mission editor, or you can use createTrigger and then set the options for the trigger type, etc.  So, AFAIK, there's no way to add an item to the radio menu without using a trigger.

As for adding an action to the player's action menu, you use this:

object addaction ["Action Name","actionScript.sqs"]

If this is a mission where the player is respawning, then you'll probably want to create a trigger with a condition of Alive Player and an onActivation with the addaction command.  Object would be whatever object/man/unit you want to add the action to.

If it's a mission where there is no respawn, then you could add the action via the init field in the mission editor.

Another thing you need to be aware of with actions, is that once you board a vehicle, your action will likely vanish.  That's because ArmA only attaches the action to the soldier, not the vehicle the soldier boards.  In that case, a looping script of some sort that adds the action when the player is in another vehicle works well.

Anyway, I'm guessing you're after the information for a radio command, not an action menu item.  If you need more info on adding actions, I can put up more detailed stuff.

Hope this helps.

I need that releated stuff to not delete the command after leave car. I made a mission WITHOUT spawning, and with much help of mando i connected his air console with a addaction order and only players wich have a laser designator will get this command added.

it works ok but the command will be deleted after get out a vehicle.

here is the piece of code which manage this all:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

//code by mando

[] spawn

{

private["_acidx1", "_acidx2", "_unit", "_veh"];

_acidx1 = -1;

_acidx2 = -1;

while {true} do

{

waitUntil {("Laserdesignator" in weapons player) && (alive player)};

_acidx1 = player addAction ["Console: Air support", "mando_airsupportdlg.sqf"];

while {("Laserdesignator" in weapons player) && (alive player)} do

{

_unit = player;

if (vehicle _unit != _unit) then

{

_veh = vehicle _unit;

_acidx2 = vehicle _unit addAction ["Console: Air support", "mando_airsupportdlg.sqf"];

waitUntil {(vehicle _unit == _unit) || (!alive _unit)};

_veh removeAction _acidx2;

};

Sleep 1;

};

_unit removeAction _acidx1;

};

};

i added 2 lines more to get it working for me but im not sure if its a good way to do it:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[] spawn

{

private["_acidx1", "_acidx2", "_unit", "_veh"];

_acidx1 = -1;

_acidx2 = -1;

while {true} do

{

waitUntil {("Laserdesignator" in weapons player) && (alive player)};

_acidx1 = player addAction ["Console: Air support", "mando_airsupportdlg.sqf"];

while {("Laserdesignator" in weapons player) && (alive player)} do

{

_unit = player;

if (vehicle _unit != _unit) then

{

_veh = vehicle _unit;

_acidx2 = vehicle _unit addAction ["Console: Air support", "mando_airsupportdlg.sqf"];

waitUntil {(vehicle _unit == _unit) || (!alive _unit)};

_veh removeAction _acidx2;

_unit removeAction _acidx1;

_acidx1 = player addAction ["Console: Air support", "mando_airsupportdlg.sqf"];

};

Sleep 1;

};

_unit removeAction _acidx1;

};

};

Now it seems to work, but im not sure....

Any ideas?

Share this post


Link to post
Share on other sites
I'm not entirely clear on what you want, but it sounds like you don't want all players to see a radio command.

Since a radio command is assigned by a trigger, then it'll show up for everyone. To hide it for some people, you'll need to put this in init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

1 SetRadioMsg "null"

That should set the first radio message to nothing for everyone. So let's say you only want the leader to be able to see it, then you could do this:

First, name the group, i.e. in the init field of the playable units put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

group1 = group this

Then in init.sqs put this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?Player != leader group1 : 1 SetRadioMsg "null"

Using that same code, you can change the radio command name as well:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

1 SetRadioMsg "Launch the Nuke"

Now, if you're talking about adding an action to the player's action menu, then that can definitely be added locally as some of the others have suggested. But if it's a radio command via trigger, then what I've written above should point you in the right direction....I hope.

I followed these instructions and had a problem. Basically I have two squads on Bluefor, one of these squads will have access to airsupport which is called via radio triggers. The problem I am having is I defined the groups but both squads still have access to the radio. For example;

1 SetRadioMsg "null"

2 SetRadioMsg "null"

3 SetRadioMsg "null"

4 SetRadioMsg "null"

This blocks the 4 Radio triggers

Then I added;

?Player != leader group1 : 1 SetRadioMsg "null"

?Player != leader group2 : 1 SetRadioMsg "Call in Airstrike"

However all of Group 1 and the lone guy in group 2 can access the 'Call in airtrike' radio command.

Only group 2 should be able to call it in.

Where am I going wrong?

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  

×