Gamer-3ac24a5e7f4beb96 4 Posted August 18, 2022 I am working on a kill counter sqf and can get it activating correctly but I don't know how to get the kill count variable to display in the hint that shows on the player screen. if (isServer) then { enemy_killed = 0; addMissionEventHandler ["EntityKilled", { _killed = _this select 0; if (side group _killed == west) then { enemy_killed = enemy_killed + 1; hint (format ["Kills", _enemy_killed]); if (enemy_killed > 10) then { failMission "LOSER"; //or any other ending }; }; if (side group _killed == east) then { enemy_killed = enemy_killed - 1; hint (format ["Kills", _enemy_killed]); if (enemy_killed > 10) then { failMission "LOSER"; //or any other ending }; }; }]; }; Right now it just displays the word "Kills" in the hint box. The failure condition works properly so I know its counting. I'm just new to scripting and couldn't figure it from the bohemia's hint info page. Share this post Link to post Share on other sites
Harzach 2518 Posted August 18, 2022 A few issues.hint is LE (Local Effect): and you are running it on the server: if (isServer) then { so it will only appear on the server (which is the same as your local machine when testing non-dedicated). For true MP compatibility, you will need to remoteExec your hint. But also, your formatting is incorrect. Check the Biki entry for format. hint format ["Kills: %1", _enemy_killed]; //returns "Kills: 1" after first kill The format command may look strange in use, but once you understand the concept, it's very intuitive. The first element ( or rather, array index 0) is the hint's body of text represented as a string. "Killed: %1" in this example. The "%1" is a proxy for the second element (array index 1). So the element in index 1 will be printed where "%1" is. hint format ["%1 %2! %3 %4 %5 %6.", "Hello", "world", "Nice", "to", "meet", "you"]; // returns ""Hello, world! Nice to meet you." In addition, your variable in index 1 is an undefined local variable. This may be a typo. It should simply be your global variable: hint format ["Kills: %1", enemy_killed]; If MP compatibility is necessary, then we use remoteExec: format ["Kills: %1", enemy_killed] remoteExec ["hint", -2]; // hints "Kills: 1" to all clients 3 Share this post Link to post Share on other sites
Joe98 92 Posted August 18, 2022 Structured text. Even I know how to use this. https://community.bistudio.com/wiki/Structured_Text . 1 Share this post Link to post Share on other sites
Harzach 2518 Posted August 18, 2022 1 hour ago, Joe98 said: Structured text. Even I know how to use this. Show, don't tell. 1 1 Share this post Link to post Share on other sites
Gamer-3ac24a5e7f4beb96 4 Posted August 19, 2022 On 8/17/2022 at 7:39 PM, Harzach said: Thank you Harzach! I am making this a script that tracks the political will of the enemy based on kills. If an enemy dies, it goes down by one. If a friendly dies, it does up by one. This is what i came up with: political_will = 100; addMissionEventHandler ["EntityKilled", { _killed = _this select 0; if (side group _killed == west) then { political_will = political_will - 1; format ["Enemy Political Will: %1", political_will] remoteExec ["hint", -2]; if (political_will < 10) then { failMission ""END1""; //or any other ending }; }; if (side group _killed == east) then { political_will = political_will + 1; format ["Kills: %1", political_will] remoteExec ["hint", -2]; if (political_will < 10) then { failMission ""END1""; //or any other ending }; }; }]; I'm using failMIssion to activate end 1 the win screen. Player side is opfor. Share this post Link to post Share on other sites
Gamer-3ac24a5e7f4beb96 4 Posted August 19, 2022 I get a generic error and an invalid number error when I put this in an init sqf in the mission folder. Share this post Link to post Share on other sites
Harzach 2518 Posted August 19, 2022 You have doubled quotes on your failMission endType strings. 1 Share this post Link to post Share on other sites
pierremgi 4905 Posted August 19, 2022 4 hours ago, Gamer-3ac24a5e7f4beb96 said: I get a generic error and an invalid number error when I put this in an init sqf in the mission folder. Typically, your code should run on server only. You are counting killed by sides and your variable political_will is not public. Furthermore, you are remoteExecuting a hint (everywhere but server, so dedicated I presume) So, run it on initServer.sqf If you have several playable sides, that could fail, of course. Use the other parameters. 2 Share this post Link to post Share on other sites
Gamer-3ac24a5e7f4beb96 4 Posted August 20, 2022 Thank you for the direction. I fixed my extra quotations and saw that my mission event handler line wasn't proper. I know I need something along the lines of addMissionEventHandler ["EntityKilled",0,]; based on the bohemia info but I'm sure that is incomplete somehow. How do I make my variable global? Searching global variable on bohemia didn't turn up a page. My mission is a coop not pvp so hopefully that reduces complications. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted August 20, 2022 _variable = "abc"; - local variable to script scope variable = "abc"; - global variable on executing machine missionNamespace setVariable ["variable", "abc", true]; - public variable - known on all machines 2 Share this post Link to post Share on other sites