XxKAIMANxX 10 Posted January 19, 2014 Hi, i'm learning some mission scripting and i would like to get the name of the killer of another player or AI and the weapon used and print that info in the chat. For example: "Player1 killed Player2 with MX 6,5mm" The problem is that i have no idea where to start from, so if you guys could help me... Thanks. Share this post Link to post Share on other sites
iceman77 18 Posted January 19, 2014 (edited) Method#1 (not so great) init.sqf { _id = _x addMPEventHandler ["MPKilled", { _victimName = name (_this select 0); _killerName = name (_this select 1); _weaponName = getText (configFile >> "cfgWeapons" >> currentWeapon (_this select 1) >> "displayname"); hintSilent format ["%1 was killed by %2 with a %3", _victimName, _killerName, _weaponName]; }]; } foreach allUnits; note: According to the wiki it's not good practice to run code directly from a MP eventHandler's code space, as the code space will be transferred over network, each time the EH fires. You'd be better off storing the code into a variable / function, and running the function from the EH instead == smaller data to transfer over the network. Method#2 (proper) init.sqf KAI_fnc_killedInfo = { _victimName = name (_this select 0); _killerName = name (_this select 1); _weaponName = getText (configFile >> "cfgWeapons" >> currentWeapon (_this select 1) >> "displayname"); hintSilent format ["%1 was killed by %2 with a %3", _victimName, _killerName, _weaponName]; }; { _id = _x addMPEventHandler ["MPKilled", { _nul = _this call KAI_fnc_killedInfo; }]; } foreach allUnits; Edited January 20, 2014 by Iceman77 1 Share this post Link to post Share on other sites
XxKAIMANxX 10 Posted January 20, 2014 Thanks so much, it is really helpful. Share this post Link to post Share on other sites