AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [TUT] Entities: what they are and how to use them (https://forums.alliedmods.net/showthread.php?t=43321)

Hawk552 02-13-2009 08:19

Re: [TUT] Entities: what they are and how to use them
 
No, read the parameters:
  • edict_t *pEdictStartSearchAfter
  • const char *pszField
  • const char *pszValue

I don't know what exactly you meant by "name" but if you didn't mean something else, you'd put "name" in pszField.

ConnorMcLeod 02-13-2009 11:14

Re: [TUT] Entities: what they are and how to use them
 
Try with field "classname" and value:"func_button"

Hawk552 02-13-2009 12:19

Re: [TUT] Entities: what they are and how to use them
 
Quote:

Originally Posted by ConnorMcLeod (Post 760918)
Try with field "classname" and value:"func_button"

Well, the problem with that is that he would have to get the ent's name and check if it's "button" each time he finds a func_button.

VMAN 02-13-2009 15:55

Re: [TUT] Entities: what they are and how to use them
 
PHP Code:

new button engfunc(EngFunc_FindEntityByStringedict) (edict_t *pEdictStartSearchAfter, const char *name, const char *mybutton);
set_pev(buttonpev_targetname"mytarget"); 

Doesn't seem to compile. I must be doing something really wrong.

Sorry If I am wasting your time

Hawk552 02-13-2009 16:24

Re: [TUT] Entities: what they are and how to use them
 
The parameters I gave you were for the VM. Here's how you read them:
  • EngFunc_FindEntityByString, // edict) - An edict is an entity structure. This means that the function returns an edict, or an entity ID.
  • edict_t *pEdictStartSearchAfter - Pointer to an edict. The pointer part is irrelevant for your purposes, but it's asking for an entity ID to start from.
  • const char *pszField - Pointer to a string denoted "Field". This is the member on the entity that you want to search.
  • const char *pszValue - Pointer to a string denoted "Value". This is the value you're looking for under "Field".
Again, I'm not sure what you mean by "name" because there are many variables that have to do with "name" (coincidentally not the string "name" itself), but if that made sense, it would look like this:

PHP Code:

new Ent engfunc(EngFunc_FindEntByString,-1,"name","button")
set_pev(Ent,pev_targetname,"mytarget"

Also, I think you want pev_target, since targetname is what you use to target that button with. For example, if I wanted to have another button which uses this button when that one is used, I would set this button's targetname to that button's target.

However, if I wanted to open a door when this button is used, I would set this button's target to the door's targetname.

I'm not sure about what you're trying to do, but I can't see an reason for needing a targetname on a button.

VMAN 02-13-2009 19:32

Re: [TUT] Entities: what they are and how to use them
 
Ah, pev_target is what I need :mrgreen:.

Haven't done mapping for weeks :oops:.


Thank you so much for your time and patience.

:up: +Karma

VMAN 02-13-2009 21:01

Re: [TUT] Entities: what they are and how to use them
 
Getting an error compiling this


undefined symbol "EngFunc_FindEntByString"

Hawk552 02-13-2009 21:10

Re: [TUT] Entities: what they are and how to use them
 
EngFunc_FindEntityByString

VMAN 02-13-2009 21:23

Re: [TUT] Entities: what they are and how to use them
 
Thanks!

Mini_Midget 08-20-2010 12:12

Re: [TUT] Entities: what they are and how to use them
 
Is there a specific order when setting values to custom ents?

For eg...
Create ent
Set classname
Set origin, size, movetype, solid, velocity
Set health, angles
Etc...

I remembered one time, one of my ent was not being made as I was playing around with the order of values being set for my ent.
Any advice on this would be great!


All times are GMT -4. The time now is 03:59.

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