Jump to content
Sign in to follow this  
Gunter Severloh

Can I have multiple names for a unit?

Recommended Posts

Hey guys.

Question in my title refers to having a unit being a player in mp have multiple names, multiple names being for example I use various scripts in my missions,

one script I use to keep my weapons after I get killed so the name of the unit is w1, now I wanted to give my soldier another ability,

which is to call for airsupport which requires yet another name to use.

but having two names or more for that matter dont work, is there a certain way to name a unit with multiple names and still

gain the function of multiple scripts that depend on the names?

I have tried w1;m1 dont work, not sure what else to try and or would actually work or would be correct.

w1 would be for keeping my weapons, and m1 for the ability to call air support.

any help is much appreciated.

Share this post


Link to post
Share on other sites

Why do you need two names? There's no logical reason I can think of, but if you really wanted you could assign a unit to any number of arbitrary global vars, ex:

w1 = this; m1 = this; somedude = this; andyetanothername = this

Share this post


Link to post
Share on other sites

I dont want two names, but the two scripts I use dont work with two names, its either I use one script or the other.

The script for air support has the name of m1, problem is I also want to respawn with the last weapon i used,

but that also requires a name of w1.

I got an idea of what your code is but not really understand how it works, how would I use it and how would it work,

I mean I put it into a unit's init line, how would I know that the game would read the multiple names as being names that the scripts call for?

Share this post


Link to post
Share on other sites

When you have an Init field, then that will run upon the start of the mission. If you write

bobobobob = this;

in a unit's init, then "bobobobo" will be a variable assigned to the unit. These variables are the names you want, so to answer your question, you can be 100% sure this will work.

However, if you'd post your scripts, I am also 100% we can find a way for you to use only one variable. ;)

Normally in a script, instead of naming an object directly, we use parameters. In a trigger you can have

nul = [] execVM "scripts\arty.sqf";

I bet that's how your script is called. The problem is that there are no variables or other in the [] bit. So, when the arty script says "createVehicle "81_Sh_HE"", that's how it needs to be. However, most scripters will prefer to have a choice. As an example, they will write "createVehicle _bullet;"

_bullet, or any other such word (_pos, _unit, sometimes _i or _j for compressed counting), is defined early in the script. You may see it read "_bullet = _this select 0;" at the top. This is a way to translate any variable that the mission editor wants, into the script, without modifying the script. _this select 0 is the first variable of the execVM array. A scripter would make an artillery sqf, but leave the type of explosion up to the mission editor to decide. That's how we can alternate between 81mm, 105mm or 122mm rounds.

If I completely misunderstood your level of knowledge, please forgive me. =)

Share this post


Link to post
Share on other sites

Ok, interesting. to answer your questions

if you'd post your scripts, I am also 100% we can find a way for you to use only one variable.

Heres the two scripts I'm using that require names for a unit:

;[b]Universal Weapons Respawn Script[/b] v1.04 (March 31, 2003) revised (February 1, 2007)
;Required Version: ArmA
;original by toadlife revised by norrin for ArmA
;toadlife@toadlife.net
;intialize like this: ["unitname",0] exec "weapons_respawn.sqs"
;            Or this: ["unitname",1] exec "weapons_respawn.sqs"
;
; * "unitname" = The name of the player the script runs on (must be enclosed by quotes!)
; * 0/1 = method of repleneshing weapons
;  **if method is 0, the player gets the same weapons he started out with every time
;  **if method is 1, the player gets the same weapons he had when he died
;
; Advanced example method of initializing script - put the following lines in your init.sqs,
; and replce the unit names with your own:
;_units = ["w1","w2","w3","w4","w5","w6","w7","w8","w9","w10","w11","w12","w13","w14","w15","w16","w17","w18"]
;{[_x,0] exec "weapons_respawn.sqs"} foreach _units
;
;

~(random 0.3)
_name = _this select 0
_method = _this select 1
_hasrifle = false
_unit = call compile format["%1",_name]
?(_method == 0):_return = "checklocal";goto "guncheck"

#checklocal
_unit = call compile format["%1",_name]
?(local _unit):goto "respawnloop"
~(1 + (random 3))
goto "checklocal"

#respawnloop
@!alive _unit
#checkmethod
?(_method == 1):_return = "waitforlife";goto "guncheck"

