View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-07-2013 , 09:09   Re: Need help with entity editing.
Reply With Quote #6

Unless your plugin is late-loaded, the entities aren't going to exist when the plugin starts. Heck, entities won't exist yet during OnMapStart and the other callbacks that fire when the map starts.

SDKHooks (comes with newer SourceMod 1.5 snapshots) and its OnEntityCreated callback save you a lot of trouble in this regard.

PHP Code:
public OnEntityCreated(entity, const String:classname[])
{
    if (
StrEqual(classname"func_tanktrain"))
    {
        
SDKHook(entitySDKHook_SpawnPostSpawnTrain);
    }
}

public 
SpawnTrain(entity)
{
    
DispatchKeyValue(entity"orientationtype""0");

A Spawn hook is used here instead of doing it on creation because, if you don't, the game will overwrite the properties you set. Spawn happens after the game writes its properties.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 08-07-2013 at 09:12.
Powerlord is offline