finding a targetname via a different value

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

finding a targetname via a different value

Post by lizardkid »

I have 7 (max) different guys that i assign the same value, squad #, and i want to be able to find their targetnames via their squad number. How is this possible?

EDIT: on the same note how could i detect a chair without knowing it's $targetname and assuming there's more than one?
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

They need to be assigned to a local, level, group or game variable. If they're not, you cannot do this.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

COD does that but not mohaa it has to be assigned a targetname or spawned useing a variable like level.thing = spawn ....
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

alright then it looks like i need to make some sort of dynamic namer.. :S
(this is for the AI side of the squad script)

so how could i make a thread that adds a variable to a new variable's name.

like say level.existantSquads is 4. each new squad gets that number then it's incremented. suppose the convention would be

level.squad#_guy# = self

so i'd probably have a set part of code that went like...

Code: Select all

level.squad#_guy1 = $guy1
level.squad#_guy2 = $guy2
etc. that'd be childs play, but how could i add the value of level.existantSquads to the # part of the variable?
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Elgan
Lieutenant General
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

im confused:S

why cant u just have them in a array?

then access them via their squad number...

and the chair thing wud be world unl;ess u spawned it:P
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

why cant u just have them in a array?

then access them via their squad number...
because i don't know how many there will be.

i want to access them via their squad number, that's what i was trying to do, find entities based on a value other than targetname.

the reason i can't do a level.squad = ... array thing is because there could be any number of squads, there could be one there might be 10.
then access them via their squad number...
explain :P
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Arrays can have variable sizes in mohaa :)
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

You can do something like this if you give all of them the targetname $guy

for(local.i=1;local.i <= $guy.size;local.i++)
{
level.guy[$guy[local.i].squad] = $guy[local.i]
}
then you can use the number level.guy[2] for example to get the guy with that squad number or you can do it like this

for(local.i=1;local.i <= $guy.size;local.i++)
{
level.guy+($guy[local.i].squad]) = $guy[local.i]
}
that way will give you level.guy2
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

OH! so make an array of arrays and access based on the squad number?

cool i didn't know i could make an array of arrays.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Elgan
Lieutenant General
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

why not just array the targtanmes. like players;)
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

i ended up realizing that just now :P

thanks guys.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Elgan wrote:why not just array the targtanmes. like players;)
Well $guy[2] may not have the squad number 2 if that is even really needed if you make another $guy then $guy[2] will become $guy[3] I belive they are incremented up when new guys are added to the targetname array .
Image
Elgan
Lieutenant General
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

really?, i didnt know tbh.. ill do some testing today./ it wud be odd if it moved a thing up the array:S

he cud still find what dude is what though and he cud give them a variable also. He cud also just use a level var in the end.

whatever is easiest to udnerstand
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

yes you can go though all $guys and find the one with the right squad number level is not nessesary . Without seeing the script no way to say what way to do it there maybe several ways to do something one no better than another .
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

well what i did in the end was knowing that max amount of guys i each squad was 7, so i wrote it in little blocks of 7, first 7 is squad one.. second is squad 2... etc. just used a little multiplication with the squad number, works good for me :D

but that's interesting you can do entity arrays like that, might come in handy.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Post Reply