#waitforlife
@alive call compile format["%1",_name]
_unit = call compile format["%1",_name]
removeAllWeapons _unit
?_hasrifle:_guns = _guns - [_prigun];_guncount = count _guns
_c = 0
while {_c <= (_magcount - 1)} do {_unit addmagazine (_mags select _c); _c = _c + 1}
_c = 0
while {_c <= (_guncount - 1)} do {_unit addweapon (_guns select _c); _c = _c + 1}
?_hasrifle:_unit addweapon _prigun;_gun = _guns + [_prigun]
;//If unit has a rifle select it
?_hasrifle:goto "selectrifle"

;//No rifle - if unit has a pistol, select it
?_unit hasweapon ((weapons _unit - [secondaryweapon _unit,"Binocular","NVGoggles"]) select 0):_unit selectweapon ((weapons _unit - [secondaryweapon _unit,"Binocular","NVGoggles"]) select 0);goto "respawnloop"

;//No rifle or pistol, select secondary weapon
_unit selectweapon secondaryweapon _unit
goto "respawnloop"

#selectrifle
;// BUG WORKAROUND! - Added to compensate for selectweapon bug 
;// Any gun with more than one muzzle (grenadelaunchers) cannot be selected with selectweapon!
;// Default Grenadelaunchers supported - Add your own types if you need to.
_unit selectweapon _prigun
?_prigun == "M16A2GL":_unit selectweapon "M16Muzzle"
?_prigun == "M16A4GL":_unit selectweapon "M16Muzzle"
?_prigun == "M16A4_ACG_GL":_unit selectweapon "M16Muzzle"
?_prigun == "M4GL":_unit selectweapon "M4Muzzle"
?_prigun == "M4A1GL":_unit selectweapon "M4Muzzle"
?_prigun == "AK74GL":_unit selectweapon "AK74Muzzle"

goto "respawnloop"


#guncheck
_guns = weapons _unit
_mags = magazines _unit
~(random 0.5)
_guncount = count _guns
_magcount = count _mags
?_unit hasweapon (primaryweapon _unit):_hasrifle = true;_prigun = primaryweapon _unit;goto _return
_hasrifle = false
goto _return

for this as it says in the script I use:

["w1",1] exec "weapons_respawn.sqs"

for the other script called Air Support, theres to many scripts in this one to post, so I will give you a link instead:

http://www.armaholic.com/page.php?id=8337

it has a demo mission. In the demo your unit has a name m1.

If I completely misunderstood your level of knowledge, please forgive me. =)

I'm not new to scripts, been using them since the Arma came out, but I am still learning, I really learned how to get around scripts, and code and stuff just by looking through the scripts, and testing them out and seeing what happens, and just by building mp missions. I'm no scripter, or coder, I have an idea but have no clue on where to start with it, but learning different commands I can implement into my missions I find fun and exciting.

If one were to describe how a code worked not on a technical level of in terms of coding but basically by the effects ingame then i would learn quickly. I am interested in the scripting and coding but really dont have te patience for it, i'd prefer working stuff that takes very little time to build in terms of their use ingame applications.

Appreciate the help though.

Share this post


Link to post
Share on other sites

Well for the first script you posted, it allows you to use any name you want as long as you pass that name to the script as the first argument. Ex:

["Bob",1] exec "weapons_respawn.sqs"

Where Bob is the name of the respawning unit.

Share this post


Link to post
Share on other sites
Why do you need two names? There's no logical reason I can think of, but if you really wanted you could assign a unit to any number of arbitrary global vars, ex:

Well for the first script you posted, it allows you to use any name you want as long as you pass that name to the script as the first argument. Ex:

["Bob",1] exec "weapons_respawn.sqs"

Where Bob is the name of the respawning unit.

what they said

variable names are just that...names...they don't really have much to do with the object other than to keep track of it. it would be borderline-retarded behavior for the developers of arma to require you to have different variable names for different functions/keywords/etc

Share this post


Link to post
Share on other sites

@Gunther

The script author made the following comments:

;intialize like this: ["unitname",0] exec "weapons_respawn.sqs"

; Or this: ["unitname",1] exec "weapons_respawn.sqs"

;

; * "unitname" = The name of the player the script runs on (must be enclosed by quotes!)

