gazac 11 Posted October 20, 2013 I'm after help to do a kill count for a 4 player co-op, it would show on screen playername 1: xx OPFOR kills playername 2: xx OPFOR kills playername 3: xx OPFOR kills playername 4: xx OPFOR kills then keep it on screen all the time updating it could this be done? Share this post Link to post Share on other sites
shuko 59 Posted October 20, 2013 There is probably multiple ways to do it. I'd add "hit" eventhandlers to enemies on server and then make server update the score with publicvariable (clients having pubvar eventhandlers). Share this post Link to post Share on other sites
zealot111 13 Posted October 22, 2013 You may try something like this. I tried this code and it works fine at first glance. init.sqf hc_killedBy = ""; hc_kills = []; if (isServer) then { { _x addMPEventHandler ["MPKilled", {[_this] execVM "onKilled.sqf";}]; } forEach allUnits; }; and onkilled.sqf private ["_rn","_obj","_this"]; fn_getRealName = { _rn = ""; _obj = _this; if (!(isplayer _obj)) then { _rn = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _obj] >> "Displayname"); if(vehicle _obj != _obj) then {_rn = getText (configFile >> "CfgVehicles" >> format["%1 crew", typeof vehicle _obj] >> "Displayname")}; }else{_rn = name _obj}; _rn; }; private ["_text","_x","_this"]; fn_genDiaryText = { _text = ""; if (hc_killedBy != "") then { _text = _text + format ["Killed by: %1 \n",hc_killedBy]; }; _text = _text + "Killed: \n"; { _text = _text + format ["%1 \n",_x]; } foreach hc_kills; _text; }; private ["_victim","_killer","_killerName","_victimName","_txt"]; if (isDedicated) exitWith {}; _victim = (_this select 0) select 0; _killer = (_this select 0) select 1; _killerName = _killer call fn_getRealName; _victimName = _victim call fn_getRealName; if (_victim == player) then { player sideChat format["%1 killed by %2 ",_victimName,_killerName]; hc_killedBy = _killerName; } else { hc_kills = hc_kills + [_victimName]; }; _txt = [] call fn_genDiaryText; hint _txt; Share this post Link to post Share on other sites
gazac 11 Posted November 2, 2013 Thanks zealot111, your scripts work great but it not what I need, I think Shuko maybe right with eventhandlers to enemies on server and then make server update the score with publicvariable (clients having pubvar eventhandlers). What I need it to do is keep a list of kills from each player [4 player coop] then show them all by hint on the screen like this all shown in there real names Ben kill count: 10 Ken kill count: 6 Bill kill count: 3 Gary kill count: 8 I have got this so far, it works in single play but I need it to work in 4 player Coop Killcount = 0; p1="gary"; // testing only fnc_showOpDeathCount = { hintsilent format ["%1 Kills Count: %2",p1,Killcount]; }; if isServer then { fnc_countOpDeaths = { Killcount = Killcount + 1; publicvariable "Killcount"; if !isDedicated then { call fnc_showOpDeathCount; }; }; { if (side _x == EAST) then { _x addMPEventHandler ["MPKilled",fnc_countOpDeaths]; }; } foreach allUnits; } else { "Killcount" addPublicVariableEventHandler {call fnc_showOpDeathCount}; }; Share this post Link to post Share on other sites