Jump to content

Recommended Posts

Hello there Guys!

 

My problem , is first that i don't find the error for this and cannot get bis_fnc_dynamicText ,

run on every PC to show on global, if anyones knows how please help  :

 

iUiUy7ypREC3NkskVw8qHQ.png

 

 

This is script is included in :

 

 




//________________  Author : [GR]GEORGE F ___________ 11/03/2018 _____________

/*	
Killfeed_GF.sqf

Headshot + Killfeed Script
https://forums.bistudio.com/forums/topic/206593-headshot-killfeed-script/
http://www.armaholic.com/page.php?id=32989

Main Source from :
https://forums.bistudio.com/forums/topic/183541-creating-a-basic-kill-feed/
by kaysio Posted August 5, 2015

3 different type of notification available
All the 3 can display together 
+ Display kills on chat 
The Kills show on global ( systemChat )
To enable the others remove the  // 
*/

publicVariable "Killfeed_notification";

addMissionEventHandler ["EntityKilled", 
{
	params ["_killed", "_killer"];
	
	if ((_killer==player) or (_killer == vehicle player)) then
	{
	
	if (_killed isKindOf "CAManBase" 			
	&& {((side group _killed) == west || 
		(side group _killed) == east || 
		(side group _killed) == independent || 
		(side group _killed) == civilian ||
		(side group _killed) == sideLogic)}
		
	)then
	{
	
	_line = "";
	_killerName = "";
	_victimName = "";
	_killerString = "";
	_victimString = "";
	_killerColor = "#99D5FF";
	_victimColor = "#99D5FF";


	_victim = _this select 0;
	_killer = _this select 1;

		
	if (!(isplayer _killer)) then {
		_killerName = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _killer] >> "Displayname");
		if(vehicle _killer != _killer) then {_killerName = getText (configFile >> "CfgVehicles" >> format["%1 crew",typeof vehicle _killer] >> "Displayname")};
		}else{_killerName = name _killer};

	if (!(isplayer _victim)) then {
		_victimName = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _victim] >> "Displayname");
		if(vehicle _victim != _victim) then {_victimName = getText (configFile >> "CfgVehicles" >> format["%1 crew",typeof vehicle _victim] >> "Displayname")};
		}else{_victimName = name _victim};

	if ((_killer==player) or (_killer == vehicle player)) then
		{
		_killerColor = "#ffff00"; //yellow
		}
		else
		{
		_killerColor = side group _killer call BIS_fnc_sideColor;

			_r = _killerColor select 0;
			_g = _killerColor select 1;
			_b = _killerColor select 2;

		_killerColor = [_r+0.1,_g+0.1,_b+0.1];

		_killerColor = _killerColor call BIS_fnc_colorRGBtoHTML;

		};

	if (_victim==player) then
		{
		_victimColor = "#ffff00"; //yellow
		}
		else
		{
		_victimColor = side group _victim call BIS_fnc_sideColor;

			_r = _victimColor select 0;
			_g = _victimColor select 1;
			_b = _victimColor select 2;

		_victimColor = [_r+0.1,_g+0.1,_b+0.1];
		
		_victimColor = _victimColor call BIS_fnc_colorRGBtoHTML;
		
		};

	_killerString = format["<t color='%1'>%2</t>",_killerColor ,_killerName];
	_victimString = format["<t color='%1'>%2</t>",_victimColor,_victimName];

	//the line which shows the final formatted kill
	_line = switch(true) do {
		case(_killer == _victim): {format ["%1  Killed Themselves",_killerString]};
		case(isNull _killer): {format ["%1  is out of Luck!",_victimString]};
		default {format ["%1  Killed  %2",_killerString,_victimString]};
	};
	_line;	
	
	//_____________________________________________________________________________
	
	
	_victim = _this select 0;
	_killer = _this select 1;

	//_victimName = "";	
	_victimString = "";
	_victimColor = "#99D5FF";

	private _distance = _killer distance2D _victim; //Distance
	
	private _killweapon = getText(configFile >> "CfgWeapons" >> currentWeapon (vehicle _killer) >> "displayname"); //Weapon

	if (!(isplayer _victim)) then {
		_victimName = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _victim] >> "Displayname");
	if(vehicle _victim != _victim) then {_victimName = getText (configFile >> "CfgVehicles" >> format["%1 crew",typeof vehicle _victim] >> "Displayname")};
		}else{_victimName = name _victim};

	_victimColor = (side group _victim call BIS_fnc_sideColor) call BIS_fnc_colorRGBtoHTML;

	_victimString = format["<t color='%1'>  %2  <t color='#FFD700'>  %3 m</t>",_victimColor,_victimName,floor _distance];

	_line = if ((_killer == player) and (_victim == player)) then {
		"<t size='2.5'>WASTED !</t>";
		//you can playSound here when killed
	} else {
		format ["<t size='0.5'>Killed  <t size='0.8'> %1</t>",_victimString];
	};	

 	[_line,0,0.3,2,0,0,7017] spawn bis_fnc_dynamicText;	//0,0.8,2,0,0,7017 
	
	//_____________________________________________________________________________
			
	/*
	Extra Line for systemChat , run on every PC to show the kills on global
	https://community.bistudio.com/wiki/BIS_fnc_MP
	*/	
		
	[format["%1  Killed  %2  from  %3 m  with  %4", name player,_victimName,floor _distance,_killweapon],"systemChat"] call BIS_fnc_MP;
	
	//_____________________________________________________________________________
			
	playSound "Killfeed_notification";	
	//_____________________________________________________________________________
