saddle 19 Posted June 27, 2023 Hello everyone, I am looking all over the place recently if there is any script or code out there that simply just works in MP and displays, say if you play with a few friends, all the players and simply their kill count on a small text list on screen. We are not satisfied with how the score board works in Arma and want something what we think is a bit more concrete display of number of kills, where everyone, including civilians adds +1 to number of kills for the individual player. Or if not binding the score to a player, maybe bind it to a unit's variable name to show. https://techlethal.com/2013/03/21/arma-3-alpha-scripting-a-kill-counter-that-keeps-track-of-ai-kills/ This is the closest I got, but it only works in SP. Any tips or feedback is appreciated! Share this post Link to post Share on other sites
Dramacius 8 Posted June 28, 2023 this might help you get started in your initplayer.sqf add the following: score = 0; add this to the init of all the ai units possibly using the following in your init.sqf { this addEventHandler ["Killed",{ params ["_unit", "_killer"]; score = score + 1; systemChat format ["%1 has been killed by %2. Current Score %3", _unit, _killer, score]; }]; } forEach allUnits; This is untested and off the top of my head but might help you get started on something. Share this post Link to post Share on other sites
saddle 19 Posted June 29, 2023 19 hours ago, Dramacius said: this might help you get started in your initplayer.sqf add the following: score = 0; add this to the init of all the ai units possibly using the following in your init.sqf { this addEventHandler ["Killed",{ params ["_unit", "_killer"]; score = score + 1; systemChat format ["%1 has been killed by %2. Current Score %3", _unit, _killer, score]; }]; } forEach allUnits; This is untested and off the top of my head but might help you get started on something. Thanks Dramacius, i'll give this a try! [EDIT] It does not work, at least not in multiplayer, no systemChat message either. Going to see if I can make some edits. Share this post Link to post Share on other sites
Dramacius 8 Posted June 29, 2023 32 minutes ago, saddle said: Thanks Dramacius, i'll give this a try! [EDIT] It does not work, at least not in multiplayer, no systemChat message either. Going to see if I can make some edits. Yeah, it was all done from top of my head no testing, hopefully it should give you a starting position to work out what you want to acheive too. format ["%1 %2 message", variable%1, variable%2] remoteExec ["hint", 0]; that might be useful to you too I prefer it over system message as that requires to player to have a radio where hint doesn't Share this post Link to post Share on other sites
Harzach 2518 Posted June 29, 2023 "score" is a scripting command. Use descriptive variables, or prepend your variables with your tag. 1 Share this post Link to post Share on other sites
saddle 19 Posted June 30, 2023 If I want it to display as simple texts and numbers on the screen for all players at all times, i'll look into titleText commands too. For example simple text in a corner showing Playerinthegame1: 0 Playerinthegame2: 0 Playerinthegame3: 0 Sorry, I appreciate the help but I am trying to make sense of it. I'll make some more tries later today when I am home! Share this post Link to post Share on other sites
Dramacius 8 Posted June 30, 2023 format ["%1 %2 message", variable%1, variable%2] remoteExec ["hint", 0]; will disaply a hint for all players Share this post Link to post Share on other sites
saddle 19 Posted July 1, 2023 15 hours ago, Dramacius said: format ["%1 %2 message", variable%1, variable%2] remoteExec ["hint", 0]; will disaply a hint for all players Trying to add score = 0; to initPlayerLocal.sqf and { this addEventHandler ["Killed",{ params ["_unit", "_killer"]; score = score + 1; systemChat format ["%1 has been killed by %2. Current Score %3", _unit, _killer, score]; }]; } forEach allUnits; to Init.sqf and then format ["%1 %2 message", variable%1, variable%2] remoteExec ["hint", 0]; into the player unit's intialization field. is this all ai units you mean? I am probably doing something wrong, because it is not working sorry. Share this post Link to post Share on other sites
Harzach 2518 Posted July 1, 2023 41 minutes ago, saddle said: I am probably doing something wrong See my post above. Share this post Link to post Share on other sites
saddle 19 Posted July 1, 2023 addMissionEventHandler ["Killed", { params ["_killed", "_killer", "_score"]; _score = score; if (_killed isKindOf "CAManBase" && {side group _killed isEqualTo east}) then { score + 1; format ["%2 Kills: %3", _killed _killer%2 _score%3] remoteExec ["hint", 0]; }; }]; Maybe I am overthinking this. Share this post Link to post Share on other sites
Harzach 2518 Posted July 1, 2023 "Score" is a scripting command. You can't use it as a variable. Also, you can't just make up your own params for an EH. The killed EH's params are: params ["_unit", "_killer", "_instigator", "_useEffects"]; So your "_score" param is just returning the instigator. score + 1; // SHOULD BE _score = _score +1; This syntax is incorrect: format ["%2 Kills: %3", _killed _killer%2 _score%3] remoteExec ["hint", 0]; Better: format ["%1 Kills: %2", _killer, _score] remoteExec ["hint", 0]; Read this: https://community.bistudio.com/wiki/format 1 Share this post Link to post Share on other sites
saddle 19 Posted July 1, 2023 2 hours ago, Harzach said: "Score" is a scripting command. You can't use it as a variable. Also, you can't just make up your own params for an EH. The killed EH's params are: params ["_unit", "_killer", "_instigator", "_useEffects"]; So your "_score" param is just returning the instigator. score + 1; // SHOULD BE _score = _score +1; This syntax is incorrect: format ["%2 Kills: %3", _killed _killer%2 _score%3] remoteExec ["hint", 0]; Better: format ["%1 Kills: %2", _killer, _score] remoteExec ["hint", 0]; Read this: https://community.bistudio.com/wiki/format No success so far. But thanks for responses up to this point. I am learning some more about how variables are working. I did a lot of troubleshooting and tweaking of the code after making the corrections you pointed out above, as it did not work yet still. Managed to get the hint displaying once and then I made a change in the code hehe and I have not managed to get the hint to show up again. At first it said something along the lines of duplicate variable when entering a game session, so I am going to look around in my files for that. Will continue tomorrow. Share this post Link to post Share on other sites
Harzach 2518 Posted July 1, 2023 24 minutes ago, saddle said: the corrections you pointed out To be clear, I merely pointed out specific problems and their specific solutions. I have not approached your code as a whole. I also missed this: addMissionEventHandler ["Killed",// No mission EH of type "Killed" exists. There is, however, an "EntityKilled" MEH: addMissionEventHandler ["EntityKilled", { params ["_unit", "_killer", "_instigator", "_useEffects"]; }]; 1 Share this post Link to post Share on other sites
saddle 19 Posted July 2, 2023 12 hours ago, Harzach said: To be clear, I merely pointed out specific problems and their specific solutions. I have not approached your code as a whole. I also missed this: addMissionEventHandler ["Killed",// No mission EH of type "Killed" exists. There is, however, an "EntityKilled" MEH: addMissionEventHandler ["EntityKilled", { params ["_unit", "_killer", "_instigator", "_useEffects"]; }]; Thanks for clearing that up, I made a little progress; addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer", "_instigator"]; if (_killed isKindOf "CAManBase" && {side group _killed isEqualTo east}) then { _score = _score +1; format ["%1 kills: %2", _killer, _score] remoteExec ["hint", 0]; }; }]; The hint is properly triggering and displaying now, however I am getting a Scalar NaN where the _score is located in the hint message. I presumed that it has not been bound to the proper value, or it has need to be shown to addScore(?), so I made many more attempts including trying to add this code [_killer,{_score addScore +1} remoteExec ["Call",_killer]; I know the score is set to 0. But I presume I have not told the game that _score is at 0. I presume the game knows the value is supposed to +1, but from what value. I tried to experiment and troubleshoot with this but did not manage to solve it yet. Will troubleshoot throughout the day. 🙂 Share this post Link to post Share on other sites
Harzach 2518 Posted July 2, 2023 _score is undefined. 2 hours ago, saddle said: I know the score is set to 0 How and where? Share this post Link to post Share on other sites
saddle 19 Posted July 2, 2023 25 minutes ago, Harzach said: _score is undefined. How and where? In the second post here added it to initPlayerLocal. Share this post Link to post Share on other sites
Harzach 2518 Posted July 2, 2023 So you have completely ignored what I said about "score." Twice. Share this post Link to post Share on other sites
saddle 19 Posted July 2, 2023 1 minute ago, Harzach said: So you have completely ignored what I said about "score." Not ignored, just not understood it. I will review it all when I got some time sorry about that inconvenience. Share this post Link to post Share on other sites
Harzach 2518 Posted July 2, 2023 18 hours ago, Harzach said: "Score" is a scripting command. You can't use it as a variable. If that's not clear, please read through the first few links in my signature. 1 Share this post Link to post Share on other sites
saddle 19 Posted July 2, 2023 6 hours ago, Harzach said: If that's not clear, please read through the first few links in my signature. Worked out the last bits of code it seems to all be working now. I get confused but it is fun and I am willing to learn. Thanks Harzach. Share this post Link to post Share on other sites
Dramacius 8 Posted July 3, 2023 don't use score instead use something like playerScore I was unaware of score being reservered so you would have to use a different variable, playerScore would work well assuming thats not also reserved putting "_variable" makes that variable only working on that specific code and is not the same as "variable" they would be two different variables the first local to the script calling it the other global. locality is very important and very confusing 1 Share this post Link to post Share on other sites