Tuliq 2 Posted March 10, 2013 (edited) UPDATED: 07.04.2013! Thought I'd post this. This is a simple more advanced killticker I've created for use in my own missions. Thought some other people might have use of it as well. It's not hard to implement. For AI it displays classname of unit, for player it displays user name. It shows a maximum of 8 kills at a time, but this you are of course free to change. killTicker.sqf tlq_killTicker = { _this addMPEventHandler ['MPKilled',{ _unit = _this select 0; _killer = _this select 1; _newKill = [_unit,_killer]; if (count tlq_killArray > 100) then {tlq_killArray = []}; tlq_killArray set [count tlq_killArray,_newKill call tlq_parseKill]; [] spawn tlq_killList; if (player == _killer) then {_newKill spawn tlq_killPopUp}; } ]; }; tlq_parseKill = { _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 ["Bad luck for %1",_victimString]}; default {format ["%1 killed %2",_killerString,_victimString]}; }; _line; }; tlq_killPopUp = { _victim = _this select 0; _killer = _this select 1; _victimName = ""; _victimString = ""; _victimColor = "#99D5FF"; 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>",_victimColor,_victimName]; _line = if ((_killer == player) and (_victim == player)) then { "<t size='0.5'>You killed yourself</t>"; } else { format ["<t size='0.5'>You killed %1</t>",_victimString]; }; [_line,0,0.8,2,0,0,7017] spawn bis_fnc_dynamicText; }; tlq_killList = { //flush kills and show most recent if (time - tlq_killTime > 37) then { tlq_displayedKills = []; }; tlq_displayedKills set [count tlq_displayedKills, tlq_killArray select (count tlq_killArray - 1)]; _tickerText = ""; _c = 0; for "_i" from (count tlq_displayedKills) to 0 step -1 do{ _c = _c + 1; _tickerText = format ["%1<br />%2",tlq_displayedKills select _i,_tickerText]; if (_c > 8) exitWith{}; }; hintsilent parsetext _tickerText; //["<t size='0.4' align='right'>" + _tickerText + "</t>",safeZoneX,safeZoneY,10,0,0,7016] call bis_fnc_dynamicText; tlq_killTime = time; }; //declare global variables tlq_killArray = []; tlq_displayedKills = []; tlq_killTime = 0; //start kill registration for player if (!isNull player) then { player spawn tlq_killTicker; }; if (isServer) then { //ai { if (!(isPlayer _x)) then { _x spawn tlq_killTicker}; } forEach allUnits; }; Hotfix 07.04.2013: Tweaked things regarding dedicated servers Changes 31.03.2013: Fixed bug that caused no kills to get displayed clientside Fixed deletion of kills when lot of kills were happening Moved kill detection clientside because of locality issues Changes 30.03.2013: Fixed bugs that caused script not to fire Brightened up colors on kills to increase readability Made global variables unique as to not interfere with other scripts Added "tlq_killTicker_init" variable to check if script has initialized Changes 21.03.2013: Now registers much more accurately for aoe-based weapons (grenades, bombs) Kill detection handled by server (or hosting player) Colors for killed players now reflect their ingame color (blufor blue, opfor red). Fixed some bugs relating to unexpected types of deaths Now registers kills for ALL editor-placed units by default (includes playable units waiting to spawn) Known bugs: When player disconnects from an ai-disabled slot, script will fire. Installation: Place in your mission folder and run "killTicker.sqf" from init.sqf like so: null = execVM "killTicker.sqf"; To add kill detection to units created during mission, run the following command after creation: yourunitName spawn tlq_killTicker; Edited April 7, 2013 by Tuliq Share this post Link to post Share on other sites
R3ality 1 Posted March 10, 2013 Looks great! I'll surely check this out in action.. Share this post Link to post Share on other sites
Tuliq 2 Posted March 10, 2013 Great! I updated it to make it a lot easier to implement. Remember that this script uses hint for its kill display, so it might not be for everyone. Share this post Link to post Share on other sites
darkxess 60 Posted March 10, 2013 (edited) Release frontpaged on the Armaholic homepage. [ALPHA] Basic killticker v0.1 Edited March 10, 2013 by DarkXess fixed the image link Share this post Link to post Share on other sites
Tuliq 2 Posted March 10, 2013 Thanks! Nice to see this getting some exposure! :) Share this post Link to post Share on other sites
ayser 1 Posted March 11, 2013 Lovely little script! Works great when i'm not trying to use the pictures, but when I remove all of the //'s, I get a error on line 91, which is <img size='2' image='%3'/> Isn't this an HTML script? How would I use this? As even though everything us uncommented, but leave this line commented, no pictures show :( Share this post Link to post Share on other sites
bjwimer 1 Posted March 11, 2013 Very nice script. I changed just one line just so I can see the weapon name in the kill message. You did all the work naming things I just used them :). Now if I can figure out how to get it to say the name of the gun instead of the classname. {format ["%1 killed %2 with %3",_killerString,_victimString,_killweapon]}; Share this post Link to post Share on other sites
Tuliq 2 Posted March 11, 2013 Hey thanks! Glad you have found use of it. To show the real name of the weapon you could create a weaponName variable and grab the displayname from config like so: _weaponName = getText(configFile >> "CfgWeapons" >> format ["%1",_killweapon] >> "displayname"); replace this variable with the killerweapon one on the line format. Adding pictures require thar you copy the <img> stuff into the string of the _line variable. It is structured text code and doesnt work alone. You need to also add the weaponpic variable into the format array. Hope this helps! Share this post Link to post Share on other sites
bjwimer 1 Posted March 12, 2013 ahh very nice. Learn something new every day. I also "borrowed" a line from another mission I played where you get the distance. Added that to the text and it looks pretty spiffy. Like you, I agree the pictures make it look... blech. However with weapon name/distance it looks nice and gets the point across. For those wanting the extra lines... just add _dist = round (_victim distance _killer); then change {format ["%1 killed %2 with %3 from %4 meters",_killerString,_victimString,_weaponName,_dist]}; and you get "Bob killed Bob with peashooter from 600 meters" Share this post Link to post Share on other sites
Vigil Vindex 64 Posted March 13, 2013 I've noticed that when using this with AI units spawned during the mission, these units don't have the handler added to them. Perhaps the bit that adds the event handler could be changed to a loop that only adds the handler to units that don't already have it? Share this post Link to post Share on other sites
blinger 1 Posted March 14, 2013 so should i be using null = "ALL" execVM "killTicker.sqf"; or unit spawn killticker; if i want this to show all kills during a TDM? Share this post Link to post Share on other sites
Tuliq 2 Posted March 21, 2013 Script has been updated :) The new script might suit you better, blinger. It should work for all playable units present in edtior. Share this post Link to post Share on other sites
Fuby 10 Posted March 22, 2013 Nice work Tuliq... really like the script!! Share this post Link to post Share on other sites
Guest Posted March 22, 2013 (edited) With a little delay, new version frontpaged on the Armaholic homepage. Basic killticker [ALPHA] v30.03.2013 Edited March 30, 2013 by Guest mirror updated Share this post Link to post Share on other sites
Vigil Vindex 64 Posted March 29, 2013 I've not been able to get this to work for me. I'm not sure if it's because I am spawning AI during the mission, but even when I die the ticker doesn't fire. Since the script doesn't use the "ALL" settings anymore, is there any other change that might be needed to ensure this works? Also I noticed you have removed the weapons and distance parts, are you going to add those or are they removed because there is a problem? Share this post Link to post Share on other sites
Tuliq 2 Posted March 29, 2013 During some tests I have found that there are a bunch of problems with the script right now. I can upload the version I am currently using myself , which has endured extensive testing, and most of the problems like you mentioned should be fixed. I will do this ASAP. For as the weapon and distance parts, I removed them because I personally had no use of them, and they did not register correctly for grenades or bombs. Using a combination of the "killed" and "fired" eventhandler, weapon detection could be done much more accurately. That would be my ideal solution. Share this post Link to post Share on other sites
Tuliq 2 Posted March 30, 2013 (edited) Script is updated again, should work a lot more reliably now. If anyone encounters problems making it work, please post here! :) Edited March 30, 2013 by Tuliq Share this post Link to post Share on other sites
braveblades 1 Posted March 30, 2013 Tuliq, sorry for newbie question, but how exactly run your script. i call it in init.sqf, and... then? :( Share this post Link to post Share on other sites
Tuliq 2 Posted March 31, 2013 (edited) No problem! After you add the line null = execVM "killTicker.sqf" , the script should start running for all units present in editor. If you are adding kill detection to units spawned in during mission, you must do a %unitname% spawn tlq_killTicker; I just fixed a bug that had caused no kills to display if you were a client on a server. Should be fixed now. Just had another major fix-session with my buddy. We seem to have fixed most of the problems I know of atm. I recommend everyone using this script to get the current version posted in the op before trying the script. Edited March 31, 2013 by Tuliq Share this post Link to post Share on other sites
Slammin 10 Posted April 1, 2013 To show the real name of the weapon you could create a weaponName variable and grab the displayname from config like so: _weaponName = getText(configFile >> "CfgWeapons" >> format ["%1",_killweapon] >> "displayname"); replace this variable with the killerweapon one on the line format. Thanks for the great script Tuliq! We got everything working except for the weapon part. Please correct me if I overlook something! Do I need to setup a configFile "CfgWeapons" manually to display the killweapon? Or do I need to define _killweapon in someway, which is not in killTicker.sqf by default? (Despite you have excluded the weapon info due to the fact it does not work correctly with grenades and such, we would like to implement it.) Share this post Link to post Share on other sites
Tuliq 2 Posted April 2, 2013 (edited) Hi! Thanks for the praise! Basically add: _killweapon = getText(configFile >> "CfgWeapons" >> format ["%1",currentWeapon _killer] >> "displayname"); after _killer has been defined in the tlq_parsekill function. Then edit _line as such: _line = switch(true) do { case(_killer == _victim): {format ["%1 killed themselves",_killerString]}; case(isNull _killer): {format ["Bad luck for %1",_victimString]}; default {format ["%1 killed %2 with %3",_killerString,_victimString,_killWeapon]}; }; I added the _killweapon string into the format of the default case of the switch (which is the standard kill message). Of course you will have to adjust the formatting of the kill line to your own tastes :) Now it is like "Slammin killed Tuliq with BB Gun". For the next version of the script I want to get rid of the hint - box, and instead use bis_fnc_dynamicText to display the kill list. Only problem is I just can't seem to get the positioning right across all different aspect ratios and interface sizes. Would totally appreciate if someone could tell me how to do this. Edited April 2, 2013 by Tuliq Share this post Link to post Share on other sites
Slammin 10 Posted April 2, 2013 Cheers Tuliq! We've got it all working now with the two codes you posted above. Wish I could be of any assistance with your bis_fnc_dynamicText-positioning request. I keep an eye out if I come across something that might be useful! Share this post Link to post Share on other sites
Amplifier 1 Posted April 7, 2013 Hi, i am new in this forums and this ist my first try to creating MP maps. I tryed to install and run the killticker for me and its working when i test it in the editor. But when i am uploading the mpmission on a server and try to test it, the killticker does not work. Can anybody help me to fix that problem, what did i do wrong. Share this post Link to post Share on other sites
Tuliq 2 Posted April 7, 2013 (edited) Hey! I think this could me my fault. I don't really have much experience with dedi-server scripting. Can you try this fix? Go to if (local player) then { player spawn tlq_killTicker; }; and replace with if (!isNull player) then { player spawn tlq_killTicker; }; Maybe this will work :) Also, are you exporting the mission into PBO format? If that is the case, it would be wise to unpack the PBO and check if all the scripts were transferred correctly. Use something like Eliteness to unpack and repack pbo's. Edited April 7, 2013 by Tuliq Share this post Link to post Share on other sites
Amplifier 1 Posted April 7, 2013 Thanks for the quick response. Also, are you exporting the mission into PBO format? If that is the case, it would be wise to unpack the PBO and check if all the scripts were transferred correctly. Use something like Eliteness to unpack and repack pbo's. I have checked this, all files incl. killTicker.sqf are on the server. sry but where can i find this lines in killTicker.sqf ? if (local player) then { player spawn tlq_killTicker; }; Share this post Link to post Share on other sites