Forum Jump :

Author Message


Posts: 11
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2011-12-20 11:59        
     
Hi all

I am new here.
I have read a lot of threads to help me with scripting in arma2 OA.
But i have run into a brick wall, so i though i might throw it out there for some help.

It is a bit of a noob question.

I am trying to use the setrank command to promote some units. but i can't get it to work.

I have created a menu list with the various ranks but when i actually select the rank, nothing happens.

I am using this line (in a menu script) to capture the selected unit.

["Promote Unit",[2],"",-5,[["expression","nul= groupSelectedUnits player execVM 'RankX\Promote Unit.sqf'"]],"1","1"],

in the promote.sqf script i use

_unit = _this;

to hold the results in the _unit variable.

but when i run the

_unit setRank "Major";

nothing happens, no rank change anywhere.

I thought i might not have the correct info in the _unit variable so i ran

hint format ["%1",_unit];

and it printed "B 1-1-A:3" for the 3rd selected unit.

Is this the info i need in the _unit variable for the setrank or setUnitRank command to work???

I have read a lot of forums and tutorials and other peoples scripts for hints and help, but no luck.

After a week of banging my head *WALL*

I figured i need more direct feedback.

thanks
Linrox


Author Message


Posts: 1124
Rank:


Level: Member PFS

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2011-12-20 23:51        
     
_unit setRank "Major";
That will raise the rank but it won't make him leader or change his position in the group until the current leader is removed from the group or killed.

Then the next highest ranked unit will take command.

To see the rank use.
hint format ["%1",rank _unit];


Advertisement


Author Message


Posts: 11
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2011-12-21 01:01        
     
Thanks
I already have a working group leader script for changing leaders and making new groups

I appreciate the info

I am just trying to get the unit to increase rank so when i create the new groups the leaders rank is above private
I have also tried the addrating and addscore commands, but i think they only work in MP missions

As mentioned in the my first post the
_unit setRank "Major";
is not working.
I am trying to figure out why.

thanks for the help.

I am starting to think that setRank will only work in multiplayer missions.
This is for a SP campaign.

Linrox


Author Message


Posts: 1124
Rank:


Level: Member PFS

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2011-12-21 01:35        
     
It's probably because higher ranking units can join a group but the lower ranking unit will still be leader.

The only way around this would be some sort of scripted sort based on rank.

How are you creating a group, isn't the first unit always the leader?

I think I've read that in MP a respawning unit will retake command when rejoining the group if he has higher rank.

This post was edited by F2kSel (2011-12-21 01:42, 855 days ago)


Author Message


Posts: 11
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2011-12-21 02:14        
     
The grouping script is not mine.
Lookup Cent_HCS2
That's the script for creating groups, it also allows you to regroup another team in to your team.

As far as i know a highest ranking unit will always be the team leader.

I am not focused on the MP side just yet. This is for a SP Campaign/Mission.

Once i get it working on SP, i might create a MP version.

Thanks for the info.


Linrox


Author Message


Posts: 11
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2011-12-23 04:47        
     
Has anyone else gotten the setRank or setUnitRank commands to work in a SP mission???


Linrox


Author Message


Posts: 11
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2011-12-24 09:50        
     
Well i though i would give you all an update.

I finally got it to work *YAHOO* but it is rather messy.


Can any body tell me why it would not work like this even though the variables hold the right info.

//Promote.sqf
_newRank = _this select 1;
_unit = _this select 0;
_unit setRank (format ["%1",_newRank]);

//RankXmenu.sqf

Rank_menu = [
["Rank",false],
["Promote",[2],"#USER:Rank_menu",-5,[["expression","nul= [groupSelectedUnits player,('CAPTAIN')] execVM 'RankX\promote.sqf'"]],"1","1"]
];

BIS_MENU_GroupCommunication = [
[localize "STR_SOM_COMMUNICATIONS", false],["Rank",[2],"#USER:Rank_menu",-5,[["expression",""]],"1","1"]
];
if (true) exitWith {};



instead i have to use this, which is so messy

//RankXMenu.sqf
sleep 1;
[] call BIS_fnc_commsMenuCreate;

Promote_menu = [
["Rank",false],
["Promote",[2],"#USER:Rank_menu",-5,[["expression","player sidechat ""this is Rank (submenu)"]],"1","1"]
];

Rank_menu = [
["Rank",false],
["Corporal",[2],"",-5,[["expression", "nul= groupSelectedUnits player execVM 'RankX\corporal.sqf'"]],"1","1"],
["Sergeant",[3],"",-5,[["expression", "nul= groupSelectedUnits player execVM 'RankX\sergeant.sqf'"]],"1","1"],
["Lieutenant",[4],"",-5,[["expression", "nul= groupSelectedUnits player execVM 'RankX\lieutenant.sqf'"]],"1","1"],
["Captain",[5],"",-5,[["expression", "nul= groupSelectedUnits player execVM 'RankX\captain.sqf'"]],"1","1"],
["Major",[6],"",-5,[["expression","nul= groupSelectedUnits player execVM 'RankX\major.sqf'"]],"1","1"]
];

BIS_MENU_GroupCommunication = [
[localize "STR_SOM_COMMUNICATIONS", false],["Rank",[2],"#USER:Promote_menu",-5,[["expression",""]],"1","1"]
];

if (true) exitWith {};


//Corporal.sqf

sleep 0.5;

_selected= _this select 0;

_newRank = "CORPORAL";

_selected setRank (format ["%1",_newRank]);


The Variable _newRank in both cases still holds the same value, but it only works when the variable is set in the same script.

I will no doubt be trying to clean it up, but any help in explaining the problem would be appreciated

Linrox

This post was edited by Linrox (2011-12-25 06:18, 851 days ago)