Jump to content
Sign in to follow this  
UK_SPAWN

Simple (probably) issue with MP feamework/rSideChat etc.

Recommended Posts

while {alive player} do {_t = time; waitUntil {time - _t > 3}; waitUntil  

{inputAction "MoveFastForward" > 0}; [player,nil,rPLAYSOUND,"SOUNDFILE"] call RE; 

[player,nil,rSay,"TEXT"] call RE; sleep 20; }; sleep 2;

--------------------------------------------------

In the units that need this, i have

--------------------------------------------------

this = [null] ExecVM "SCRIPTNAME.sqf";

--------------------------------------------------

The problem is that when the player and 4 other AI/player are playing, and you run, the sound plays, and the MSG is displayed in the chat. however it is displayed 5 times (one for each player). (its not because the other units run/follow, because i told them to "stop".)

iv tried variations to try to make it 'personal' to each unit,

stuff like;

--------------------------------------------------

this1,2,3,4 etc = [null/player/_this/this/UNITNAME] ExecVM "SCRIPTNAME.sqf"; etc etc 

--------------------------------------------------

and stuff like;

--------------------------------------------------

_unit = _this select 0;

while {alive _unit} do {_t = time; waitUntil {time - _t > 3}; waitUntil  

{inputAction "MoveFastForward" > 0}; [player,nil,rPLAYSOUND,"SOUND"] call RE; 

[_unit,nil,rSay,"TEXT"] call RE; sleep 20; }; sleep 2;

--------------------------------------------------

and, this, unitname, etc etc etc. but i just dont know enough to get it working.

(the sound seems ok, and plays only once not 5 times!)

Any ideas guru-programmer guys?

Cheers,

Share this post


Link to post
Share on other sites

First of,

_t = time; waitUntil {time - _t > 3};

is a really, really, fancy way to write

sleep 3

.

Furthermore the number and use of parameters in your RE-calls is off:

[nil_or_caller, nil_or_target_object,"loc/per", script_to_execute, par0, par1...] call RE;

So your RE-calls should look rather like this:

[nil,player,"loc",rPLAYSOUND,"SOUNDFILE"] call RE; 

But this makes no sense at all, because if you use "player" as the target and "loc" as the condition, that translates to:

playSound "SOUNDFILE";

//edit: okay, fair enough, your use of RE is by all means not wrong, but without more information about the whole scenario it seemed off to me :<

And assigning something to "this"? Please, don't, just, don't xD

To sum this up, what do you intend to do? Do you want the player who moves fast forward to hear a sound and read something on the screen or do you want every player to hear/see that?

If its first, you don't have any MP problems because you can handle it like in SP, just use the "normal" functions like playSound and say.

If you'd like to intend something else, please consider letting us in with some more information :)

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

thanks for your reply, lol i see that im a noob :P

okay basically, when a player runs, it should say "charge" on the radio, to the group. (not enemy team etc) AND th sound should be heard locally, so i have used Say3d and not playSound.

the ability needs to be on all BLUFOR units but not on OPFOR.

It should work after respawns.

while {alive player} do {_t = time; waitUntil {time - _t > 3};

waitUntil {inputAction "MoveFastForward" > 0}; t1 Say3d "CHRG";[t1,"loc",rGroupChat,"CHARGE!!!"] call RE; sleep 20; }; sleep 2;

seems to work how i want, but unfortunate any "PLAYER" that runs, even on the OPFOR, still triggers this. even if "execvm thisscript" is not in there init.

but thats because its "waitUntill Inputaction", not wait "untill input action of specific units and not all units" or any way to define it.

Basically it needs to do what default arma2 does, when you see an enemy. on the radio it says "enemy spotted" and the player says something relevant. but when a blufor player sprints (doubble tap W)

---------- Post added at 11:13 ---------- Previous post was at 11:11 ----------

ah i thought [nil,player,"loc",rPLAYSOUND,"SOUNDFILE"] call RE; was, Play this sound on all things that are "local" to the "player" .. ie the PLAYERS squad...

doh.

---------- Post added at 11:16 ---------- Previous post was at 11:13 ----------

the enemy should be able to hear the player scream charge, yes, but not see the radio msg, or hear the sound over the other side of the map (like with playsound)

Share this post


Link to post
Share on other sites

Oh okay now it's more clear what you want to have :D

Unfortunately say3D has local effects, so you have to broadcast it to everyone in order to achieve what say3D does - playing a sound in the perimeters of specified object.

Just calling say3D will also output the audio, but just for you - everyone else, even one meter besides you, won't hear it.

I'd suggest another approach for this, using public variables, which makes it a little more easy to broadcast those commands.

// init.sqf

if (!isDedicated) then
{
waitUntil {!isNull player};

outputCharge = {
	private ["_chargeSubj", "_group"];

	_chargeSubj	= (_this select 1);
	_group		= group _chargeSubj;

	if (group player == _group) then
	{
		_chargeSubj groupChat "Charge!!!";
	};

	_chargeSubj	say3D "SOUND";
};
"chargeSubject" addPublicVariableEventHandler outputCharge;

if (side player == west) then
{			
	[] spawn {
		while {true} do
		{
			waitUntil {alive player};
			waitUntil {inputAction "MoveFastForward" > 0};

			chargeSubject = player;
			publicVariable "chargeSubject";

			["chargeSubject", player] call outputCharge;

			waitUntil {inputAction "MoveFastForward" == 0};
		};
	};
};
};

Okay the code above will do the following:

  • If the player is on side west (BLUFOR):
    • Wait until the player is alive (just a precaution)
    • Wait until the player starts to sprint
    • Broadcast the player to every client:
      • If the broadcasted player is in the same group like the local players group, output "Charge!!!"
      • play the defined sound in the perimeter of the broadcasted player

      [*]Because the publicVariableHandler won't get executed on the client which did the broadcast, manually call the handler

      [*]Finally, wait until the player isn't sprinting anymore and start from the top

I dunno if this will work with respawning players, but in the worst case scenario you could wrap the code into a sqf-file and execVM it once in the init.sqf and after every respawn in the respawn event handler.

Disclaimer: Didn't test this code in MP.

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  

×