Home   Help Search Login Register  

Author Topic: Need help with addaction command  (Read 2152 times)

0 Members and 1 Guest are viewing this topic.

Offline xylaz

  • Members
  • *
    • Dark Hunters
Need help with addaction command
« on: 05 Dec 2005, 06:45:38 »
Lets say there is 6 players, and I want addaction to 1 of them. But I want this 1 player could always see this added action in his menu, and  other players would not see it at all when standing next to him. Because I dont want others to use his action.

I readed Baddo's tutorial "Triggers, scripts and addAction in multiplayer" but still dont get it.

Durbs

  • Guest
Re:Need help with addaction command
« Reply #1 on: 05 Dec 2005, 07:36:10 »
Here's a little example mission that might help you :)

The player with the action is named DUDE.
The ACTION.sqs assigns dude with the addaction.
The SCRIPT.sqs is the action/script performed.


Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Need help with addaction command
« Reply #2 on: 05 Dec 2005, 17:26:47 »
Your problem is that addaction has an activating radius of i believe 5m.
This means that any player next to another player that has this addaction will see it in his action list.

User actions, which are config based have an attribute which dictates what this radius should be, unfortunately this radius is fixed in addactions

So basically you cannot hide this action from other players

However you can stop any script that the action executes, if the activating unit is not Unit X

eg
INIT.sqs
?(Player == W1): Player addaction ["Say Hello", "hello.sqs"]

hello.sqs
Quote
?! (Player == W1): exit
Player sidechat "Hello, this message is activated by W1 only"
« Last Edit: 05 Dec 2005, 17:31:59 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Need help with addaction command
« Reply #3 on: 06 Dec 2005, 00:34:06 »
Another way to prevent units other than the one to whom the action is "attached" from making use of the action is to use the fact that the action passes 3 parameters in the script it activates.  These are as follows: _this select 0 is the owner of the action, _this select 1 is the doer of the action and _this select 2 is the index id value of the action.  So you can start your script like this:

_owner = _this select 0
_doer = _this select 1
_id = _this select 2

? _doer != _owner : exit

If the _owner is also the _doer, the script will proceed, but if the doer is anyone else, the script will end.  If you want to remove the action right after it is done you can also add this line:

_owner removeAction _id

Offline xylaz

  • Members
  • *
    • Dark Hunters
Re:Need help with addaction command
« Reply #4 on: 15 Dec 2005, 22:08:31 »
Thanks! I'll try your idea Raptorsaurus next time.
I can see idea by Terox can be usefull too.
And about idea by DurbanPoison, I tested it on dedicated server with second real player and it doesnt work. There is no any action added to any of players. It works only in editor or maybe when player is server.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Need help with addaction command
« Reply #5 on: 05 Jan 2006, 22:32:38 »
I thought that actions only appeared on the client where they were added?

So basically, all you have to do is only add an action to the player on his machine.

Note that init fields are run on every client, so if that is where you are adding the action, then that would be the problem.

You could solve this by adding the action in the init.sqs, which gets run individually on each client:

Code: [Select]
player addaction "whatever.sqs"
Since this line of code would only be run ONCE on each client, and 'player' would refer to a different unit on each client, then it should work. On a dedicated server the server might sport an error, since it doesn't have a player, but I don't think it would be a problem.

Anyway, let me know if this doesn't work.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:Need help with addaction command
« Reply #6 on: 05 Jan 2006, 23:27:38 »
I thought that actions only appeared on the client where they were added?

So basically, all you have to do is only add an action to the player on his machine.

Note that init fields are run on every client, so if that is where you are adding the action, then that would be the problem.

You could solve this by adding the action in the init.sqs, which gets run individually on each client:

Code: [Select]
player addaction "whatever.sqs"
Since this line of code would only be run ONCE on each client, and 'player' would refer to a different unit on each client, then it should work. On a dedicated server the server might sport an error, since it doesn't have a player, but I don't think it would be a problem.

Anyway, let me know if this doesn't work.


That is exactly what Kegetys is explaining in the tutorial mentioned in the first post (which I only translated from Finnish into English). And, the example code from GB is perhaps not correct? Should be an array, not a string after addAction.