Jump to content
Sign in to follow this  
csk222

Broadcast sideChat to all players

Recommended Posts

Hello.
 
I want players to broadcast to all other players on sideChat when they click on an rscbutton to edit their weapon sway. How is this done?
 
I was reading this
 
Example:
action = "player setCustomAimCoef 0.1; player sidechat 'I set my Weapon Sway to 10%';";
text = "10% Sway";
tooltip = "";

Thank you.

 

Share this post


Link to post
Share on other sites

Question 1

Try:

action = ["[player] spawn SaySide"];

SaySide function:

_player = _this select 0;
[_player, format ["I set my Weapon Sway to 10%"],"sidechat",west,false,false] call BIS_fnc_MP;

Share this post


Link to post
Share on other sites

I was able to broadcast sidechat to all players like this.

 

Button:

action = "player setCustomAimCoef 0.1;[[],'teg_fnc_sway10',true,true] call BIS_fnc_MP;";
text = "10% Sway"; //--- ToDo: Localize;
tooltip = ""; //--- ToDo: Localize;

Function:

teg_fnc_sway10 = {player sidechat "I set my Weapon Sway to 10%";};

The problem now is that no matter who presses the button, it will display a players own name in sidechat not the player who pressed the button.

 

Example:

 

Player1 presses the button and it'll display correctly on their machine "Player1 I set my Weapon Sway to 10%"

 

But on Player2's machine, it will display his own name "Player2 I set my Weapon Sway to 10%" even though it was Player1 who pressed the button.

 

I want it so that when Player1 presses the button it says "Player1 I set my Weapon Sway to 10%" to display on Player2,3,4's etc. machines.

 

How do I do that?

Share this post


Link to post
Share on other sites

I have no idea if this will work. If it does, you could get pretty fancy with the formatting and have only a few functions passing loads of different text.

 

Button:

action = "player setCustomAimCoef 0.1;[[],'[profileName player] teg_fnc_sway10',true,true] call BIS_fnc_MP;";
text = "10% Sway"; //--- ToDo: Localize;
tooltip = ""; //--- ToDo: Localize;

Function:

teg_fnc_sway10 = 
{
	params ["_callerName"];
	_plrName = profileName player;
	if (_callerName == _plrName) then
	{
		player sidechat "I set my Weapon Sway to 10%";
	}
	else
	{
		player sidechat format [" %1 set their Weapon Sway to 10%", _callerName]; 
	
	};		
};

Share this post


Link to post
Share on other sites

private _msg = format ["%1 % sway",_sway];
_msg remoteExec ["sideChat",0];

Edit: Changed target parameter from -2 to 0. See KK's post below for the reason.

Share this post


Link to post
Share on other sites

Soolie:

I tried what you posted but it didn't seem to work.

 

Revo:

Can you explain & clarify that a bit more.

 

---

 

I tried this out but with the same results.

Player1 presses the button and it'll display correctly on their machine "Player1 Set Weapon Sway to 10 Percent"

 

But on Player2's machine, it will display his own name "Player2 Set Weapon Sway to 10 Percent" even though it was Player1 who pressed the button.

 

Button:

action = "player setCustomAimCoef 0.1;[[],'teg_fnc_sway10',true,true] call BIS_fnc_MP;";
text = "10% Sway"; //--- ToDo: Localize;
tooltip = ""; //--- ToDo: Localize;

Function:

teg_fnc_sway10 = {[west,"HQ"] sideChat format["%1 Set Weapon Sway to 10 Percent",name player];};

Share this post


Link to post
Share on other sites
Guest

Why dont you send the player as an argument ?
I would personnaly do it like this.

action = "player setCustomAimCoef 0;[player] remoteExec [""teg_fnc_sway0""];";
text = "0% Sway"; //--- ToDo: Localize;
tooltip = ""; //--- ToDo: Localize;
teg_fnc_sway10 = {
    _unit = _this select 0;
    // Could be good to add classic checks like isNull, isPlayer etc...
    [west,"HQ"] sideChat format["%1 Set Weapon Sway to 10 Percent",name _unit];
};

EDIT : With remoteExec your need to configure CfgRemoteExec in your description.ext and at least disable the whitelist or simply withelist the function with the whitelist enabled.

https://community.bistudio.com/wiki/Description.ext#CfgRemoteExec

 

EDIT 2 : You can directly send the player name instead if you only need that.

Share this post


Link to post
Share on other sites
private _msg = format ["%1 % sway",_sway];_msg remoteExec ["sideChat",-2];

Why -2? This will not work for hosting player or in SP. Why go into trouble isolating the server if systemchat will simply get ignored on it and no kittens will be harmed?

Share this post


Link to post
Share on other sites

Why -2? This will not work for hosting player or in SP. Why go into trouble isolating the server if systemchat will simple get ignored on it and no kittents will be harmed?

 

 

why send an unnecessary packet to the server?

Share this post


Link to post
Share on other sites

why send an unnecessary packet to the server?

remoteexec always sends a packet to the server first

Share this post


Link to post
Share on other sites

remoteexec always sends a packet to the server first

 

I changed my post accordingly. Thanks for the heads-up.

Share this post


Link to post
Share on other sites

remoteexec always sends a packet to the server first

 

regardless if the server doesnt need to know, theres no reason to have the server cpu evaluate whether or not to call sidechat

Share this post


Link to post
Share on other sites

regardless if the server doesnt need to know, theres no reason to have the server cpu evaluate whether or not to call sidechat

 

Of course there is reason, you are REMOTE executing it, the word in capitals should give good clue as to why it has to go through the server.

Share this post


Link to post
Share on other sites

harmdhast - Thank you very much, that worked!

 

Button:

action = "player setCustomAimCoef 0.1;[player] remoteExec [""teg_fnc_sway10""];";
text = "10% Sway";
tooltip = "";

Function:

teg_fnc_sway10 =  {_unit = _this select 0;[west,"HQ"] sideChat format["%1 Set Weapon Sway to 10 Percent",name _unit];};

Notes: I still don't understand what this was all about, how it works or how to implement it for my use.

R3vo

Posted 27 August 2016 - 13:43


private _msg = format ["%1 % sway",_sway];
_msg remoteExec ["sideChat",0];

Edit: Changed target parameter from -2 to 0. See KK's post below for the reason.

 

 

Share this post


Link to post
Share on other sites

Of course there is reason, you are REMOTE executing it, the word in capitals should give good clue as to why it has to go through the server.

 

you're missing the point

 

you are still having the server call the sidechat function. whether or not there is an if statement in the engine to decide what to do on server is beside the point. its good practice to do the correct thing even when doing the wrong thing (attempting to execute GUI code on server) sometimes won't cause harm. and really, how much trouble is it to use -2 instead of 0?

[[west,'hq'],'imma sidechat k'] remoteexec ['sidechat',-2];

is better than

[[west,'hq'],'imma sidechat k'] remoteexec ['sidechat',0];

Share this post


Link to post
Share on other sites

The engine can perfectly handle ui commands on server, why become a control freak and try to handle everything yourself at the expense of performance? I can guarantee you that "if" in the engine is at least 10x faster than "if" in sqf.

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  

×