Page 1 of 1
finding a targetname via a different value
Posted: Thu Jul 14, 2005 4:40 am
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?
Posted: Thu Jul 14, 2005 5:39 am
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.
Posted: Thu Jul 14, 2005 11:16 am
by bdbodger
COD does that but not mohaa it has to be assigned a targetname or spawned useing a variable like level.thing = spawn ....
Posted: Thu Jul 14, 2005 6:09 pm
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?
Posted: Thu Jul 14, 2005 6:26 pm
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
Posted: Thu Jul 14, 2005 8:28 pm
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

Posted: Thu Jul 14, 2005 8:57 pm
by jv_map
Arrays can have variable sizes in mohaa

Posted: Thu Jul 14, 2005 11:16 pm
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
Posted: Thu Jul 14, 2005 11:46 pm
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.
Posted: Fri Jul 15, 2005 12:05 am
by Elgan
why not just array the targtanmes. like players;)
Posted: Fri Jul 15, 2005 12:07 am
by lizardkid
i ended up realizing that just now
thanks guys.
Posted: Fri Jul 15, 2005 10:20 am
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 .
Posted: Fri Jul 15, 2005 11:09 am
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
Posted: Fri Jul 15, 2005 1:25 pm
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 .
Posted: Fri Jul 15, 2005 4:28 pm
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
but that's interesting you can do entity arrays like that, might come in handy.