Posting Player Ranks On Screen

Posting Player Ranks On Screen

« posted: May 21, 2019, 11:39 PM »
Hey folks, Ant here, looking for a little help... First off let me preface that I am in no way a fluent Arma Wasteland coder but try to come up with additional ways to enhance the game... so I dabble in it a bit. So that being said i have an issue that maybe someone from the community could help finalize my code or point me in the right direction.

So here goes.
I am using this body of code provided by "CeccaTTo"  http://forums.a3wasteland.com/index.php?topic=3805.0  to set random player gear via monies a player has in the ATM account. I have added set player ranks to the code for the spawned in players at the bottom of each player class within the code.

The code to show player rank works outside of wasteland so i figured i would try to merge the two to make something that would entice players to grind out the missions for more money and rank. The error i get when i enter all the code pieces in Wasteland is script functions not found? So a little lost... any help would be appreciated and thanks for having this great forum... I have learned a lot by reading and trying things the community has published.

CeccaTTo code is below

// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
//   @file Name: playerSetupGear.sqf
//   @file Author: [GoT] JoSchaap, AgentRev
//  @file Modifications to LEVEL LOADOUTS: [BC]CeccaTTo

private ["_player", "_bmoney", "_playerScore", "_uniform", "_headgear"];
_player = _this;
_bmoney = _player getVariable ["bmoney", 0];
_playerScore = (([_player, "playerKills"] call fn_getScore) - ([_player, "teamKills"] call fn_getScore));
_uniform = [_player, "uniform"] call getDefaultClothing;
_headgear = [_player, "headgear"] call getDefaultClothing;

if (_uniform != "") then { _player addUniform _uniform };
if (_headgear != "") then { _player addHeadgear _headgear };

sleep 0.1;

switch (true) do {
   case (_bmoney >= 0 && _bmoney <= 9999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_FieldPack_oli";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "30Rnd_556x45_Stanag";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addWeapon "arifle_Mk20_GL_plain_F";
      _player addMagazine "30Rnd_556x45_Stanag";
      _player addMagazine "30Rnd_556x45_Stanag";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_Aco";
      _rank = "Private";
               call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 10000000 && _bmoney <= 19999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_TacticalPack_mcamo";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "30Rnd_556x45_Stanag";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addWeapon "arifle_TRG21_GL_F";
      _player addMagazine "30Rnd_556x45_Stanag";
      _player addMagazine "30Rnd_556x45_Stanag";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_Aco";
      _rank = "Private";
                call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 20000000 && _bmoney <= 29999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_TacticalPack_rgr";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "200Rnd_556x45_Box_F";
      _player addWeapon "LMG_03_F";
      _player addMagazine "200Rnd_556x45_Box_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_ERCO_blk_F";
      _rank = "CORPORAL";
                call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 30000000 && _bmoney <= 39999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_TacticalPack_oli";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "30Rnd_65x39_caseless_green";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addWeapon "arifle_Katiba_GL_F";
      _player addMagazine "30Rnd_65x39_caseless_green";
      _player addMagazine "30Rnd_65x39_caseless_green";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_Arco";
      _rank = "CORPORAL";
                call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 40000000 && _bmoney <= 49999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_FieldPack_khk";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "30Rnd_65x39_caseless_mag";
      _player addMagazine "3Rnd_HE_Grenade_shell";
      _player addWeapon "arifle_MX_GL_F";
      _player addMagazine "30Rnd_65x39_caseless_mag";
      _player addMagazine "30Rnd_65x39_caseless_mag";
      _player addMagazine "3Rnd_HE_Grenade_shell";
      _player addMagazine "3Rnd_HE_Grenade_shell";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_Arco";
      _rank = "SERGEANT";
                call TAG_fnc_updatePlayerRank;
   };   
   case (_bmoney >= 50000000 && _bmoney <= 59999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_FieldPack_oli";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "200Rnd_65x39_cased_Box";
      _player addWeapon "LMG_Mk200_F";
      _player addMagazine "200Rnd_65x39_cased_Box";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_Hamr";
      _rank = "LIEUTENANT";
                call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 60000000 && _bmoney <= 69999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_FieldPack_cbr";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "30Rnd_762x39_Mag_F";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addWeapon "arifle_AK12_GL_F";
      _player addMagazine "30Rnd_762x39_Mag_F";
      _player addMagazine "30Rnd_762x39_Mag_F";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "1Rnd_HE_Grenade_shell";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_Hamr";
      _rank = "LIEUTENANT";
               call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 70000000 && _bmoney <= 79999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_FieldPack_ocamo";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "150Rnd_762x54_Box";
      _player addWeapon "LMG_Zafir_F";
      _player addMagazine "150Rnd_762x54_Box";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_DMS";
      _rank = "CAPTAIN";
                call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 80000000 && _bmoney <= 89999999): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_Carryall_Base";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "130Rnd_338_Mag";
      _player addWeapon "MMG_02_sand_F";
      _player addMagazine "130Rnd_338_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_AMS";
      _rank = "MAJOR";
      call TAG_fnc_updatePlayerRank;
   };
   case (_bmoney >= 90000000 && _bmoney <= 100000000): {
      removeAllItems _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      removeAllWeapons _player;
      removeVest _player;
      removeBackpack _player;
      _player addVest "V_HarnessO_brn";
      _player addBackpack "B_Carryall_oli";
      _player addWeapon "Binocular";
      _player addItem "FirstAidKit";
      _player addItem "SmokeShell";
      _player addMagazine "150Rnd_93x64_Mag";
      _player addWeapon "MMG_01_tan_F";
      _player addMagazine "150Rnd_93x64_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addWeapon "hgun_ACPC2_F";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addMagazine "9Rnd_45ACP_Mag";
      _player addPrimaryWeaponItem "optic_AMS";
      _rank = "COLONEL";
                call TAG_fnc_updatePlayerRank;
   };
};

