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

GetEntProp Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SuperRaWR
SourceMod Donor
Join Date: Jan 2010
Location: Sylvan Lake, Alberta, Ca
Old 03-27-2011 , 13:25   GetEntProp Error
Reply With Quote #1

Hello everyone, I'm somewhat new to Pawn, and I'm getting an error while working entities when I use GetEntProp.

The error looks like this in the console / SM logs:

Code:
[SM] Native "GetEntProp" reported: Entity -1 (-1) is invalid
I'm hooking SDKHook_Spawn for tf_projectile_rocket.

I'm then using GetEntProp, to get the owner of the rocket:

Code:
//Condition is true if the rocket's owner's rocket launcher is level 101 (normally impossible to get unless using asherkins TF2 items extention)
if( IsClientInGame(iOwner) && IsPlayerAlive(iOwner) &&  GetEntProp(GetEntPropEnt(iOwner, Prop_Send, "m_hActiveWeapon"),  Prop_Send, "m_iEntityLevel") == 101)
And that's where I'm getting that error. Anyone have any pointers? Is there a condition that i should be checking for before calling GetEntProp?

Also, I just want to clarify, the above DOES work, however my console gets spammed with that error sometimes (it's either spamming like crazy, or not at all).
__________________
[WDZ]SuperRaWR

I use event scripts.

Last edited by SuperRaWR; 03-27-2011 at 13:28.
SuperRaWR is offline
Send a message via Skype™ to SuperRaWR
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-27-2011 , 13:44   Re: GetEntProp Error
Reply With Quote #2

PHP Code:
if( IsClientInGame(iOwner) && IsPlayerAlive(iOwner) )
{
    new 
Weapon GetEntProp(iOwnerProp_Send"m_hActiveWeapon");
    if( 
Weapon != -&&  GetEntProp(Weapon,  Prop_Send"m_iEntityLevel") == 101 )
    {
        
// Do stuff
    
}

You have to check "weapon" does not equal -1 is what the error is telling you.

GetEntPropEnt is for getting an entity index from a client (something like that, someone can hopefully elaborate) so use GetEntProp instead... as above.
__________________
Silvers is offline
SuperRaWR
SourceMod Donor
Join Date: Jan 2010
Location: Sylvan Lake, Alberta, Ca
Old 03-27-2011 , 14:22   Re: GetEntProp Error
Reply With Quote #3

Quote:
Originally Posted by Silvers View Post
You have to check "weapon" does not equal -1 is what the error is telling you.

GetEntPropEnt is for getting an entity index from a client (something like that, someone can hopefully elaborate) so use GetEntProp instead... as above.

OhhH!! Okay, I'm assuming it would = -1 if they fired a rocket, then died before the hook on the rocket entity is killed or something like that. I didn't understand where the -1 was coming from though. Thanks Silvers, I'll use GetEntProp instead!
__________________
[WDZ]SuperRaWR

I use event scripts.
SuperRaWR is offline
Send a message via Skype™ to SuperRaWR
psychonic

BAFFLED
Join Date: May 2008
Old 03-27-2011 , 16:18   Re: GetEntProp Error
Reply With Quote #4

GetEntPropEnt is to get the index of an entity handle (the 'h' properties). You above code was correct other than that you needed to check to see if there was a valid weapon. -1 is invalid entity, commonly used as "none" like in m_hActiveWeapon or m_hOwnerEntity.
psychonic 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 04:38.


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