aie-boshell 22 Posted July 17, 2017 Hello, I'm creating a multiplayer game mode that is rank focused. I need some way to simply show each player's rank on screen. I've been able to use this addMissionEventHandler ["draw3d",{hintsilent format ["RANK: %1",rank player]}]; but everyone sees the same "hint" so it doesn't work for me. I also tried substituting "player" for the name of a unit with one "addmissioneventhandler" for each unit but still have the same message on each player's screen. I've been at this for a while and for the first time I cannot find my answer to a question here and have to post. I appreciate any help I can get. Thank you :-) Share this post Link to post Share on other sites
das attorney 858 Posted July 17, 2017 Try this: addMissionEventHandler ["draw3d",{ if (isPlayer cursorObject) then { hintsilent format ["RANK: %1",rank cursorObject] } else { hintsilent "" } }]; 1 Share this post Link to post Share on other sites
aie-boshell 22 Posted July 17, 2017 1 hour ago, das attorney said: Try this: addMissionEventHandler ["draw3d",{ if (isPlayer cursorObject) then { hintsilent format ["RANK: %1",rank cursorObject] } else { hintsilent "" } }]; I think we're getting warmer, thanks so much for that. Your script shows that I can have a different hint on each player's screen showing rank, which I haven't been able to accomplish before, but maybe I should have worded it differently as I'm looking for a script that shows the player their own rank in a hint on their own screen at all times and updates as they get promoted by a point system. EDIT: I already have a script that promotes them by points, I just need one to show the rank on their own screen. Thanks again :-) Share this post Link to post Share on other sites
das attorney 858 Posted July 17, 2017 I see, ok - you were on the right lines at first then. In your mission, make an initPlayerLocal.sqf file and add this line in: _handle = addMissionEventHandler ["eachFrame",{hintsilent format ["RANK: %1",rank player]}]; So then everyone should be getting a hint of their own rank. Not sure what was happening for you before. 2 Share this post Link to post Share on other sites
aie-boshell 22 Posted July 18, 2017 1 hour ago, das attorney said: I see, ok - you were on the right lines at first then. In your mission, make an initPlayerLocal.sqf file and add this line in: _handle = addMissionEventHandler ["eachFrame",{hintsilent format ["RANK: %1",rank player]}]; So then everyone should be getting a hint of their own rank. Not sure what was happening for you before. Before I had the scripts in init.sqf and didn't have the _handle. After doing what you said things are working better, although a little buggy. I have two units and it really seems to only update the rank of one of them correctly, although the second seems to work at first but stops showing an update at about Sergeant rank. That issue could have to do with my setrank script, I'll tinker with it and come back to it if I have more questions. I cannot thank you enough for your help, this is more progress than I've made in a week. 1 Share this post Link to post Share on other sites
das attorney 858 Posted July 18, 2017 That's no problem at all - always happy to help people who give it a go themselves. :) If you post up your setRank script, we can have a look at that - I too suspect it may not be acting the way you want it to. PS: The _handle is only there so you can keep track of the eventhandler and delete it if required. It shouldn't make any difference as to how the scripts work/ EDIT: also, are you strictly playing multiplayer (as in you and your mates), or have you got some AI that you are team switching with?? Share this post Link to post Share on other sites
Larrow 2822 Posted July 18, 2017 Rather than setting a hint every frame this is the sort of thing that would be better placed in a cutRsc. Description.ext //Define any ui base classes needed for the ui #include "ui\baseDefines.hpp" //any ui that uses cutRsc must exist with in this class class RscTitles { //include the file containing the ui #include "ui\playerStatsUI.hpp" }; //CfgFunctions is the class used for defining any function needed class CfgFunctions { //include the file containing the functions definitions #include "functions\playerStatsFunctions.hpp" }; Includes several files as shown below, need for the ui and functions to work. initPlayerLocal.sqf waitUntil{ !isNull call BIS_fnc_displayMission }; "playerRankLayer" cutRsc [ "playerRank", "PLAIN" ]; Waits until the mission has started ( main Arma ui has been initialised ) then uses cutRsc to display the ui (playerRank) as a non-interactable display. ui\baseDefines.hpp #define CT_STATIC 0 #define ST_LEFT 0x00 #define GUI_GRID_WAbs ((safezoneW / safezoneH) min 1.2) #define GUI_GRID_HAbs (GUI_GRID_WAbs / 1.2) #define GUI_GRID_H (GUI_GRID_HAbs / 25) #define GUI_TEXT_SIZE_MEDIUM (GUI_GRID_H * 1) class RscText { deletable = 0; fade = 0; access = 0; type = CT_STATIC; idc = -1; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; text = ""; fixedWidth = 0; x = 0; y = 0; h = 0.037; w = 0.3; style = ST_LEFT; shadow = 1; colorShadow[] = {0,0,0,0.5}; font = "RobotoCondensed"; SizeEx = GUI_TEXT_SIZE_MEDIUM; linespacing = 1; tooltipColorText[] = {1,1,1,1}; tooltipColorBox[] = {1,1,1,1}; tooltipColorShade[] = {0,0,0,0.65}; }; Defines resources that the ui will use. RscText is a base class for displaying text in the ui. ui\playerStatsUI.hpp class playerRank { idd = -1; fadein = 0; fadeout = 0; duration = 1e10; class controls { class rank : RscText { x = 0; //change this to position text on screen y = 0; //change this to position text on screen w = 0.06 * safeZoneW; h = 0.02 * safeZoneH; text = "Rank: "; onLoad = "uinamespace setVariable [ 'playerRankText', _this select 0 ]; _this select 0 call TAG_fnc_updatePlayerRank"; }; }; }; This is the ui. Displays text that when this ui is loaded will call TAG_fnc_updatePlayerRank that will update the text displayed. As is the text will be displayed in the upper left center of the screen. Use the two commented values (x and y) to move the text where needed. functions\playerStatsFunctions.hpp class ui { tag = "TAG"; class playerStats { file = "functions"; class updatePlayerRank {}; }; }; This defines any functions used in the mission and the tag( "TAG" ) that the function will be prefixed with. This defines the function TAG_fnc_updatePlayerRank. functions\fn_updatePlayerRank.sqf //call this function each time you have updated the players rank( TAG_fnc_updatePlayerRank ) uiNamespace getVariable "playerRankText" ctrlSetText format[ "Rank: %1", rank player ]; The file used in the above function definition, this is the actual functions code that will be placed in the defined function. This function needs calling every time you change the players rank and will update the text in the ui. Example code that can be used to update the ui, try it from the debugConsole once you have the above all setup. player setrank "LIEUTENANT"; call TAG_fnc_updatePlayerRank; Example mission 3 Share this post Link to post Share on other sites
aie-boshell 22 Posted July 18, 2017 16 hours ago, das attorney said: That's no problem at all - always happy to help people who give it a go themselves. :) If you post up your setRank script, we can have a look at that - I too suspect it may not be acting the way you want it to. PS: The _handle is only there so you can keep track of the eventhandler and delete it if required. It shouldn't make any difference as to how the scripts work/ EDIT: also, are you strictly playing multiplayer (as in you and your mates), or have you got some AI that you are team switching with?? I figured out the error in my setrank script, and now with your help, it's working flawlessly. The original issue with each player's hint showing only one of the player's ranks must have been that I had no initplayerlocal.sqf. I'm playing multiplayer and haven't fully decided whether I will incorporate team switch with AI yet, but to start I'd just like to get it working for players with no team switch. I'm testing by having two computers connect to the dedicated server running the mission and adding to the score by radio trigger and setting ranks with "if (unitscore > 59 and unitscore < 70) then { p setrank "colonel"; }" Where "p" is the unit name and "unitscore = SCORE p" as an example. All appears to be working great, but I'm likely to run into more issues with other features. Thanks again, Das! 1 Share this post Link to post Share on other sites
aie-boshell 22 Posted July 18, 2017 On 7/18/2017 at 8:01 AM, Larrow said: This is fantastic, although a bit more complex than I was initially going for, I see at least one benefit of doing it this way and that's that it would leave "hint" open to use for other things so I may end up using this, thanks so much. There is one issue with it, and that's that I'm only seeing "Rank: PRI", where actually only the first two and 1/2 letters of the rank are showing. I would like to display the rank in this format "RANK: Private" if at all possible. I tried to look in the files and see where I could edit that but this type of scripting is a bit out of my league, but very awesome and I'm very thankful you shared it with me. This community is amazing! Share this post Link to post Share on other sites
Berntsen 19 Posted July 19, 2017 6 hours ago, aie-boshell said: This is fantastic, although a bit more complex than I was initially going for, I see at least one benefit of doing it this way and that's that it would leave "hint" open to use for other things so I may end up using this, thanks so much. There is one issue with it, and that's that I'm only seeing "Rank: PRI", where actually only the first two and 1/2 letters of the rank are showing. I would like to display the rank in this format "RANK: Private" if at all possible. I tried to look in the files and see where I could edit that but this type of scripting is a bit out of my league, but very awesome and I'm very thankful you shared it with me. This community is amazing! in the ui\playerStatsUI.hpp, try changing the w = 0.06 * safeZoneW to a larger number, see if that works. If not, I'm not sure. class playerRank { idd = -1; fadein = 0; fadeout = 0; duration = 1e10; class controls { class rank : RscText { x = 0; //change this to position text on screen y = 0; //change this to position text on screen w = 0.06 * safeZoneW; // Try increasing this to 0.12 <------------------------------- (sorta like 'w = 0.12 * safeZoneW;') h = 0.02 * safeZoneH; text = "Rank: "; onLoad = "uinamespace setVariable [ 'playerRankText', _this select 0 ]; _this select 0 call TAG_fnc_updatePlayerRank"; }; }; }; Share this post Link to post Share on other sites
Larrow 2822 Posted July 19, 2017 @Berntsen is correct. Change the width of the ui text element. I'm using a 21:9 monitor so the width of my screen (safeZoneW) is likely larger than your display. The 0.06 is basically saying size the text element to 6% of the screen width, which I know on mine was just enough to fit in the longest rank "LIEUTENANT". On a secondary note @aie-boshell, can you remove my whole quote from your reply, it makes the forum messy and hard to read if people quote large sections of repeated text. thanks Share this post Link to post Share on other sites