finding a targetname via a different value
Moderator: Moderators
finding a targetname via a different value
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?
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
۞
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:
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...
etc. that'd be childs play, but how could i add the value of level.existantSquads to the # part of the variable?
(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 = $guy2Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
because i don't know how many there will be.why cant u just have them in a array?
then access them via their squad number...
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.
explainthen access them via their squad number...
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
You can do something like this if you give all of them the targetname $guy
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
for(local.i=1;local.i <= $guy.size;local.i++)
{
level.guy+($guy[local.i].squad]) = $guy[local.i]
}
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.
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
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006