/* 
    Number: X coordinates (optional)
    Number: Y coordinates (optional)
    Number: Duration (Optional)
    Number: FadeIn time (Optional)
    Number: Delta Y, Text will move up or down depending on value (Optional)
    Number: Resource layer (Optional)
	
	f00000ff blue
	FF0000 red
	FFD700 gold
	000000 black
*/
	//_____________________________________________________________________________
	
	//2 Different type of notification	
	
	// Cannot get bis_fnc_dynamicText , run on every PC to show on global, if anyones knows how , please contact 
_victim_parsetext = format["%1  Killed <t color='%2'>  %3  <t color='#FFD700'> from   %4 m   with  <t color='#FF0000'> %5</t>",name _killer,_victimColor,_victimName,floor _distance,_killweapon];
publicVariable "_victim_parsetext";
		
	//_____________________________________________________________________________
	
	// 1	Hint 
	//	hintsilent parsetext _victim_parsetext;
	
	// 2	Center up screen
	["<t size='0.6' align='right' with  %4 >" + _victim_parsetext + "</t>",safeZoneX,safeZoneY,10,0,0,7016] call bis_fnc_dynamicText; //10,0,0,7016
	
//	[["<t size='0.6' align='right' with  %4 >" + _victim_parsetext + "</t>",safeZoneX,safeZoneY,10,0,0,7016] call bis_fnc_dynamicText] call BIS_fnc_MP;
	
	// hint"Killfeed working";	
	};
	};				
}];

 

  • Confused 1

Share this post


Link to post
Share on other sites

Your addMissionEventHandler must run on every PC. Consider your bis_fnc_dynamictext as an HUD, so local.

You don't need to publicVariable anything because all Pcs have the same Event. Remove all comments in your EH code.

  • Thanks 1

Share this post


Link to post
Share on other sites
5 hours ago, pierremgi said:

Remove all comments in your EH code.

 

Thank you pierremgi!

 

but to be honest... i don't get it!

First ,  you are saying maybe about the question in the main topic of the script?

https://forums.bohemia.net/forums/topic/206593-headshot-killfeed-script/?page=2&tab=comments#comment-3275573

 

Because ,  i made also another ,  different question in the main topic  , that has to do with EventHandler ,

but there is no EventHandler in the code above.

 

I also post this question seperate , to avoid misunderstanding with the main topic question.

 

The problem ,  is that the others players don't get the notification ,  in the message center screen above.

TLCVPkq7Qzij0OzWnVCTLg.png

 

 

So far only the killfeed on systemchat is showing in global.

 

 

Share this post


Link to post
Share on other sites
29 minutes ago, GEORGE FLOROS GR said:

 

First ,  you are saying maybe about the question in the main topic of the script?

https://forums.bohemia.net/forums/topic/206593-headshot-killfeed-script/?page=2&tab=comments#comment-3275573

 

Because ,  i made also another ,  different question in the main topic  , that has to do with EventHandler ,

but there is no EventHandler in the code above.

 

 

 

 

 

