|
Great Tester of Whatever
|
07-12-2020
, 22:13
Re: Map light origin
|
#5
|
Quote:
Originally Posted by safetymoose
What i'd like to know is, is there a way to directly retrieve the origin from the light entity itself?
If not, i think i should be looking into the entity lump from OnLevelInit. It has the necessary data, but i have no idea how to properly parse this. I just need the proper "origin" fields for each "light" or similar entity.
Any suggestions?
|
As i know OnEntityCreated calls too early and you need to wait before you can get entity origin
UPD:
Works perfect
Code:
[test.smx] DEBUG: Entity created: beam_spotlight | Origin: 82.96, 29.19, 28.33
[test.smx] DEBUG: Entity created: light_dynamic | Origin: -16.55, -0.60, 55.96
[test.smx] DEBUG: Entity created: light | Origin: 1132.53, 5624.00, 2521.00
Spoiler
PHP Code:
#pragma semicolon 1 #pragma newdecls required
#include <sourcemod> #include <sdktools>
public void OnEntityCreated(int entity, const char[] classname) { if (StrContains(classname, "light", false) != -1) { CreateTimer(0.1, tTimer, EntIndexToEntRef(entity)); } }
public Action tTimer (Handle timer, int iReference) { if (!IsValidEdict(iReference)) return;
float vOrigin[3]; GetEntPropVector(iReference, Prop_Send, "m_vecOrigin", vOrigin); char szName[36]; GetEdictClassname(iReference, szName, sizeof szName); LogMessage("DEBUG: Entity created: %s | Origin: %.2f, %.2f, %.2f", szName, vOrigin[0], vOrigin[1], vOrigin[2]); }
__________________
Last edited by BHaType; 07-13-2020 at 02:40.
|
|
|
|