switch (true) do {
   case (["_medic_", typeOf _player] call fn_findString != -1):
   {
      _player removeItem "FirstAidKit";
      _player addItem "Medikit";
   };
   case (["_engineer_", typeOf _player] call fn_findString != -1):
   {
      _player addItem "MineDetector";
      _player addItem "Toolkit";
   };
   case (["_sniper_", typeOf _player] call fn_findString != -1):
   {
      _player removeItem "Binocular";
      _player addWeapon "Rangefinder";
   };
};

switch (true) do {
   case (_playerScore >= 100 && _playerScore <= 149): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
   };
   case (_playerScore >= 150 && _playerScore <= 199): {
      _player addItem "MiniGrenade";
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "HandGrenade";
   };
   case (_playerScore >= 200 && _playerScore <= 249): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "APERSTripMine_Wire_Mag";
   };
   case (_playerScore >= 250 && _playerScore <= 299): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "APERSBoundingMine_Range_Mag";
   };
   case (_playerScore >= 300 && _playerScore <= 349): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "APERSMine_Range_Mag";
   };
   case (_playerScore >= 350 && _playerScore <= 399): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "ClaymoreDirectionalMine_Remote_Mag";
   };
   case (_playerScore >= 400 && _playerScore <= 449): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "SLAMDirectionalMine_Wire_Mag";
   };
   case (_playerScore >= 450 && _playerScore <= 499): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "DemoCharge_Remote_Mag";
   };
   case (_playerScore >= 500 && _playerScore <= 999): {
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "DemoCharge_Remote_Mag";
      _player addMagazine "RPG32_F";
      _player addWeapon "launch_RPG32_F";
      _player addMagazine "RPG32_F";
   };
   case (_playerScore >= 1000): {
      _player removeItem "Binocular";
      _player removeItem "Rangefinder";
      _player addMagazine "Laserbatteries";
      _player addWeapon "Laserdesignator";
      _player addItem "MiniGrenade";
      _player addItem "HandGrenade";
      _player addItem "DemoCharge_Remote_Mag";
      _player addMagazine "RPG32_HE_F";
      _player addWeapon "launch_RPG32_F";
      _player addMagazine "RPG32_HE_F";
   };
};

if (_player == player) then
{
   thirstLevel = 100;
   hungerLevel = 100;
};

_________________________________________________________________________________________

Ants code to show player rank below


To call the player code I have a functions directory with two files in it:

File 1. is named fn_updatePlayerRank.sqf and its code reads:

//call this function each time you have updated the players rank( TAG_fnc_updatePlayerRank )

uiNamespace getVariable "playerRankText" ctrlSetText format[ "Rank: %1", rank player ];


File two is. playerStatsFunctions.hpp and its code reads:

class ui
{
   tag = "TAG";
   class playerInfo
   {
      file = "functions";
      class updatePlayerRank {};
   };
};

___________________________________________________________________________________________

The next directory I have is the UI folder. In the UI directory i have two files.

File 1. baseDefines.hpp and its code reads:

#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.149,0.149,0.149,1};
   colorText[] = {0.992,0.824,0.306,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};
};

File 2 is: playerStatsUI.hpp and its code reads

class playerRank
{
   idd = -1;
   fadein = 0;
   fadeout = 0;
   duration = 1e10;

   class controls
   {
      class rank : RscText
      {
         x = 1.4; //change this to position text on screen
         y = 0.19; //change this to position text on screen
         w = 0.12 * safeZoneW;
         h = 0.02 * safeZoneH;

         text = "Rank: ";
         onLoad = "uinamespace setVariable [ 'playerRankText', _this select 0 ]; _this select 0 call TAG_fnc_updatePlayerRank";
      };
   };
};

___________________________________________________________________________________________

In my description.ext file I have the code below.

#include "ui\baseDefines.hpp"

class RscTitles
{
   #include "ui\playerStatsUI.hpp"
};

class CfgFunctions
{
   #include "functions\playerStatsFunctions.hpp"
};


___________________________________________________________________________________________
and in my initPlayerLocal.sqf i have

waitUntil{ !isNull call BIS_fnc_displayMission };
"playerRankLayer" cutRsc [ "playerRank", "PLAIN" ];


Again any help is highly appreciated



[MSOF Rule The Wasteland Server
Direct connect to the server is 68.203.6.236:2302