addMissionEventHandler ["EntityKilled", ....  ???? in killfeed.

But perhaps, i'm lost in all your lines, commented or not.

Your error message comes from Bis_fnc_dynamicText, and as far I understood, It's embedded inside this MEH.

Anyway, there are suspensions for script (sleep , waitUntil) inside this function. It should be spawned. So try with something like:

 

["<t size='0.6' align='right' with  %4 >" +

format ["%1  Killed <t color='%2'>  %3  <t color='#FFD700'> from   %4 m   with  <t color='#FF0000'> %5</t>",name player,_victimName,floor _distance,_killweapon,"systemChat"] +

"</t>",safeZoneX,safeZoneY,10,0,0,7016] spawn bis_fnc_dynamicText;

 

  • Thanks 1

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

with something like:

 

Thanks pierremgi for your time , i 'll check it!

Share this post


Link to post
Share on other sites
2 minutes ago, davidoss said:

I am always run MEH on server and remoteexec stuff to client.

So i should also remoteExec  this?

Share this post


Link to post
Share on other sites

Here you have an example:

 

if (isServer) then {
	addMissionEventHandler ["EntityKilled", {	

		params [["_killed",objNull,[objNull]],["_killer",objNull,[objNull]],["_instigator",objNull,[objNull]]];
		if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0};
		if (isNull _instigator) then {_instigator = _killer};
		0 = [
			[name _killed, name _instigator],
			{systemChat format ["%1 was killed by %2",_this select 0,_this select 1]}
		] remoteExecCall ["call", [0,-2] select isDedicated, false];
	}];
};

 

  • Thanks 1

Share this post


Link to post
Share on other sites
5 hours ago, davidoss said:

I am always run MEH on server and remoteexec stuff to client.

As a general rule, it's a very bad idea. There is no reason to do that, except if you want to load the network.

 

  • Like 2

Share this post


Link to post
Share on other sites
On 3/11/2018 at 10:42 AM, pierremgi said:

spawn bis_fnc_dynamicText;

 

Thanks pierremgi!

 

I noticed that i messed it , with call instead of spawn for some reason!

 

for global execute i added:

[["<t size='0.5' align='left' with  %4 >" + _killed_parsetext + "</t>",safeZoneX,safeZoneY,10,0,0,7016] spawn bis_fnc_dynamicText] call BIS_fnc_MP;

but i haven't test this yet.

  • Thanks 1

Share this post


Link to post
Share on other sites

You definitely don't need to remoteExec or bis_fnc_MP it.   Why?

 

You just want to keep players informed of who killed who.

So, If you place the MEH on server only, the code will run... on server only. So, yes, you need to remoteExec / bis_fnc_MP something to be displayed on each screen.

That's network resource demanding for nuts.

If you place the MEH in init.sqf for instance, your code (event then local code) will run on each PC. The MEH can be truly supported locally.

So, as victim and killer are same for everyone, there is no reason at all to have an exchange of data between the server and all the clients for that.

Just let the MEH triggers locally and that's roll without any problem, like any hint or HUD display or local thing.

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 3/11/2018 at 11:53 PM, GEORGE FLOROS GR said:

 

Thanks pierremgi!

 

I noticed that i messed it , with call instead of spawn for some reason!

 

for global execute i added: 


[["<t size='0.5' align='left' with  %4 >" + _killed_parsetext + "</t>",safeZoneX,safeZoneY,10,0,0,7016] spawn bis_fnc_dynamicText] call BIS_fnc_MP;

but i haven't test this yet.

 

since i show this old post ,

this should be :

//________________	2. Left Corner up display	________________
_BIS_fnc_dynamicText_info=[["<t size='0.6' align='left' with  %4 >" + _kill_info + "</t>",safeZoneX,safeZoneY,10,0,0,7016] remoteExec ["BIS_fnc_dynamicText"]];

 

  • Like 1

Share this post


Link to post
Share on other sites

Erfff! George, I'm not sure to understand why you remoteExec some HUD code + the EH "killed" script by its own... You just have to run the "MPKilled" MP EH in initPlayerLocal.sqf, or even the Mission EH "entityKilled" in init.sqf.

 

Did you try to let all the stuff local? The only things which should be broadcast are the shared data (kill counts, by publicVariable) if you feel there can be some differences between PC). for the rest... why do you want to broadcast what PCs are able to do locally?

 

Btw, if (!local player) exitWith {}; is just a waste of code. Player is always local,... AFAIK.

  • Like 1

Share this post


Link to post
Share on other sites
28 minutes ago, pierremgi said:

Btw, if (!local player) exitWith {}; is just a waste of code.

Maybe it's just a stupid isNull aka isDedicated check?

Share this post


Link to post
Share on other sites
11 hours ago, pierremgi said:

You just have to run the "MPKilled" MP EH in initPlayerLocal.sqf, or even the Mission EH "entityKilled" in init.sqf. 

 

Thank you Pierre !

 

To be honest , now that i'm looking at the script , i do realize it !

I have written a lot of code so far , but everyday i see that there is something new to learn , reading the forum and wiki and i have notice a lot of bad coding in my scripts !

It's not also that easy to update everything , i would do this if i had the time though.

  • Like 1

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

×