FindExactSpawnID and TargetExact, finding spawns by name
Posted: Fri Aug 06, 2004 1:12 pm
FindExactSpawnID will return the spawn id of the spawn that matches the exact name passed to it, TargetExact will target the spawn matching the exact name.
The reason for this is that if you have two players with names that contain the same string, for example you have a toon Joe and a second toon Joey and you want to target Joe. Typing '/target joe' will target joey if he happens to be closer to you. These will match Joe no matter what.
The reason for this is that if you have two players with names that contain the same string, for example you have a toon Joe and a second toon Joey and you want to target Joe. Typing '/target joe' will target joey if he happens to be closer to you. These will match Joe no matter what.
Code: Select all
Sub FindExactSpawnID(string Name)
/declare CurrentID int local
/declare FirstID int local
/declare Counter int local 1
/varset CurrentID ${Spawn[${Name}].ID}
:FESI_FindNext
/if (!${CurrentID} || ${Spawn[id ${CurrentID}].CleanName.Equal[${Name}]}) /return ${CurrentID}
/varset CurrentID ${Spawn[id ${Me.ID}].NearestSpawn[${Counter},${Name}].ID}
/varcalc Counter ${Counter}+1
/goto :FESI_FindNext
/return 0
Code: Select all
Sub TargetExact(string Name)
/declare CurrentID int local
/declare FirstID int local
/declare Counter int local 1
/varset CurrentID ${Spawn[${Name}].ID}
:TE_FindNext
/if (!${CurrentID}) /return 0
/if (${Spawn[id ${CurrentID}].CleanName.Equal[${Name}]}) {
/target id ${CurrentID}
/return
}
/varset CurrentID ${Spawn[id ${Me.ID}].NearestSpawn[${Counter},${Name}].ID}
/varcalc Counter ${Counter}+1
/goto :TE_FindNext
/return