; * 0/1 = method of repleneshing weapons

; **if method is 0, the player gets the same weapons he started out with every time

; **if method is 1, the player gets the same weapons he had when he died

;

; Advanced example method of initializing script - put the following lines in your init.sqs,

; and replce the unit names with your own:

;_units = ["w1","w2","w3","w4","w5","w6","w7","w8","w9","w10","w11","w12","w13","w14","w15","w16","w17","w18"]

;{[_x,0] exec "weapons_respawn.sqs"} foreach _units

You should read these comments carefully. Unfortunately, not all authors detail the correct procedure in easy terms, but in this case I think the author provided a good explanation. Simply, that you put "["unitname",0] exec "weapons_respawn.sqs"". That unitname means any unit's assigned name.

When you later see him using the ["w1","w2"... etc] array, what he is doing is assigning the variable _units to every one of the soldiers named in that list. That way he can call the list later, without repeating all the names.

Then, he takes that list (which has now been given a name), and makes every one of the units listed use the script. He does this by the forEach command, which is a command that takes any command inside the {} brackets, and has every unit in the array do that command. For instance, he could've written {setbehaviour "safe"} forEach _units to make them all chill.

I'll send you a brief PM.

Hope this helps.

Edited by SCAJolly

Share this post


Link to post
Share on other sites

Ya I get what your saying, i have it already setup for 4 guys to have

["w1",1] exec "weapons_respawn.sqs" units name is w1 ect

["w2",1] exec "weapons_respawn.sqs"

["w3",1] exec "weapons_respawn.sqs"

["w4",1] exec "weapons_respawn.sqs"

each unit or soldier has their own name.

I used w1 as it was a name already used, i personally dont care about the name as u dont see it ingame nor does it have any

function anyways on its own, so i used w1 which he had in the script already.

My real question is, so I have a player pick a role and the role (unit) in mp is the 2nd guy for example, so the code

for this character role would be:

["w2",1] exec "weapons_respawn.sqs" in his init line.

so this guy when he dies his weapons he had last will respawn with him.

now the problem arises what I want to do is have another feature that this same guy is to have which is airsupport,

I can call airsupport but my problem is I cant respawn with my weapons which sucks, but I can call airsupport, the other

guys cant call air support but they can respawn with their weapons, so I have a double edged sword here.

In the units name for the guys that have their weapons respawn with them their names are w2, ect.,

name of my guy is m1 as that is used for the airsupport script.

in the characters name field what do i put so that I can respawn with my weapons, and call airsupport too,

even if its just me that can call airsupport, as it wouldn't be realistic if everyone could call a fighter jet in to drop bombs :D

I'm still missing what i have to put where.

Do i use the name field of the unit, or the initialization line instead to call both scripts,a nd if I used the

init line would the guy still need a name in the name field?

Appreciate the help, and I am learning, but please make examples of how the codes works in terms of how it

responds ingame or you might lose me, i got the idea, but its hard to make an clear association sometimes if you get to technical.

Share this post


Link to post
Share on other sites
Ya I get what your saying, i have it already setup for 4 guys to have

["w1",1] exec "weapons_respawn.sqs" units name is w1 ect

["w2",1] exec "weapons_respawn.sqs"

["w3",1] exec "weapons_respawn.sqs"

["w4",1] exec "weapons_respawn.sqs"

each unit or soldier has their own name.

I used w1 as it was a name already used, i personally dont care about the name as u dont see it ingame nor does it have any

function anyways on its own, so i used w1 which he had in the script already.

My real question is, so I have a player pick a role and the role (unit) in mp is the 2nd guy for example, so the code

for this character role would be:

["w2",1] exec "weapons_respawn.sqs" in his init line.

so this guy when he dies his weapons he had last will respawn with him.

now the problem arises what I want to do is have another feature that this same guy is to have which is airsupport,

I can call airsupport but my problem is I cant respawn with my weapons which sucks, but I can call airsupport, the other

guys cant call air support but they can respawn with their weapons, so I have a double edged sword here.

In the units name for the guys that have their weapons respawn with them their names are w2, ect.,

name of my guy is m1 as that is used for the airsupport script.

in the characters name field what do i put so that I can respawn with my weapons, and call airsupport too,

even if its just me that can call airsupport, as it wouldn't be realistic if everyone could call a fighter jet in to drop bombs :D

