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

Question creating an entity "classname"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-13-2017 , 08:12   Question creating an entity "classname"
Reply With Quote #1

PHP Code:
   new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target")) 
   
entity_set_string(entEV_SZ_classname"my_classname"
Why not just
PHP Code:
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"my_classname")) 
?
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-13-2017 , 08:36   Re: Question creating an entity "classname"
Reply With Quote #2

Quote:
Originally Posted by abdobiskra View Post
PHP Code:
   new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target")) 
   
entity_set_string(entEV_SZ_classname"my_classname"
Why not just
PHP Code:
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"my_classname")) 
?
Try it.
__________________
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-13-2017 , 09:30   Re: Question creating an entity "classname"
Reply With Quote #3

I would guess that the CreateNamedEntity function validates the entity's classname before creating it. And since "my_classname" is not a valid classname, it won't create it.
__________________
fysiks is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-13-2017 , 09:40   Re: Question creating an entity "classname"
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
I would guess that the CreateNamedEntity function validates the entity's classname before creating it. And since "my_classname" is not a valid classname, it won't create it.
Yes Logical.
So what can be understood is that there is no problem if i use it this way If the classname is on that map ?
example :
PHP Code:
new ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_player_start")) 
__________________

Last edited by abdobiskra; 12-13-2017 at 09:41.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-13-2017 , 11:26   Re: Question creating an entity "classname"
Reply With Quote #5

Not as I thought!
I did not get debug output.
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-13-2017 , 20:58   Re: Question creating an entity "classname"
Reply With Quote #6

I'm guessing it's different because different types of entities have different attributes so you should stick with what you've seen work before.
__________________
fysiks is offline
Solokiller
Senior Member
Join Date: Sep 2015
Old 12-14-2017 , 17:35   Re: Question creating an entity "classname"
Reply With Quote #7

CreateNamedEntity creates an instance of a particular entity, then you change its classname to another one to make everything think it's something different.

If you try to create say "my_classname" it'll fail because there is no entity class with that name. If you try to rename an existing entity to a class that also exists, the game could crash if it tries to interpret it as such.

Think of it like this: if you create a car and then call it a bicycle, trying to access the third and fourth wheel would cause a crash, because there are no such wheels. Trying to create a starship fails because no starships exist, but renaming a car to a starship works just fine because nothing will try to access it as a starship.
Solokiller is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-14-2017 , 23:06   Re: Question creating an entity "classname"
Reply With Quote #8

Short, use this only for known game entities, after set a custom classname, simple.
CrazY. 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 11:37.


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