Raised This Month: $ Target: $400
 0% 

Retrieving an entity id before it's created


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DavidLin
Member
Join Date: Jan 2016
Old 01-13-2016 , 11:15   Retrieving an entity id before it's created
Reply With Quote #1

How can I detect what id the entity will have before it's created ?
DavidLin is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-13-2016 , 11:38   Re: Retrieving an entity id before it's created
Reply With Quote #2

It may be predictable with code that simulates what ED_Alloc() engine function does here: https://github.com/dreamstalker/rehl..._edict.cpp#L48
I don't think it's possible to do it from an AMXX plugin though. As far as I know, AMXX doesn't offer any natives that deal with edicts directly, so it probably has to be written within a module.

Why do you even want to predict the id? I don't see how is that useful.
klippy is offline
DavidLin
Member
Join Date: Jan 2016
Old 01-13-2016 , 12:10   Re: Retrieving an entity id before it's created
Reply With Quote #3

Well I get entity origins from a .cfg file and store them in a dynamic array. There is a menu from which I can delete the entity, add them and etc. So when I delete the entity I want to delete the dynamic array item too, but how can I retrieve the array item id when deleting the entity ?
DavidLin is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-13-2016 , 12:15   Re: Retrieving an entity id before it's created
Reply With Quote #4

You could save array index in entity's pev_iuser[1-4] fields. Easily retrieved with pev().
PHP Code:
set_pev(entpev_iuser1index); 
klippy is offline
DavidLin
Member
Join Date: Jan 2016
Old 01-13-2016 , 13:27   Re: Retrieving an entity id before it's created
Reply With Quote #5

Thanks also why does this part give me a tag missmatch?
PHP Code:

enum _
:mearray {
        
id,
        
line_id,
        
Float:Origins],
        
Float:Angles]
}
DataOrigins ][ ] = 2.0; <-- This one 

Last edited by DavidLin; 01-13-2016 at 13:28.
DavidLin is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-13-2016 , 14:36   Re: Retrieving an entity id before it's created
Reply With Quote #6

You are probably declaring that array as:
PHP Code:
new Data[mearray]; 
The compiler doesn't actually look at the tag of "Origins" constant, but at the tag of "Data" variable. That's a compiler bug that (as Arkshine stated in one of the commits) was introduced in version 1.60 of AMXX, as is now fixed in newest 1.8.3 dev releases.

One way to get around that is to de-tag the value you assign to your variable:
PHP Code:
Data[Origins][0] = _:2.0
The other way would be to declare your variable ("structure") as:
PHP Code:
new anyData[mearray]; 
That's kind of bad because it allows you to assign a value of any tag to your variable, but it at least shuts the compiler warnings.
klippy is offline
DavidLin
Member
Join Date: Jan 2016
Old 01-14-2016 , 07:12   Re: Retrieving an entity id before it's created
Reply With Quote #7

Thanks
DavidLin 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 09:26.


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