Home   Help Search Login Register  

Author Topic: AddAction To 1 Player in MP  (Read 3936 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris1986

  • Members
  • *
AddAction To 1 Player in MP
« on: 10 Jul 2009, 20:00:05 »
Hey ive been searching the fourms and couldnt find what i was looking for , Basicly i want 1 Unit ( Player ) to have a Action ( AddAction ) . I have got it working fine in the editor but as most scripts go on a dedicated server they act diffrently . Im new with the whole scripting in ArmA(2) so excuse any of my divkid questions / scripting .

Init Of The INS Unit : This Exec "AddActionINS.sqs"

AddActionINS :-
Code: [Select]
?(Player == Ins): Ins addaction["Beast Recruits","scripts\beast.sqf"]
Beast.sqf :-
Code: [Select]
soldier1 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
soldier2 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
soldier3 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
soldier4 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";

exit


Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: AddAction To 1 Player in MP
« Reply #1 on: 11 Jul 2009, 12:31:52 »
I always use player addAction, to ensure that only one action is added to your player in a MP environment. If the action is triggered by a player, then the script it tiggers will run on that players client machine only. It will not run on the server in a dedicated game.

This will produce a problem in your case. If soldier1, soldier2, etc are not local to the client running the script, they wont obey the playMove command. If they are AI units compeely under computer control, for example.

playMove must always be local to the client (computer) on which the command is executed. It's effects, however, are global. If the command is issued correctly on one computer all players in the network will see the same effect. In this case: soldiers doing pushups.

Note: This thread should be moved to MP section.
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: AddAction To 1 Player in MP
« Reply #2 on: 11 Jul 2009, 14:22:11 »
If you want to add actions to the player (in SP or MP), do not do it via an init field. Instead, do it via init.sqf:
Code: (addBeastAction.sqf) [Select]
// Run from init.sqf with:
//   [] execVM "addBeastAction.sqf";
if (isDedicated) exitWith {}; // Don't run on server.
waitUntil { alive player }; // Wait until the player object is created.
player addaction["Beast Recruits","scripts\beast.sqf"];
Although this seems like more messing about than when you just add the action to one player in SP in the init field, it makes considerably more sense in MP, since the code is only in one place (the file) rather than having to be repeated on every object. Any alterations or additions to the code are also much easier, since you don't have to edit all those init fields.

I'm not suggesting you use this method, but your original code could have been simplified as:
Code: (init field the same on all player objects) [Select]
if (player == this) then { this addaction["Beast Recruits","scripts\beast.sqf"]; };
Which means that you could use exactly the same code in every init, rather than having to ensure you had the correct name of the object in the code.

You still have the issues regarding the MP nature of the of playMove command that nominesine mentioned, of course.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Chris1986

  • Members
  • *
Re: AddAction To 1 Player in MP
« Reply #3 on: 11 Jul 2009, 16:58:44 »
Cheer's for the help lads , About the player method i really wanted it so that only the "Training Staff" could use the action so then you dont get other people on the training map giving others pushup's ( i know how tempting it would be ) that is why i tryed to use the name ( INS ) so that only 1 person could use it .

I think now with ArmA2 you have the Radio as a carryable object(Item) i could only issue the radio to the INS unit and use the moves via OnAct radio command as i think this will be global ? Might be a nice little work around for the time being .

I will continue to crack on to try to get it working . If i do i will post up the solved version or if anyone has any brain waves on how to do this would be mega! .

p.s Thanks for moving post i realised my mistake after i had posted .  :good:

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: AddAction To 1 Player in MP
« Reply #4 on: 11 Jul 2009, 19:27:55 »
Well, in that case, where you are actually only wanting one person to have the action, then that is more reasonable. You still have the problem that init lines must be SQF, not SQS (? : is SQS) so you will get somewhere just using my second example which shows how to add the action in SQF properly. You still have the MP issue of trying to run local commands (playMove) in MP though.

Using radio triggers makes more sense, since they are run globally. As long as you can ensure the recruits don't get hold of a radio, you are sorted ;)
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Chris1986

  • Members
  • *
Re: AddAction To 1 Player in MP
« Reply #5 on: 11 Jul 2009, 20:31:31 »
Using radio triggers makes more sense, since they are run globally. As long as you can ensure the recruits don't get hold of a radio, you are sorted ;)

Yeah i think ill just removeallitems from the recruits , then use the radio that or strip search them all . Cheer's for the help again fella  :good: