Im trying to add a model to an info_target that i put in my map and trying to find all info_targets that match a certain name and get the origin and angles so I can teleport the model to the info_target.
Im using FindEntityByClassname, then on if string matches, then it will add a model to that position.
What im having trouble with is making it work with more then just one, it can find one out of mutiple points but only assigns to one point. Ive tryed using a loop to keep checking but doesnt work.
Code:
new i = -1;
new Float:entPos[3];
decl String:name[64];
while ((i = FindEntityByClassname(i, "info_target")) != -1)
{
GetEntPropString(i, Prop_Data, "m_iName", name, sizeof(name));
if (StrEqual(name, "target1", false))
{
GetEntPropVector(i, Prop_Send, "m_vecOrigin", entPos);
TeleportEntity(tmodel, entPos, NULL_VECTOR, NULL_VECTOR);
TeleportEntity(cModel, entPos, NULL_VECTOR, NULL_VECTOR);
}
}
im pretty sure I should be using an array and putting all the info_targets with the name "target1" into a list and having it run the code on each one but I have no idea how to do that and have limited experience with arrays.
Hope you can help