Jump to content

Recommended Posts

Evening people

 

So I'm currently in the process of making a missions which is coming along rather well but I've now ran into a problem (which I was aware would happen), and I'm unsure how to go about it.

 

Context:

Upon spawning there two sides "west" & "civilian"

When the CivPop players spawn I wish for one of them at random to be selected to have a certain option and also be hinted they are the chosen player.

 

The option I wish for them to have is an "AddAction" which when activated will execute a script.In that script I wish for it to force that unit to switch Side to "east", change their loadout, play a sound file, hint to "west", and then remove action.

 

 

Currently I have a onPlayerRespawn.sqf file with the following (Var shooter is currently on "east" side)

sleep 5;

shooteraction = shooter addAction [

"<t color='#C00000'>BEGIN CARNAGE</t>",

"shooter.sqf"

];

 

Within the shooter.sqf is the following

shooter say3d ["pumped", 25, 1];

shooter removeAction shooteraction;

 

All of the above code works fine, it's quite simple, I've got the sound file to play fine and the action to be removed; but now how would I go about the rest.

 

Upon spawning:

  • Choosing random CivPop player to have said option and hint informing them upon spawning

 

When activated:

  • Forcing chosen player to side "east"
  • Forcing chosen player to change loadout to what I list
  • To play the above sound file
  • and finally remove action

Any help would be great.

 

I'm still quite Amature to development for Arma but I have a passion to learn. Sadly I'm stumped .

Share this post


Link to post
Share on other sites

- I don't know what shooter is, here, but that must be an object/unit, edited and named shooter. So, any player will see the addAction...

NB: If you spawn your shooter while in game, on server, you'll need to remoteExec your addAction (only server will knows this variable name)

 

- You can choose any player by:

selectRandom allPlayers

You will select an existing player, no matter if all slots are played or not.

 

- To change loadout, first you have to register a loadout (export from arsenal for example, or use getUnitLoadout), then use the setUnitLoadout when needed.

- Play the sound file: depending on who have to hear that. remoteExec it if needed. See BIKI.

 

You need to remoteExec the removeAction. If not you will remove it locally only.

 

Share this post


Link to post
Share on other sites

 

 

The "shooter" is a var for the current single OPFOR unit.

The addaction works after the sleep time and and when used it removes itself just fine for that single unit (Which I intended) 

but I wish to expand the mission so that instead of having an OPFOR unit that everyone knows from mission start will be the "shooter" 

I hoped to have it more random by making one of the civs at start be chosen by random to have the addaction which would then enable all the following stuff I listed. 

 

 

EDIT: Let's forget about the script that does all the playing music, loadouts, and so on.

 

What I really wish to know is how do I get a random Civilian player at mission start to be chosen to have the addAction and a hint informing them they are said shooter?

 

sleep 0;

if ((side player) == civilian) then { 
_random = selectRandom [civ1, civ2];
	shooteraction = _random addAction [

      "<t color='#C00000'>BEGIN CARNAGE</t>",
	  {
      execVM "shooter.sqf"
	  },
	  [], 
    1.5,  
    true,  
    false,  
    "", 
    "true",
    0.1, 
    false, 
    "", 
    "" 
    ];
};

EDIT: Above is what I have now and I believe far as I can tell it works fine. 
It randomizes the chosen person.

 

Looking at my code above, does what I've wrote seem like it works without issue? i.e would this code cause an issue I'm not initially aware of while play testing? 

 

Share this post


Link to post
Share on other sites

in initServer.sqf, at the end of this script:

waitUntil {sleep 1; {side _x == civilian} count allPlayers >1};  // waiting for 2 players as civilian

_shooter = selectRandom [civ1, civ2];
[_shooter, [ "<t color='#C00000'>BEGIN CARNAGE</t>", {
params ["_plyr","_tgt","_id"];

  _plyr execVM "shooter.sqf";

  _plyr removeAction _id;

}, [], 1.5, true, false, "", "true", 0.1, false, "", "" ]

] remoteExec ["addaction",_shooter];

 

shooter.sqf:

params ["_plyr"];

hint "bla bla";

[_plyr, ["pumped", 25, 1] ] remoteExec ["say3D"];

_grp = createGroup East;

[_plyr] joinSilent _grp;

 

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

×