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

[TF2] Entity is not a CBaseEntity


Post New Thread Reply   
 
Thread Tools Display Modes
Koolman
Junior Member
Join Date: Mar 2014
Location: United Kingdom
Old 03-05-2014 , 12:14   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #11

Another problem.
I've declared the array petRef with MAXPLAYERS+1 to store the indexes for each player.
PHP Code:
petRef[client] = EntIndexToEntRef(pet[client]); 
PHP Code:
AcceptEntityInput(petRef[client], "Kill"); 
I've associated AcceptEntityInput with petRef[client], however when KillPet starts AcceptEntityInput, it produces a similar error to the original.

PHP Code:
L 03/05/2014 16:56:34: [SMNative "AcceptEntityInput" reportedEntity -(-2051944066is not a CBaseEntity
L 03
/05/2014 16:56:34: [SMDisplaying call stack trace for plugin "DFSPets3.smx":
L 03/05/2014 16:56:34: [SM]   [0]  Line 399src\dfs\STOREHOUSE\STAGE3\DFSPets3.sp::KillPet()
L 03/05/2014 16:56:34: [SM]   [1]  Line 152src\dfs\STOREHOUSE\STAGE3\DFSPets3.sp::Event_Spawn() 
Koolman is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 03-05-2014 , 13:23   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #12

You have to call EntRefToEntIndex on the reference first.
bl4nk is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-05-2014 , 13:34   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #13

? No, AcceptEntityInput does accept entrefs as its first argument. I've used it to Kill entities without problems for quite a while now.

https://wiki.alliedmods.net/Entity_R...es_(SourceMod)

Quote:
All natives (provided by SourceMod) should be able to accept references in place of indexes (wherever the parameter asks for an entity - Not clients), and these will use the serial to check that the entity index contained in the reference is the same as when the reference was created.
https://forums.alliedmods.net/showthread.php?t=236319
__________________

Last edited by ddhoward; 03-05-2014 at 13:44.
ddhoward is offline
Koolman
Junior Member
Join Date: Mar 2014
Location: United Kingdom
Old 03-05-2014 , 13:45   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #14

PHP Code:
new index EntRefToEntIndex(petRef[client]);
    
AcceptEntityInput(index"Kill"); 
PHP Code:
L 03/05/2014 18:34:06: [SMNative "AcceptEntityInput" reportedEntity -(-1is not a CBaseEntity
L 03
/05/2014 18:34:06: [SMDisplaying call stack trace for plugin "DFSPets3.smx":
L 03/05/2014 18:34:06: [SM]   [0]  Line 404src\dfs\STOREHOUSE\STAGE3\DFSPets3.sp::KillPet()
L 03/05/2014 18:34:06: [SM]   [1]  Line 152src\dfs\STOREHOUSE\STAGE3\DFSPets3.sp::Event_Spawn() 
Converting the reference to an index anyhow causes the same error.
Koolman is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 03-05-2014 , 13:48   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #15

If it returns -1 entity which you searched for might've already been destroyed so it results in -1
add this so it won't target destroyed entities into code:
PHP Code:
if(index 0)
{


__________________
...
Oshizu is offline
Koolman
Junior Member
Join Date: Mar 2014
Location: United Kingdom
Old 03-05-2014 , 13:53   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #16

Quote:
Originally Posted by Oshizu View Post
If it returns -1 entity which you searched for might've already been destroyed so it results in -1
add this so it won't target destroyed entities into code:
PHP Code:
if(index 0)
{


This fixed it. Many thanks.
Koolman is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-05-2014 , 13:53   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #17

Quote:
Originally Posted by Oshizu View Post
If it returns -1 entity which you searched for might've already been destroyed so it results in -1
add this so it won't target destroyed entities into code:
PHP Code:
if(index 0)
{


Exactly. Although it isn't documented, it seems to return -1 when the entity no longer exists.

Anyway, the entity might be being killed when its parent is killed.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 03-05-2014 at 13:54.
Powerlord is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-05-2014 , 13:59   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #18

It returns INVALID_ENT_REFERENCE, and it is documented in the wiki.

https://wiki.alliedmods.net/Entity_R...es_(SourceMod)
__________________

Last edited by ddhoward; 03-05-2014 at 13:59.
ddhoward is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-05-2014 , 14:06   Re: [TF2] Entity is not a CBaseEntity
Reply With Quote #19

Quote:
Originally Posted by ddhoward View Post
It returns INVALID_ENT_REFERENCE, and it is documented in the wiki.

https://wiki.alliedmods.net/Entity_R...es_(SourceMod)
Still, it should be documented in the function documentation.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 22:43.


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