I'm still missing what i have to put where.

Do i use the name field of the unit, or the initialization line instead to call both scripts,a nd if I used the

init line would the guy still need a name in the name field?

Appreciate the help, and I am learning, but please make examples of how the codes works in terms of how it

responds ingame or you might lose me, i got the idea, but its hard to make an clear association sometimes if you get to technical.

how about you post what youre using to call both scripts. i think youre confused about whats going on. you shouldnt be concerned with whats in the scripts themselves, you should only be concerned with how their called. i dont know how the air support script works, since it doesnt have whats in it readily available (and i dont want to download it), but im thinking that youre just calling it the wrong way. it doesnt matter if inside the script, the unit is called m1, it matters what you named the unit, and what you passed in, nothing else. each script should operate independently of the other, so there shouldnt be a reason for one to work, and one not to

so basically, you should be able to pass w1 into both scripts, you shouldnt be changing the name for any reason.

Share this post


Link to post
Share on other sites

the script for the respawn with same weapons is in the unit's init line, you put this:

["w1",1] exec "weapons_respawn.sqs"

then in the box for the name you put w1

for each unit a player picks when they join the server, each character needs a new line,

so the 2nd guy would be:

["w2",1] exec "weapons_respawn.sqs" his name is w2

rd guy would be:

["w3",1] exec "weapons_respawn.sqs" his name is w3

for the airsupport script

you put m1 for the unit's name.

and then a marker is placed on the map far away as that is where the planes and choppers come from,

the marker is named:

Aspad

thats how its called.

I understand it np as the scripts works, and i have used them many times.

I think you guys are missing what Im asking or think Im missin what Im trying to do with the scripts.

Im trying to call 2 or more scripts that add2 seperate features to one person on a server,

but the requirement to call the script as seen above is one script is called by the

["w1",1] exec "weapons_respawn.sqs" his name is w1

line in his init line, and then his name is w1, well the problem once again is that I want to use that while

also using the airsupport script which just needs the m1 name.

so as I ask again the problem being seen here the name w2:

http://img257.imageshack.us/img257/992/namea.jpg

How can I make two names work that call two different scripts, as i said w2 and M1 dont work in the same box,

so how can I call both scripts with one person, that requires the names there?

Share this post


Link to post
Share on other sites

We'll help you best if you post both scripts. We can then tell you what to put in w1's INIT.

Share this post


Link to post
Share on other sites
Or this: ["unitname",1] exec "weapons_respawn.sqs"

;

; * "unitname" = The name of the player the script runs on (must be enclosed by quotes!)

; * 0/1 = method of repleneshing weapons

; **if method is 0, the player gets the same weapons he started out with every time

; **if method is 1, the player gets the same weapons he had when he died

;

; Advanced example method of initializing script - put the following lines in your init.sqs,

; and replce the unit names with your own:

;_units = ["m1","m2","m3","m4","m5","m6","m7","m8","m9","m10" ,"w11","w12","w13","w14","w15","w16","w17","w18 "]

;{[_x,0] exec "weapons_respawn.sqs"} foreach _units

Change to ^^

["m1",1] exec "weapons_respawn.sqs"; nul = [m1,"jadam","lgb","cbuap","cbuat","cbumine","cas","helo","trans"] execVM "airSup\airSupInit.sqf";

In the players INIT or as draper said in his readme place this into init

nul = [m1,"jadam","lgb","cbuap","cbuat","cbumine","cas","helo","trans"] execVM "airSup\airSupInit.sqf";

As an aside limit the amount of air support used, missions get very easy with 99 airstrikes.

Share this post


Link to post
Share on other sites

This is not Draper's Script, he also dont have a readme for the air support script.

the weapons respawn script is by:

;Universal Weapons Respawn Script v1.04 (March 31, 2003) revised (February 1, 2007)

;Required Version: ArmA

;original by toadlife revised by norrin for ArmA

;toadlife@toadlife.net

["m1",1] exec "weapons_respawn.sqs"; nul = [m1,"jadam","lgb","cbuap","cbuat","cbumine","cas"," helo","trans"] execVM "airSup\airSupInit.sqf";

I see what you did here instad of using w1 for the weapon respawn you used m1 which was the name needed for the airsupport.

