Skagget 11 Posted September 26, 2011 I would like to have a sidechat where I see how my team progress. So I saw this post http://forums.bistudio.com/showthread.php?t=124141 And I thought; is there a way to get it to look like: " Adam kills a Takistan Rifleman " Where I catch the ace name with %1 I guess. But how about giving enemy units a name like just Rifleman instead of its class of "Soldier Light" as an example. So when I shoot an enemy it will broadcast that sidechat msg to all in the MP. Share this post Link to post Share on other sites
lucilk 10 Posted September 26, 2011 //add a event handler on all units { if (side _x==WEST) then { _x addMPEventHandler ["mpkilled", {_this execVM "playerkilled.sqf";}]; }; } foreach allunits; //playerkilled.sqf _killed = _this select 0; _killer = _this select 1; //check first if _killed is a player if (!isplayer ) then { [[west,"HQ"],nil,rSIDECHAT,format ["%1 killed %2",name _killer,name _killed]] call RE; } else { //if killed is an AI get his type _AItype = typeof _killed; _AIdisplname = getText (configFile >> "CfgVehicles" >> _AItype >> "displayName"); //broadcast message [[west,"HQ"],nil,rSIDECHAT,format ["%1 killed a %2",name _killer,_AIdisplname]] call RE; }; not tested, but should give you an idea Share this post Link to post Share on other sites
Skagget 11 Posted September 27, 2011 Hiya, thanks for the effort but no show. Ive tried to turn off all addons and just pure me and an opfor. Tried it in both just editor and preview, that didnt work, tried it as saved MP and put it up on the server and not working. Not the best scripter around so cant say AHA in what can be the factor for it not working as intended. Ive put the code in the soldiers init and nothing on the opfor enemy. The sqf file is in the folder. Trying to eleminate something I did wrong hehe :) Is there anything as looking through the code once more that stands out ? Share this post Link to post Share on other sites
twirly 11 Posted September 27, 2011 Just a wild shot at this....but do you have the Functions Module placed on the map? Share this post Link to post Share on other sites
Skagget 11 Posted September 27, 2011 Nope nothing on the map. (tried with the Functions and nothing there aswell) I went first with all my addons and thought that was the key to it all. So then I went for just me and an opfor enemy, so no modules, no extra nothing.. me and the enemy on the map with my player init having the code to execVM and the sqf in same mission folder. Share this post Link to post Share on other sites
Muzzleflash 111 Posted September 27, 2011 Since you would need an event handler for all players anyway why not just add an ordinary killed event handler locally for each: deathfunction = { _dead = _this select 0; _killer = _this select 1; if ( {isPlayer _x} count [_dead, _killer] < 1) exitWith {}; if (_dead == _killer) exitWith {[side player, "HQ"] sideChat format ["%1 killed himself", name _killer];}; [side player, "HQ"] sideChat format ["%1 killed %2", _killer, typeOf _dead]; }; { _x addEventHandler ["killed", {_this call deathfunction;}]; } forEach allUnits; Share this post Link to post Share on other sites
Skagget 11 Posted September 28, 2011 Muzzleflash > Your idea works great in SP I guess and local. But as per multiplayer the kill isnt broadcasted to all in the multiplayer. So something in between. Did some reading in the sidechat, and it stated you can use it but you have another code to get it broadcasted to all in your group. Share this post Link to post Share on other sites
Muzzleflash 111 Posted September 28, 2011 Yeah you're right. Somehow I my understanding the killed and hit event handlers got wrong even though I've used them a lot before. Anyway my point is you don't need to broadcast it yourself. Just use the addMPEventHandler for each machine (player) instead. In the handler code you sideChat or something. sideChat is only run on the local machine meaning if you only register the event on one machine, eg. the server then yes you would need to broadcast some message that it's time to do a sideChat. If you add the handler for each machine then you don't have to broadcast it. Share this post Link to post Share on other sites
Skagget 11 Posted September 28, 2011 Are we talking about two diffent things maybe. If I add the code in all init/players, then yes they will see a sideChat if they kill a enemy. But they wount see if I kill a enemy. What would be nice = is if I shoot an enemy, I will see the sidechat of course but you will see it on your computer aswell. So I guess the eventhandler must be broadcasted, and is that what the "addMPEventHandler" will do ? Share this post Link to post Share on other sites
Muzzleflash 111 Posted September 29, 2011 I'm assuming you are only interested in kills or deaths involving at least one player. Meaning you are not interested in knowing whether an AI killed another AI. If you are then this can be easily be fixed in my below solution. What you propose it to add an event handler for allunits for each player. Then when the event happens you check whether the player was involved. If it was then you broadcast a message. So if you have player A, B and C then each check if they were the killer. Let's say B and C wasn't so they don't do anything. A, however was the killer, so he broadcast a message that he killed someone. What I propose it that you already have the information you need on each machine. There no reason to manually broadcast anything. player B and C (and A) can check themselves to see if player was involved and sideChat the correct message. I changed my previous example to use addMPEventHandler instead. Try this one (put it in init.sqf for example) out, it should work. Will only show kills involving at least one player: deathfunction = { private ["_dead","_killer"]; _dead = _this select 0; _killer = _this select 1; if ( {isPlayer _x} count [_dead, _killer] < 1) exitWith {}; if (_dead == _killer) exitWith {[side player, "HQ"] sideChat format ["%1 killed himself", name _killer];}; [side player, "HQ"] sideChat format ["%1 killed %2", name _killer, name _dead]; }; { _x addMPEventHandler ["mpkilled", {_this call deathfunction;}]; } forEach allUnits; If you wish for better description of AI units then look at the bottom of lucilk's code post. Share this post Link to post Share on other sites
Skagget 11 Posted September 29, 2011 The code you provided works like a clockwork. Thats what I was looking for ! :) Great thanks.. dont want to know what AI kills or so hehe. Easy way to get "NAMEPLAYER killed an enemy" or as lucilk code with the "CfgVehicles" and get a "Riflemen" instead of name of the unit.. will be kind of comedy fun to see "NAMEPLAYER killed Mashiri Shalan", that doesnt mean much rather then it was the name of the unit :D Great work once again ! Share this post Link to post Share on other sites
froggyluv 2136 Posted October 3, 2011 Hi, I kind of get this code but not :o I need help getting a sound played when only a certain hit squad kills members of another group. Hit Squad name: Bull1 (2 members) Enemy squad: E3 (15 members) So basically I know how to bring up the kill messages, but how do I isolate to only one group's kills? Share this post Link to post Share on other sites