Raised This Month: $535 Target: $400
 133% 

Map light origin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
safetymoose
Senior Member
Join Date: Feb 2015
Old 07-12-2020 , 06:46   Map light origin
Reply With Quote #1

How can i retrieve the origin of a map's "light" entity?

"m_vecOrigin" doesn't work here.
safetymoose is offline
Rohanlogs
Senior Member
Join Date: Nov 2015
Old 07-12-2020 , 10:19   Re: Map light origin
Reply With Quote #2

Hi, you sure it doesn't work? Can you show the code?
__________________
Rohanlogs is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 07-12-2020 , 11:18   Re: Map light origin
Reply With Quote #3

Code:
PHP Code:
public OnEntityCreated(entity, const char[] classname)
{
    if (
StrContains(classname"light"false) != -1)
    {
        
//SDKHook(entity, SDKHook_SpawnPost, OnLightSpawnPost) // Spawn doesnt work for lights, they get removed...
        
        
float origin[3]
        
GetEntPropVector(entityProp_Send"m_vecOrigin"origin)
        
        
LogMessage("DEBUG: Entity created: %s | Origin: %.2f, %.2f, %.2f"classnameorigin[0], origin[1], origin[2])
    }

Output:
PHP Code:
L 07/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight_spot Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight_spot Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight_spot Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight_spot Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight_environment Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight Origin0.000.000.00
L 07
/12/2020 04:38:09: [lighttest.smxDEBUGEntity createdlight Origin0.000.000.00 
safetymoose is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 07-12-2020 , 16:43   Re: Map light origin
Reply With Quote #4

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?
safetymoose is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 07-12-2020 , 23:13   Re: Map light origin
Reply With Quote #5

Quote:
Originally Posted by safetymoose View Post
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
__________________
cry

Last edited by BHaType; 07-13-2020 at 03:40.
BHaType is offline
Send a message via AIM to BHaType
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-15-2020 , 02:10   Re: Map light origin
Reply With Quote #6

Don't need a timer, use SDKHook_SpawnPost and if it's still not valid then RequestFrame from here.
__________________
Silvers is offline
Reply


Thread Tools
Display Modes

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 18:58.


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