Jump to content
  • 0

setRank script


Swash

Question

I've been trying to find helpful information about setRank, but everything I found is vague or relies on global channel being active.

 

Does anyone have any idea how I can set group rank on login? Maybe a BEC script to set a player's group rank based on ID? Or mission script?

 

Any help or gentle nudging in the right direction would be most appreciated.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

first google result:

https://community.bistudio.com/wiki/setRank

 

 

You would call this within your script block.

player setRank "COLONEL"

 

 

If you're asking how to implement this in your mission file... You could hardcode your group members ranks by ID in your init.sqf or anywhere else in your mission file if you liked...

 

something like this could work... no idea if it actually does what you want though...

// ranks.sqf  -  called from init.sqf

// we could have 1 big multi-dim array containing each users ID and Rank but...
// that would make this harder to adjust in the future since this is a manual
// process.   If you were to load this data from a DB for instance, you might
// want to keep it in a multi-dimensional array like: 
// [["1234","PRIVATE"],["231","General"]]
Ranks_PRIVATE		=	[
							"1234567",	// Me
							"7654321" 	// No trailing ,!
						];
Ranks_CORPORAL		=	[];
Ranks_SERGEANT		=	[];
Ranks_LIEUTENANT	=	[];
Ranks_CAPTAIN		=	[];
Ranks_MAJOR			=	[];
Ranks_COLONEL		=	[]; 



_playerUID = player getPlayerUID;
_found = false;
_rank = "PRIVATE"; // default private rank

// check to see if our player matches 

while {!_found} do {
	if (_playerUID in Ranks_PRIVATE) then {
		_rank = "PRIVATE";
		_found = true; // breaks us out of this while loop
	};
	// ... and so on
};

// finally set our players rank!
player setRank _rank;
Link to comment
Share on other sites

  • 0

Thank you hambeast you are the best! I'll try this out tonight.

 

 

 

first google result:

https://community.bistudio.com/wiki/setRank

 

 

This was one of the things I found in my search, but had no clue how to implement in sqf.

I read all that page and was left saying "um... what??" lol

I wish I could give this an extra like for posting comments in the script as well, wish everyone did this!

This was more than a "gentle nudge" this was above and beyond what I expected. Thank you!

 

btw great Mr. Reynholm avatar lol

Link to comment
Share on other sites

  • 0

Thanks again hambeast for the scripting help. I'm not all that familiar with sqf, but I recognize coding patterns from other languages.

I had to add in a wait for ingame and I did some other modifications to the script.

With your permission I'd like to post the final script in the A3 Epoch Resources/Scripts for others to use.

Original script credit to you of course.

 

Here is the final script I intend to post.

//ranks.sqf
//Original Script by hambeast
//Modified and Completed by Evan Black

// Wait for ingame
waitUntil {!isNuLL(uiNameSpace getVariable ["EPOCH_loadingScreen",displayNull])};
waitUntil {isNuLL(uiNameSpace getVariable ["EPOCH_loadingScreen",displayNull])};
sleep 2; //Optional delay to ensure script execution

// Rank/UID list. Use Example Below.
//UID Example: Ranks_CORPORAL        =    ["7656xxxxxxxxxxxxxx","7656xxxxxxxxxxxxxx"]; no trailing coma
Ranks_CORPORAL        =    [];
Ranks_SERGEANT        =    [];
Ranks_LIEUTENANT    =    [];
Ranks_CAPTAIN        =    [];
Ranks_MAJOR        =    [];
Ranks_COLONEL        =    [];

_playerUID = getPlayerUID player; //get player UID


// loop to check to see if our player matches
_found = false;
while {!_found} do {
    if (_playerUID in Ranks_CORPORAL) then {
        player setRank "CORPORAL";
        _found = true; // endloop
    }else{
        if (_playerUID in Ranks_SERGEANT) then {
            player setRank "SERGEANT";
            _found = true;

        }else{
            if (_playerUID in Ranks_LIEUTENANT) then {
                player setRank "LIEUTENANT";
                _found = true;

            }else{
                if (_playerUID in Ranks_CAPTAIN) then {
                    player setRank "CAPTAIN";
                    _found = true;

                }else{
                    if (_playerUID in Ranks_MAJOR) then {
                        player setRank "MAJOR";
                        _found = true;

                    }else{
                        if (_playerUID in Ranks_COLONEL) then {
                            player setRank "COLONEL";
                            _found = true;

                        }else{
                            player setRank "PRIVATE"; //setting default rank for all others
                            _found = true;
                            
                        };
                    };
                };
            };    
        };    
    };
};

Link to comment
Share on other sites

  • 0

Thanks again hambeast for the scripting help. I'm not all that familiar with sqf, but I recognize coding patterns from other languages.

I had to add in a wait for ingame and I did some other modifications to the script.

With your permission I'd like to post the final script in the A3 Epoch Resources/Scripts for others to use.

Original script credit to you of course.

 

Here is the final script I intend to post.

//ranks.sqf
//Original Script by hambeast
//Modified and Completed by Evan Black

// Wait for ingame
waitUntil {!isNuLL(uiNameSpace getVariable ["EPOCH_loadingScreen",displayNull])};
waitUntil {isNuLL(uiNameSpace getVariable ["EPOCH_loadingScreen",displayNull])};
sleep 2; //Optional delay to ensure script execution

// Rank/UID list. Use Example Below.
//UID Example: Ranks_CORPORAL        =    ["7656xxxxxxxxxxxxxx","7656xxxxxxxxxxxxxx"]; no trailing coma
Ranks_CORPORAL        =    [];
Ranks_SERGEANT        =    [];
Ranks_LIEUTENANT    =    [];
Ranks_CAPTAIN        =    [];
Ranks_MAJOR        =    [];
Ranks_COLONEL        =    [];

_playerUID = getPlayerUID player; //get player UID


// loop to check to see if our player matches
_found = false;
while {!_found} do {
    if (_playerUID in Ranks_CORPORAL) then {
        player setRank "CORPORAL";
        _found = true; // endloop
    }else{
        if (_playerUID in Ranks_SERGEANT) then {
            player setRank "SERGEANT";
            _found = true;

        }else{
            if (_playerUID in Ranks_LIEUTENANT) then {
                player setRank "LIEUTENANT";
                _found = true;

            }else{
                if (_playerUID in Ranks_CAPTAIN) then {
                    player setRank "CAPTAIN";
                    _found = true;

                }else{
                    if (_playerUID in Ranks_MAJOR) then {
                        player setRank "MAJOR";
                        _found = true;

                    }else{
                        if (_playerUID in Ranks_COLONEL) then {
                            player setRank "COLONEL";
                            _found = true;

                        }else{
                            player setRank "PRIVATE"; //setting default rank for all others
                            _found = true;
                            
                        };
                    };
                };
            };    
        };    
    };
};

 

 

Swash, I am so happy what I typed helped you out!   I think we forget sometimes, just how hard it is to make the jump into Arma coding from other languages.  But... once you get the basics, the rest will become clear.

Link to comment
Share on other sites

  • 0

A final release of a completed script has been posted to

It is much cleaner and better. If it is approved, you should use that script.

Thank you hambeast for all your help!

Link to comment
Share on other sites

  • 0

Help me install!

The final script is posted at

It has step by step instructions on how to install.

 

Hi,

I used that script and it work fine with me! Ty, i hope that be implemented in future!

A cleaner and faster script has been posted to

Hope you like it!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...