Raised This Month: $51 Target: $400
 12% 

help. need to replace all entities given by name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Static2601
Senior Member
Join Date: Jun 2010
Old 12-28-2014 , 20:57   help. need to replace all entities given by name
Reply With Quote #1

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
Static2601 is offline
Static2601
Senior Member
Join Date: Jun 2010
Old 12-29-2014 , 00:40   Re: help. need to replace all entities given by name
Reply With Quote #2

Ok I think I figured it out, it was finding all the info targets that have the same name, as I wanted it to and was placing a model at the origin of each target, but having teleportentity like it is, i think, will make it teleport from the first target to the next til it reaches the last one.
I solved this by moving teleport entities outside the function and into another, then called it from where teleportEntitys were.So far this works good but if you have a better way please post it, thanks.

Last edited by Static2601; 12-29-2014 at 00:41.
Static2601 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode