Jump to content
Sign in to follow this  
doomnet

How to link an image and alternative text to ranks in getRankinfo.sqf

Recommended Posts

HI,

i have a database system with ranks on my server, the file who set the ranks is getRankinfo.sqf

example :

if (_xp >= 900) then
{
_rank = 4;
_nextrankxp = 1300;
}else{
if (_xp >= 600) then
{
_rank = 3;
_nextrankxp = 900;
}else{
if (_xp >= 300) then
{
_rank = 2;
_nextrankxp = 600;
}else{
_rank = 1;
_nextrankxp = 300;

How do i link rank 1 to another or alternative text and also to a picture ?

what the player sees when ingame is "rank 1" but i need to change it to real rank names for example "rank 10" = sergeant, also linked to insigna pictures.

any help would be nice ! as i am a noob sqf language !

I hope i was clear enough

Share this post


Link to post
Share on other sites
How do i link rank 1 to another or alternative text and also to a picture ?

what the player sees when ingame is "rank 1" but i need to change it to real rank names for example "rank 10" = sergeant, also linked to insigna pictures.

any help would be nice ! as i am a noob sqf language !

I hope i was clear enough

Depends how you want to display it. You could try something like this. Keep in mind that i am a newbie in sqf scripting.

if (_xp >= 900) then
{
   _rank = 4;
   _nextrankxp = 1300;
player setRank "CAPTAIN";
}else{
if (_xp >= 600) then
{
   _rank = 3;
   _nextrankxp = 900;
player setRank "LIEUTENANT";
}else{
if (_xp >= 300) then
{
   _rank = 2;
   _nextrankxp = 600;
player setRank "SERGEANT";
}else{
   _rank = 1;
   _nextrankxp = 300; 
player setRank "PRIVATE";

Then you can call that by displaying it with

_nameCtrl = findDisplay 60000 displayCtrl 1100;
_nameCtrl ctrlSetText format["RANK: %1", rank player];

As an alternative to the above you could go something like :

switch (rank player) do {
   case "PRIVATE": {
  		//Insert code

   };
   case "CORPORAL": {
   	     //Insert code

   };
   case "SERGEANT": {
	//Insert code
   };
   case "LIEUTENANT": {
   	//Insert code
   };
   case "CAPTAIN": {
   	//Insert code
   };
   case "MAJOR": {
   	//Insert code
   };
   case "COLONEL": {
   	//Insert code
   };
};

Now if you want to display a picture, you can go something like this:

((uiNamespace getVariable "PlayerRank") displayCtrl 1200) ctrlSetText format ["\A3\Ui_f\data\GUI\Cfg\Ranks\%1_gs.paa", rank player];

In order to do that you will need to create a dialog. Something like :

class PlayerRank
{
idd=60000;
fadeout=0;
fadein=0;
duration = 86400;//24h
name = "PlayerRank";
onLoad = "uiNamespace setVariable ['PlayerRank', _this select 0]";


class controls 
{
class DisplayRank: RscPicture
{
idc = 1200;
size = "0.02 / (getResolution select 5)";
text = "";
x = 0.784672 * safezoneW + safezoneX;
y = 0.829823 * safezoneH + safezoneY;
w = 0.0515625 * safezoneW;
h = 0.0879657 * safezoneH;
};
};
};

I hope that i gave you some help. As a newbie myself in scripting i could be wrong. Anyway, i am very positive that the resident script gurus will come in to help you out.:)

Regards

Seed

Edited by Seed

Share this post


Link to post
Share on other sites

ok thanks a lot seed i'm gonna learn from you know

this could be helpful for me, i will give it a try tonight on test server

thanks bro !!!

Share this post


Link to post
Share on other sites

well i tried some couple of hours your code and i can't make things work

i just don't know where exactly to put the code.

i give you my working description file, the only thing i need to do is to link a picture to the rank titles, for exemple it will show up next to it.

i have already prepared all .paa files with ranks the name of the pictures are 1.paa, 2.paa 3.paa etc.... to correspond to the rank number ?

its not clear where to put my image files on the server ? or in the mission folder ?

here is my working description file for now showing up only stats in text format.

class Header
{
gameType=TDM;
minPlayers=1;
maxPlayers=24;
};
respawn = "BASE";
respawndelay = 5;
respawnTemplates[] = {"MenuPosition"};

joinUnassigned = 0;
disabledAI = 1;
saving = 0;
enableDebugConsole = 1;

corpseLimit = 10;
corpseRemovalMinTime = 15;
corpseRemovalMaxTime = 20;

wreckLimit = 10;
wreckRemovalMinTime = 15;
wreckRemovalMaxTime = 20;

class CfgFunctions
{
   #include "ASORGS\cfgfunctions.hpp"
   #include "functions\cfgfunctions.hpp"			// Integrated I&A functions
   #include "scripts\taw_vd\CfgFunctions.hpp"

class myTag
{
	class myCategory
	{
		class skipBriefing
		{
			file = "skipBriefing.sqf";
			preInit = 1;
		};
	};
};
};
#include "ASORGS\menu.hpp"
#include "scripts\taw_vd\dialog.hpp"

//class RscPicture 
//{
//	type = CT_STATIC;
//	idc = -1;
//	style = 48;
//	colorBackground[] = {0, 0, 0, 0};
//	colorText[] = {1, 1, 1, 1};
//	font = "PuristaMedium"; //Typeface
//	sizeEx = 0;
//};

class CfgSounds
{
   sounds[] = {opforsnd, blueforsnd, indisnd};

class opforsnd
{
	name="opforsnd";
	sound[]={sounds\opforsnd.ogg,1,1};
	 titles[] = {};
   };

class blueforsnd
{
	name="blueforsnd";
	sound[]={sounds\blueforsnd.ogg,1,1};
	 titles[] = {};
   };

class indisnd
{
	name="indisnd";
	sound[]={sounds\indisnd.ogg,1,1};
	 titles[] = {};
   };
};

class CfgMusic
{
   tracks[] = {JingleBells, Snakes};

class JingleBells
   {
   name="JingleBells";
   sound[]={sounds\JingleBells.ogg,0.9,1};
   titles[] = {};
   };
};

class RscTitles
{
class statsScreen
{    
	idd = -1;
	duration = 1e+1000;
	fadeIn = 0;
	fadeOut = 0;
	name = "";
	onLoad = "uiNamespace setVariable ['statsDisplay', _this select 0];";

	class controls
	{

		class statsrank
		{    
			idc = 998;
			type = 0;
			style = 0;

			text = "0";
			x = 0.80 * safezoneW + safezoneX;
               y = 0.81 * safezoneH + safezoneY;
               w = 0.15 * safezoneW;
               h = 0.04 * safezoneH;

			font = "PuristaMedium";
			sizeEx = 0.04;
			colorBackground[] = {0,0,0,0};
			colorText[] = {1,1,1,1};
		};
		class statsxp
		{    
			idc = 1000;
			type = 0;
			style = 0;

			text = "0";
			x = 0.80 * safezoneW + safezoneX;
               y = 0.84 * safezoneH + safezoneY;
               w = 0.15 * safezoneW;
               h = 0.04 * safezoneH;

			font = "PuristaMedium";
			sizeEx = 0.04;
			colorBackground[] = {0,0,0,0};
			colorText[] = {1,1,1,1};
		};  
		class statskills
		{    
			idc = 1001;
			type = 0;
			style = 0;

			text = "0";
			x = 0.80 * safezoneW + safezoneX;
               y = 0.87 * safezoneH + safezoneY;
               w = 0.12 * safezoneW;
               h = 0.04 * safezoneH;

			font = "PuristaMedium";
			sizeEx = 0.04;
			colorBackground[] = {0,0,0,0};
			colorText[] = {1,1,1,1};
		};
		class statskd
		{    
			idc = 997;
			type = 0;
			style = 0;

			text = "0";
			x = 0.80 * safezoneW + safezoneX;
               y = 0.9 * safezoneH + safezoneY;
               w = 0.12 * safezoneW;
               h = 0.04 * safezoneH;

			font = "PuristaMedium";
			sizeEx = 0.04;
			colorBackground[] = {0,0,0,0};
			colorText[] = {1,1,1,1};
		};	

	};
};
  class wm_disp {
       idd = -1;
       onLoad = "uiNamespace setVariable ['wm_disp', _this select 0]";
       fadein = 0;
       fadeout = 0;
       duration = 10e10;
       controlsBackground[] = {};
       objects[] = {};
       class controls {
           class wm_text2 {
               idc = 1;
               x = safeZoneX+0.027;//safeZoneW*0.01;
               y = safeZoneY+safeZoneH-0.16;
               w = 0.151*safeZoneH;
               h = 0.057*safeZoneH;
               shadow = 2;
               class Attributes
               {
                   font = "PuristaMedium";
                   color = "#FFFFFF";
                   align = "left";
                   valign = "middle";
                   shadow = 2;
               };
               colorBackground[] = { 1, 0.3, 0, 0 };
               font = "PuristaMedium";
               size = 0.06*safeZoneH;
               type = 13;
               style = 0;
               text="";
           };
       };
   };
};

voilà !

Also i tested your rank sqf code but the rank names don't show i see only my rank number.

here is the code :

{
_rank = 8;
_nextrankxp = 3100;
player setRank "Sergeant First Class";
}else{
if (_xp >= 2100) then
{
_rank = 7;
_nextrankxp = 2600;
player setRank "Staff Sergeant";
}else{
if (_xp >= 1700) then
{
_rank = 6;
_nextrankxp = 2100;
player setRank "Sergeant";
}else{
if (_xp >= 1300) then
{
_rank = 5;
_nextrankxp = 1700;
player setRank "Corporal";
}else{
if (_xp >= 900) then
{
_rank = 4;
_nextrankxp = 1300;
player setRank "Army Specialist";
}else{
if (_xp >= 600) then
{
_rank = 3;
_nextrankxp = 900;
player setRank "Private First Class";
}else{
if (_xp >= 300) then
{
_rank = 2;
_nextrankxp = 600;
player setRank "Private 2nd Class";
}else{
_rank = 1;
_nextrankxp = 300;
player setRank "Private";
};

already thank you for helping me again !

:)

Share this post


Link to post
Share on other sites
well i tried some couple of hours your code and i can't make things work

i just don't know where exactly to put the code.

It seems that you are using "Custom Made" ranks and pictures. In that case what i mentioned above will not work. The code that i mentioned above will work for the standard ingame ranks that your unit has. Hence the "playerSetrank" command. Here is an example how would work with the ingame ranks. it will simply display your rank icon on the bottom right corner of your screen.

1. PlayerRank.hpp

class PlayerRank
{
idd=60000;
fadeout=0;
fadein=0;
duration = 86400;//24h
name = "PlayerRank";
onLoad = "uiNamespace setVariable ['PlayerRank', _this select 0]";


class controls 
{

class DisplayRank: RscPicture
{
idc = 1200;
size = "0.02 / (getResolution select 5)";
text = "";
x = 0.888667 * safezoneW + safezoneX;
y = 0.848344 * safezoneH + safezoneY;
w = 0.108854 * safezoneW;
h = 0.15394 * safezoneH;
};
};
};

2. Make a "Hud.sqf" and place inside

disableSerialization;

_rscLayer = "PlayerRank" call BIS_fnc_rscLayer;
_rscLayer   cutRsc["PlayerRank","PLAIN", 1, false ];


While { true } do {
((uiNamespace getVariable "PlayerRank") displayCtrl 1200) ctrlSetText format ["\A3\Ui_f\data\GUI\Cfg\Ranks\%1_gs.paa", rank player];
};

3. On you mission init.sqf place :

execVM "Hud.sqf";

On you Description.ext place the following :

#include "Defines.hpp"
class RscTitles {

 #include "PlayerRank.hpp"

};

The Defines.hpp in case you wondering is the "base class" definition file which includes stuff like rscpicture and so on. The code above will work only for the standard ingame ranks. Hence "playerSetrank" command.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

i give you my working description file, the only thing i need to do is to link a picture to the rank titles, for exemple it will show up next to it.

i have already prepared all .paa files with ranks the name of the pictures are 1.paa, 2.paa 3.paa etc.... to correspond to the rank number ?

Honestly i never made custom ranks and pictures. I have spend couple of hours trying to find a solution to yor problem as its of interest to me also since i am newbie in sqf scripting. I think we have 2 options and both will require the "onLoad" command. The first option will be to usethe "onLoad" to cycle through the pictures. For that we will need to define many classes and the location of the pictures. In the example above the PlayerRank.hpp will look like :

class PlayerRank
{
idd=60000;
fadeout=0;
fadein=0;
duration = 86400;//24h
name = "PlayerRank";
controls[] = {"RscPicture_1200","RscPicture_1201","RscText_1000","RscText_1001","RscText_1002","RscPicture_1202","RscPicture_1203","RscPicture_1204","RscPicture_1205","RscPicture_1206"};
onLoad = "((_this select 0) displayCtrl 1200) ctrlSetText format [""Subject: %1"", PICTURELOCATION];";



class DisplayRank: RscPicture
{
idc = 1200;
size = "0.02 / (getResolution select 5)";
text = "";
x = 0.888667 * safezoneW + safezoneX;
y = 0.848344 * safezoneH + safezoneY;
w = 0.108854 * safezoneW;
h = 0.15394 * safezoneH;
};
......
};

PICTURELOCATION = "\FileName\picture.paa";

The second option will be to use a function with the "onLoad"

onLoad = "[_this select 0] call Player_fnc_RankPic"

The question will be how the function will look like with your custom rank framework? Something like this ?

Player_fnc_RankPic { 
switch ( player ) do { 
case "Private 2nd Class" : { 
player setVariable ["player", "Private 2nd Class", true];
     ((uiNamespace getVariable "PlayerRank") displayCtrl 1200) ctrlSetText format ["Private 2nd Class.paa"]
};
case "Army Specialist" : { 
      player setVariable ["player", "Army Specialist", true];	
      ((uiNamespace getVariable "PlayerRank") displayCtrl 1200) ctrlSetText format ["Army Specialist.paa"]
};
case "Staff Sergeant" : { 
      player setVariable ["player", "Staff Sergeant", true];	
     ((uiNamespace getVariable "PlayerRank") displayCtrl 1200) ctrlSetText format ["Staff Sergeant.paa"]
};
};
};	

I really hope some of the script gurus will jump in and help you out as its a bit too complex for me. I am sorry that i couldn´t help you.

Regards

Seed

Share this post


Link to post
Share on other sites

what i try to achieve is simply replace or link the text that shows up on screen "rank 1 to private first class

i already have the stats and rank name showing up and working. so i don't need i think to recreate a new code for ranks as it is already working with database sqlite @Arma2NET

if i change the rank number "1" to an other text for example: private first class, the database rank system is broken i get in place of rank "1" rank "any".

so is there a simple way to just link rank "1" text, to other text whatever it is, without or with editing the getRankInfo.sqf or another file.

if i can link rank "1" to another text for example just after it: "Rank: 1 private first class" and not what i have now "Rank: 1"

then i can link also a picture with the rank text.

i hope i was clear enough, i'm a noob in editing and sometimes maybe i understand it wrong how things works in scripting.

but maybe it is like in HTML when you link a picture with a text. i don't know :j:

this is the working rank system getRankInfo.sqf:

_xp = _this;
_rank = 0;
_nextrankxp = 0;
if (_xp >= 900000) then
{
_rank = 75;
_nextrankxp = 0;
}else{
if (_xp >= 740000) then
{
_rank = 74;
_nextrankxp = 900000;
}else{
if (_xp >= 710000) then
{
_rank = 73;
_nextrankxp = 740000;
}else{
if (_xp >= 680000) then
{
_rank = 72;
_nextrankxp = 710000;
}else{
if (_xp >= 650000) then
{
_rank = 71;
_nextrankxp = 680000;
}else{
if (_xp >= 620000) then
{
_rank = 70;
_nextrankxp = 650000;
}else{
if (_xp >= 590000) then	
{	
_rank = 69;
_nextrankxp = 620000;
}else{
if (_xp >= 565000) then	
{	
_rank = 68;
_nextrankxp = 590000;
}else{
if (_xp >= 545000) then	
{	
_rank = 67;
_nextrankxp = 565000;
}else{
if (_xp >= 525000) then	
{	
_rank = 66;
_nextrankxp = 545000;
}else{
if (_xp >= 505000) then	
{	
_rank = 65;
_nextrankxp = 525000;
}else{
if (_xp >= 485000) then	
{	
_rank = 64;
_nextrankxp = 505000;
}else{
if (_xp >= 465000) then	
{	
_rank = 63;
_nextrankxp = 485000;
}else{
if (_xp >= 445000) then	
{	
_rank = 62;
_nextrankxp = 465000;
}else{
if (_xp >= 425000) then	
{	
_rank = 61;
_nextrankxp = 445000;
}else{
if (_xp >= 405000) then	
{	
_rank = 60;
_nextrankxp = 425000;
}else{
if (_xp >= 385000) then	
{	
_rank = 59;
_nextrankxp = 405000;
}else{
if (_xp >= 365000) then	
{	
_rank = 58;
_nextrankxp = 385000;
}else{
if (_xp >= 350000) then	
{	
_rank = 57;
_nextrankxp = 365000;
}else{
if (_xp >= 335000) then	
{	
_rank = 56;
_nextrankxp = 350000;
}else{
if (_xp >= 320000) then	
{	
_rank = 55;
_nextrankxp = 335000;
}else{
if (_xp >= 305000) then
{	
_rank = 54;
_nextrankxp = 320000;
}else{
if (_xp >= 290000) then	
{	
_rank = 53;
_nextrankxp = 305000;
}else{
if (_xp >= 275000) then	
{	
_rank = 52;
_nextrankxp = 290000;
}else{
if (_xp >= 260000) then	
{	
_rank = 51;
_nextrankxp = 275000;
}else{
if (_xp >= 245000) then	
{	
_rank = 50;
_nextrankxp = 260000;
}else{
if (_xp >= 220000) then
{	
_rank = 49;
_nextrankxp = 245000;
}else{
if (_xp >= 210000) then
{	
_rank = 48;
_nextrankxp = 220000;
}else{
if (_xp >= 190000) then
{	
_rank = 47;
_nextrankxp = 210000;
}else{
if (_xp >= 170000) then
{	
_rank = 46;
_nextrankxp = 190000;
}else{
if (_xp >= 150000) then
{	
_rank = 45;
_nextrankxp = 170000;
}else{
if (_xp >= 140000) then
{	
_rank = 44;
_nextrankxp = 150000;
}else{
if (_xp >= 130000) then
{	
_rank = 43;
_nextrankxp = 140000;
}else{
if (_xp >= 120000) then
{	
_rank = 42;
_nextrankxp = 130000;
}else{
if (_xp >= 110000) then
{	
_rank = 41;
_nextrankxp = 120000;
}else{
if (_xp >= 100000) then
{	
_rank = 40;
_nextrankxp = 110000;
}else{
if (_xp >= 90000) then
{	
_rank = 39;
_nextrankxp = 100000;
}else{
if (_xp >= 85000) then
{	
_rank = 38;
_nextrankxp = 90000;
}else{
if (_xp >= 80000) then
{	
_rank = 37;
_nextrankxp = 85000;
}else{
if (_xp >= 75000) then
{	
_rank = 36;
_nextrankxp = 80000;
}else{
if (_xp >= 70000) then
{	
_rank = 35;
_nextrankxp = 75000;
}else{
if (_xp >= 65000) then
{	
_rank = 34;
_nextrankxp = 70000;
}else{
if (_xp >= 60000) then
{	
_rank = 33;
_nextrankxp = 65000;
}else{
if (_xp >= 55000) then
{	
_rank = 32;
_nextrankxp = 60000;
}else{
if (_xp >= 50000) then
{	
_rank = 31;
_nextrankxp = 55000;
}else{
if (_xp >= 45000) then
{	
_rank = 30;
_nextrankxp = 50000;
}else{
if (_xp >= 40000) then
{	
_rank = 29;
_nextrankxp = 45000;
}else{
if (_xp >= 37000) then
{	
_rank = 28;
_nextrankxp = 40000;
}else{
if (_xp >= 34000) then
{	
_rank = 27;
_nextrankxp = 37000;
}else{
if (_xp >= 31000) then
{	
_rank = 26;
_nextrankxp = 34000;
}else{
if (_xp >= 28000) then
{	
_rank = 25;
_nextrankxp = 31000;
}else{
if (_xp >= 25000) then
{	
_rank = 24;
_nextrankxp = 28000;
}else{
if (_xp >= 22000) then
{	
_rank = 23;
_nextrankxp = 25000;
}else{
if (_xp >= 19000) then
{	
_rank = 22;
_nextrankxp = 22000;
}else{
if (_xp >= 16000) then
{
_rank = 21;
_nextrankxp = 19000;
}else{
if (_xp >= 14000) then
{
_rank = 20;
_nextrankxp = 16000;
}else{
if (_xp >= 12000) then
{
_rank = 19;
_nextrankxp = 14000;
}else{
if (_xp >= 10000) then
{
_rank = 18;
_nextrankxp = 12000;
}else{
if (_xp >= 9000) then
{
_rank = 17;
_nextrankxp = 10000;
}else{
if (_xp >= 8000) then
{
_rank = 16;
_nextrankxp = 9000;
}else{
if (_xp >= 7000) then
{
_rank = 15;
_nextrankxp = 8000;
}else{
if (_xp >= 6200) then
{
_rank = 14;
_nextrankxp = 7000;
}else{
if (_xp >= 5400) then
{
_rank = 13;
_nextrankxp = 6200;
}else{
if (_xp >= 4800) then
{
_rank = 12;
_nextrankxp = 5400;
}else{
if (_xp >= 4200) then
{
_rank = 11;
_nextrankxp = 4800;
}else{
if (_xp >= 3600) then
{
_rank = 10;
_nextrankxp = 4200;
}else{
if (_xp >= 3100) then
{
_rank = 9;
_nextrankxp = 3600;
}else{
if (_xp >= 2600) then
{
_rank = 8;
_nextrankxp = 3100;
}else{
if (_xp >= 2100) then
{
_rank = 7;
_nextrankxp = 2600;
}else{
if (_xp >= 1700) then
{
_rank = 6;
_nextrankxp = 2100;
}else{
if (_xp >= 1300) then
{
_rank = 5;
_nextrankxp = 1700;
}else{
if (_xp >= 900) then
{
_rank = test4;
_nextrankxp = 1300;
}else{
if (_xp >= 600) then
{
_rank = test3;
_nextrankxp = 900;
}else{
if (_xp >= 300) then
{
_rank = test2;
_nextrankxp = 600;
}else{
_rank = test;
_nextrankxp = 300;
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};



_output = [_rank, _nextrankxp];
_output

getPlayerStats.sqf:

if (isServer) then
{
//check if player exists in db
_unit = _this select 0;
_uid = getPlayerUID _unit;
_name = name _unit;

	_query = format ["SELECT id,uid FROM player WHERE uid = '%1'", _uid];

	while{!isNil("serverRunningQuery") && serverRunningQuery} do { 
	sleep 0.5;//busy wait
	};
	serverRunningQuery = true;
	_get = nil;
	while {isNil("_get")} do {
	_get = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommandAsync ['weaponsArma3', '%1']", _query];
	if (_get == "") then {
		_get = nil;
	};
	sleep 0.5;
	};

	if ((count (toArray(_get))) < 6) then { //if user doesnt exist in database

		_query = "INSERT into player (uid, name, xp, kills, deaths, ammo, weapons, items, assignitems, headgear, goggles, vest, vestitems, uniform, uniformitems, backpack, packitems, handgunitems,
		primarywep, secondarywep) VALUES(";

		_query = _query + "'" + (_uid) + "'," + "'" + (_name) + "'" + ",0,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)";

		_return = nil;
		while {isNil("_return")} do {
			_return = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommandAsync ['weaponsArma3', '%1']", _query];
			if (_return == "") then {
				_return = nil;
			};
			sleep 0.5;
		};
	};

	//get saved stats from server
	_query = format ["SELECT xp,kills,deaths FROM player WHERE uid = '%1'", _uid];

	_get = nil;
	while {isNil("_get")} do {
		_get = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommandAsync ['weaponsArma3', '%1']", _query];
		if (_get == "") then {
			_get = nil;
		};
		sleep 0.5; 
	};
	serverRunningQuery = false;


//This converts the string to an array
_get = call compile _get;

//only select the inner array, throw away this outer array shell
_get = _get select 0;
_get = _get select 0;

_string = _get select 0;
_xp = parseNumber _string;
_string = _get select 1;
_kills = parseNumber _string;
_string = _get select 2;
_deaths = parseNumber _string;

player_stats_add = [_xp,_kills,_deaths];
owner _unit publicVariableClient "player_stats_add";
player_stats_got = 1;
owner _unit publicVariableClient "player_stats_got";
};

updatePlayerStats.sqf

if (isServer) then
{
_unit = _this select 0;
_uid = getPlayerUID _unit;
_stats = _this select 1;
_name = name _unit;

_xp = _stats select 0;
_kills = _stats select 1;
_deaths = _stats select 2;

_query = "UPDATE player SET name=" + "'" + (_name) + "',xp=" + "'" + (str _xp) + "',kills='" + (str _kills) + "',deaths='" + (str _deaths) + "'";

_check = format [" WHERE uid = '%1'", _uid];
_query = _query + _check;

while{!isNil("serverRunningQuery") && serverRunningQuery} do { 
sleep 0.5;//busy wait
};
serverRunningQuery = true;
_return = nil;
while {isNil("_return")} do {
	_return = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommandAsync ['weaponsArma3', '%1']", _query];
	if (_return == "") then {
		_return = nil;
	};
	sleep 0.5; 
};
serverRunningQuery = false;
};

this ranking system is working very good and showing up !

so i just need to add or link real rank names and a picture!

nothing else

if you want i can send you in pm my mission.pbo to check it, cause maybe you need to look in other files i did not post here.

anyway everybody is welcome to help me and i will share the code with you so you can use it.;)

thanks

Share this post


Link to post
Share on other sites
if i change the rank number "1" to an other text for example: private first class, the database rank system is broken i get in place of rank "1" rank "any".

I do not know much about database stuff but it breaks because the code asks for Rank "1" and you give "text". Theoretically speaking the simplest way will be to simply create a new entry on your database and try it to display it just like you display with "rank 1".

so is there a simple way to just link rank "1" text, to other text whatever it is, without or with editing the getRankInfo.sqf or another file.

if i can link rank "1" to another text for example just after it: "Rank: 1 private first class" and not what i have now "Rank: 1"

The simplest way that i know of to add a text is :https://community.bistudio.com/wiki/text. So maybe something like this ? :

if (_xp >= 900) then
{
   _rank = 4;
   _nextrankxp = 1300;
    _stxt2 = text "Private 2nd Class."

}else{
if (_xp >= 600) then
{
   _rank = 3;
   _nextrankxp = 900;
   _stxt2 = text "Sergeant First Class."

}else{
if (_xp >= 300) then
{
   _rank = 2;
   _nextrankxp = 600;
   _stxt2 = text "Staff Sergeant."

}else{
   _rank = 1;
   _nextrankxp = 300;  
   _stxt2 = text "Army Specialist."

Then you can use the same method that your are using to display "Rank 1" on your screen. But yeah, hope someone else can hop in and help you out.:)

Regards

Seed

Share this post


Link to post
Share on other sites
I do not know much about database stuff but it breaks because the code asks for Rank "1" and you give "text". Theoretically speaking the simplest way will be to simply create a new entry on your database and try it to display it just like you display with "rank 1".

The simplest way that i know of to add a text is :https://community.bistudio.com/wiki/text. So maybe something like this ? :

if (_xp >= 900) then
{
   _rank = 4;
   _nextrankxp = 1300;
    _stxt2 = text "Private 2nd Class."

}else{
if (_xp >= 600) then
{
   _rank = 3;
   _nextrankxp = 900;
   _stxt2 = text "Sergeant First Class."

}else{
if (_xp >= 300) then
{
   _rank = 2;
   _nextrankxp = 600;
   _stxt2 = text "Staff Sergeant."

}else{
   _rank = 1;
   _nextrankxp = 300;  
   _stxt2 = text "Army Specialist."

Then you can use the same method that your are using to display "Rank 1" on your screen. But yeah, hope someone else can hop in and help you out.:)

Regards

Seed

well i tried this and it doesn't show up i only see rank: 1

no i'm confused with all these codes i try to understand i read and read again and test a lot but now i don't know anymore what to do!

thank you for your help, hope someone will get on this for me

Share this post


Link to post
Share on other sites

:confused: Anyone ????? i'm sure the response is here on these pages !!!! I need your help !!!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×