View Single Post
[email protected]
Junior Member
Join Date: Aug 2013
Old 08-07-2013 , 13:09   Re: Need help with entity editing.
Reply With Quote #7

Quote:
Originally Posted by Doodil View Post
Well, first of all you are only editing one (the first) func_train. You've got to use a loop like this to process all of them:

PHP Code:
public OnPluginStart()
{
    new 
ent = -1;
    while ((
ent FindEntityByClassname(ent"func_tanktrain")) != -1)
    {
        new 
String:classname[32];
        
GetEdictClassname(entclassname32);
        
DispatchKeyValue(ent"orientationtype""0");
    }    

(Imagine the function as a list of entities, the first time you start from the very first element until you find the first entity that has the classname of "func_tanktrain", the second loop you start from the index of the first entity, to not find this one again, but instead the next entity in the list. If you move through the whole list without finding the entity, the function return -1 and therefore ends the loop)

Another thing is the way you dispatch the key value. If you are sure that it's a floatvalue you want to dispatch, use DispatchKeyValueFloat instead. You can also check the return value, if you succeeded in changing the value it returns true.

It also might be possible that you have to dispatch another keyvalue to make the changes take effect... I don't really remember which one that was, something about activate I assume (I might be wrong here, but I remember there being something like this some time ago).

I can also imagine that the OnRoundStart or OnMapStart event resets the entities, maybe check into that if the other things don't work.


And last but not least: What are you trying to achieve changing the orientationtype?
Thanks a lot. It works great. However, it is just as you said with the OnRoundStart and OnMapStart. But I cant hook the same to all of those, because the entities properties are set after roundstart and mapstart. (the only thing was that it is a float value, worked as soon as i set DispatchKeyValueFloat in stead of DispatchKeyValue.) Thanks
aMasheep@gmail.com is offline