:j: stupid me why didn't I think of that, lol

gees... I appreciate the help and insight. this will def fix the one issue I have.

Thanks again!

Share this post


Link to post
Share on other sites

I see what you did here instad of using w1 for the weapon respawn you used m1 which was the name needed for the airsupport.

:j: stupid me why didn't I think of that, lol

gees... I appreciate the help and insight. this will def fix the one issue I have.

Thanks again!

lol, thats what all of us were trying to tell you...it doesnt matter what is inside the script, it matters how you call it

Share this post


Link to post
Share on other sites

I knew how to call the script, it was how do you call two scripts requiring two names using the same name box for the unit.

I knew there was a way to use the init box to change this, but wasn't sure how.

Share this post


Link to post
Share on other sites
I knew how to call the script, it was how do you call two scripts requiring two names using the same name box for the unit.

I knew there was a way to use the init box to change this, but wasn't sure how.

no, you were calling the script wrong. passing arguments into the script was incorrect. i think you need to spend some time learning what scripts are, and how they work from a top-level view. i dont think you understand how this stuff works. passing arguments into a script is part of calling a script

these are some links you might find useful. it is in an actual language instead of whatever substitution script that arma uses. functions and methods (which are just another name for a function) are some sort of function, which has arguments that are passed in. part of calling that function, is that you have to specify the correct arguments, so in this respect, a function is the same as the script you are trying to call (all I want you to really focus on, is the arguments for the functions in the articles following):

Java Methods

C Functions

For everything else, I suggest you find a nice arma tutorial to teach you what you are actually doing. As the saying goes: give a man a fish, feed him for a day. teach a man to fish, feed him for a lifetime. What this thread has done is fed you a fish, but you clearly (no offense) don't know why we told you what we did. This is clear because you still don't understand why you were supposed to pass in the same variable name. I couldn't find a link with variables that might help you, but i did only search for a few seconds (don't look for variables in any actual language, because there are keywords and data types used in their declaration, which is not used in Arma, and it could end up confusing you more than helping). For this particular case, one of the arguments was a string (or more explicitly, an array of strings), that was to represent a variable name. passing in the variable name of the unit that was to receive the added support was part of the scripts parameters, which is why i suggested you posting up your specific lines that you used to call the scripts itself.

long story short: you need to do some more learning to understand the inner working of what you are doing instead of just copying and pasting it

Edited by GDICommand

Share this post


Link to post
Share on other sites

Ok, I appreciate the support, and the heed to know for myself how to better understand this.

which is why i suggested you posting up your specific lines that you used to call the scripts itself.

I did that. Dont know what else to tell you here other then I was really just running the script based on what they said to do.

The respawn with weapons was add the code into the unit's init line, and give him a name, i did that, the airsupport was a name was needed,

and a marker on the map as well as a line in the init script, i did that.

I basically copy n paste the script codes and such, I mean what else am I supposed to do considering I didn't make the scripts.

I've learned how to implement many scripts over the years, and some more complicated then others, some I ran into issues as

there was no clear explanation on how to make multiple scripts to work together when like 3-4 scripts all had codes that

needed to be in an init script, and in a description.ext.

I will look into some tutorials for scripting, I know where I can find some.

thanks again.

Share this post


Link to post
Share on other sites
Change to ^^

["m1",1] exec "weapons_respawn.sqs"; nul = [m1,"jadam","lgb","cbuap","cbuat","cbumine","cas"," helo","trans"] execVM "airSup\airSupInit.sqf";

In the players INIT or as draper said in his readme place this into init

nul = [m1,"jadam","lgb","cbuap","cbuat","cbumine","cas"," helo","trans"] execVM "airSup\airSupInit.sqf";

I had tried this, I updated my mission, and it dont work

["m1",1] exec "weapons_respawn.sqs"; nul = [m1,"jadam","lgb","cbuap","cbuat","cbumine","cas"," helo","trans"] execVM "airSup\airSupInit.sqf";

I set up the init line with instead, changing w1 to m1.

["m1",1] exec "weapons_respawn.sqs";

the

nul = [m1,"jadam","lgb","cbuap","cbuat","cbumine","cas"," helo","trans"] execVM "airSup\airSupInit.sqf";

is already called in the init script, and I got the weapon respawn to work np, and the air support script to work as well.

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  

×