PDA

View Full Version : [TUT] Entities: what they are and how to use them


Hawk552
08-16-2006, 20:13
Before we begin, please be aware that this tutorial is aimed toward scripters of intermediate level that understand Pawn conceptually but are still sketchy when it comes to implementation. Beginners may get confused, and experts may find they already know all this.

An entity is basically anything in the game that can change. The map is not an entity - it is impossible to change. You can do something like put a spraypaint on it, but that's not changing the map per se; rather it simply paints another texture on the location you sprayed.

Lights, players, the bomb, weapons (when on the ground, or even while being held in some mods) and breakable glass are all examples of entities. But what is important about ent(ities -- from now on they will be abbreviated to 'ents')? As said above, they can change. This means you can modify gameplay or make the game look different with them.

One of the most basic things that must be learned about entities is how to spawn one. Throughout this tutorial, I will post both an engine and fakemeta method of doing things, so here is one example:


// Engine
new Ent = create_entity("classname")



// Fakemeta
new Ent = engfunc(EngFunc_CreateNamedEntity,engfunc(Eng Func_AllocString,"classname"))


Now what do we see here that I haven't explained? What is this "classname"? A classname is given to all ents to help the engine determine what it is. If we stopped reading this tutorial and went outside, looking at various things, a person walking by might be classname "human" (however players in game are classname "player"), a tree might be classname "tree", a car might be "func_car" (func_ since it's a usable entity or it serves a purpose) and a cat might be "monster_cat" (monster_ because it's an NPC that may or may not be hostile). What can we do with the classname? We can use it to implement game functions (if you name an ent "hostage_entity" then Counter-Strike will automatically assume it's a hostage) or we can search for it (using find_ent_by_class or similar functions) among other things.

An entity also has other values. These values, such as health, target, targetname, gravity, movetype, etc. are all defined in part of HLSDK called the "edict_t" structure. An edict is effectively the basis for an entity because of this.

If you have any experience with AMXX scripting, you've probably ran into the function set_user_health. You may not understand what it does, but you know it works. What it basically does is go into the player's edict_t structure and change the "health" value (which is actually a float, not an int) to whatever you specify. Let's look at how it actually implements this though. Let's say for example we want to set a player's health to 200.

In fun, it looks like this:

set_user_health(id,200)


But in engine/fakemeta, it looks like this:

// engine
entity_set_float(id,EV_FL_health,200.0)
// fakemeta
set_pev(id,pev_health,200.0)


We obviously have more power this way. It looks much more confusing, but rather than simply making a "set_user_x" (where x is gravity, targetname, or what not) we have access to the entire edict_t structure (which links to the entvars structure, which is where all the information really is).

But what about this "entity_set_float"? There are 12 functions when it comes to engine and manipulating the entvars of an ent:

entity_get_int
entity_get_float
entity_get_string
entity_get_vector
entity_get_edict
entity_get_byte
entity_set_int
entity_set_float
entity_set_string
entity_set_vector
entity_set_edict
entity_set_byte

Additionally, we have some other functions that do similar things:

entity_set_origin
entity_set_model
entity_set_size

Note that these are not the same as simply using entity_set_vector/string, as they actually notify the engine (not the module) of the changes.

We have similar functions in fakemeta, however there are only 2 that do the same thing as these:

pev
set_pev

Because there is only 2, we have to be much more careful with fakemeta, since we could accidentally pass a float when the pev expects an int, or something to that effect.

There are also other functions which can be executed through engfunc and dllfunc (as shown near the top with the new Ent = engfunc... bit).

But now, how can these be implemented? We've already seen above how we can avoid fun and instead use engine/fakemeta, but what are some other things we can do with ents?

Well, let's say we want to teleport a player to a spot on the map. The first thing we must understand about where we want to teleport them, is that the location will be a vector. Why? Because a vector is a 3 cell array that contain data that generally acts as an x,y,z axis. We must also understand that all vectors implemented with engine/fakemeta are floats. Here is an example of a vector:


// static vector
Float:{0.0,1.0,2.0}
// dynamic vector
new Float:Vector[3]


Now, how is this relevant to setting a player's location? We must first look up how we set the entity's origin. After looking through the funcwiki (http://www.amxmodx.org/funcwiki.php?go=inc&id=8) we come across this:

entity_set_origin

So what do we do? First, we find out where we want to teleport the player. Let's say we want to teleport them to 50,-30,1000. We must first convert this to a vector:


new Float:Origin[3] = {50.0,-30.0,1000.0}


Then set their origin.


// engine
entity_set_origin(id,Origin)
// fakemeta
engfunc(EngFunc_SetOrigin,id,Origin)


When creating an entity, one of the most important things is to set its owner. Say, for example, a player types "car" in their console which creates a car in front of them, that can only be used by them. This can be done by setting their owner, and then checking when the ent is used if the owner is the person using it. Here is an example:


// engine
#include <amxmodx>
#include <amxmisc>
#include <engine>

new g_Classname[] = "func_car"
new g_Model[] = "models/car.mdl"

public plugin_init()
{
register_plugin("OMFG","HAX","LOL")

register_clcmd("say car","CmdSayCar")

register_touch(g_Classname,"player","TouchCar")
}

public plugin_precache()
precache_model(g_Model)

public CmdSayCar(id)
{
new Ent = create_entity("info_target")
entity_set_string(Ent,EV_SZ_classname,g_Class name)
entity_set_model(Ent,g_Model)
entity_set_int(Ent,EV_INT_solid,SOLID_TRIGGER )
entity_set_size(Ent,Float:{-50.0,-50.0,-50.0},Float:{50.0,50.0,50.0})
entity_set_edict(Ent,EV_ENT_owner,id)
}

public TouchCar(Ptd,Ptr)
{
new Owner = entity_get_edict(Ptd,EV_ENT_owner)
if(Owner != Ptr)
return

client_print(Ptr,print_chat,"You have used this car. Due to time purposes, I'm not going to add code beyond this.")
}


// fakemeta
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new g_Classname[] = "func_car"
new g_Model[] = "models/car.mdl"

public plugin_init()
{
register_plugin("OMFG","HAX","LOL")

register_clcmd("say car","CmdSayCar")

register_forward(FM_Touch,"ForwardTouch")
}

public plugin_precache()
precache_model(g_Model)

public CmdSayCar(id)
{
new Ent = engfunc(EngFunc_CreateNamedEntity,engfunc(Eng Func_AllocString,"info_target"))
set_pev(Ent,pev_classname,g_Classname)
engfunc(EngFunc_SetModel,Ent,g_Model)
set_pev(Ent,pev_solid,SOLID_TRIGGER)
engfunc(EngFunc_SetSize,Ent,Float:{-50.0,-50.0,-50.0},Float:{50.0,50.0,50.0})
set_pev(Ent,pev_owner,id)
}

public ForwardTouch(Ptd,Ptr)
{
new Classname[33],Ent = Ptd,id = Ptr
pev(Ptd,pev_classname,Classname,32)

if(!equal(Classname,g_Classname))
{
Ent = Ptr
id = Ptd

pev(Ptr,pev_classname,Classname,32)

if(!equal(Classname,g_Classname))
return
}

new Owner = pev(Ent,pev_owner)
if(Owner != id)
return

client_print(id,print_chat,"You have used this car. Due to time purposes, I'm not going to add code beyond this.")
}


With these examples, we went into a few things that we haven't before. First of all - solidity. When we boil water and steam floats up from it, if we put our hands through they do not get stopped after they touch the first water droplet. If go poke the nearest person, our finger will get stopped once it makes contact with them. This can be represented through solidity in the HL engine. There are 5 different solid types, which can be found here: http://www.amxmodx.org/funcwiki.php?go=module&id=3#const_solid

The one we used in this case was SOLID_TRIGGER, because we want the player to trigger a touch when they touch the car (even though it will still trigger on BBOX or BSP).

Another concept we have yet to go over is entity_set_size / engfunc(EngFunc_SetSize..., which allows you to set the size of an entity. This is important because without it, the ent's solidity will not matter. If the entity is 0 units on the x,y,z axis, then it is by definition SOLID_NOT, even if we set it to SOLID_BSP/_BBOX. No matter how big the model is, it's the size that really matters.

This is already way too long, so I'm going to end this here. If you have any questions about this or any way to improve upon it, feel free to post.

Additional information:

The list of current Engine (module) entvar types can be found here (and below it):
http://www.amxmodx.org/funcwiki.php?go=module&id=3#const_ent_int
and the list of current Fakemeta entvars can be found here:
http://www.amxmodx.org/funcwiki.php?go=module&id=16

Zenith77
08-16-2006, 21:07
You've become a tutorial beast Hawk! Although it didn't do anything for me, somebody new to HL scripting could well benefit from this :up:.

Hawk552
08-16-2006, 22:11
youve done it again, once again Hawk has impressed me , good tutoriol man !!!!! How would you go about setting , lets
say the bomb, as the oriigon? because its constantly moving you cant just set vectors right? http://forums.alliedmods.net:80/

Hi raphero,

you can set it the same way as any other entity. for something like the bomb though, you should run drop_to_floor on it, to make sure that whoever tries to defuse it can.

To find the bomb and move it to x,y,z:

new Ent = find_ent_by_model(-1,"grenade","models/w_c4.mdl")
// if not found -- probably not planted
if(!Ent)
return

entity_set_origin(Ent,Float:{0.0,0.0,0.0})

Hawk552
08-16-2006, 23:12
http://forums.alliedmods.net:80/ Well I dont want to move the bomb , I want to set the bomb as an origon to use
find_sphere_class
ans search the sphere from the bomb ,to find players . So would I still Use vectors to do this ?
EDIT
Thanks for making the tutoriol on entities . Good job!http://forums.alliedmods.net:80/

Well all you have to do is:


new Float:Origin[3],EntList[32]
entity_get_vector(Ent,EV_VEC_origin,Origin)

find_sphere_class(0,"player",50.0,EntList,32,Origin)


assuming Ent is the bomb. Or you can just do:


new EntList[32]

find_sphere_class(Ent,"player",50.0,EntList,32)


If you don't have the bomb's ent id, you can do:


new Ent = find_ent_by_model(-1,"grenade","models/w_c4.mdl")

k007
08-17-2006, 01:12
Your the man Hawk gj

Cheap_Suit
08-17-2006, 01:52
I've always wondered..

When creating an custom entity why must be the classname info_target? Or can be anything?

Hawk552
08-17-2006, 10:40
I've always wondered..

When creating an custom entity why must be the classname info_target? Or can be anything?

It can technically be anything, but honestly I don't know why most people use info_target. I'm reasonably sure it's better to set the ent's classname to what you want after it's spawned, so that's probably why.

Mark186
08-25-2006, 01:43
I have a question concerning creating models that appear at server/map start.
Is there something that can be registered in public plugin_init() that is not a command and is executed during map start?

Hawk552
08-25-2006, 11:24
I have a question concerning creating models that appear at server/map start.
Is there something that can be registered in public plugin_init() that is not a command and is executed during map start?

Umm...


public plugin_init()
{
new Ent = create_entity("info_target")
// do shit
}

Illusionist
08-28-2006, 05:12
Nice tutorial Hawk, I have a question though, using engine, how can I create 2 or more entities with the same command or function. For instance, how could I set clcmd "CmdSayCar" to spawn two cars instead of one? (this is not the best example but I'm hoping that you understand what I'm trying to ask)

Hawk552
08-28-2006, 10:05
Nice tutorial Hawk, I have a question though, using engine, how can I create 2 or more entities with the same command or function. For instance, how could I set clcmd "CmdSayCar" to spawn two cars instead of one? (this is not the best example but I'm hoping that you understand what I'm trying to ask)

Just make the code inside it a loop (for loop kinda like for(new Count;Count < 2;Count++) { do the spawning stuff })

Simon Logic
11-29-2006, 14:33
Great article! But it doesn't clearly cover the difference between using entity_set_vector(ent, EV_VEC_origin, val) and entity_set_origin(ent, origin). Does it mean that i have to use entity_set_origin() always? What's the difference in gameplay?

Orangutanz
11-29-2006, 14:43
I'm assuming entity_set_origin sets up all the properties of a static entity, so that its interactable for touching etc.

Maniplating manually will more than likely won't allow for this, unless you play around with pev_absmin & pev_absmax (Bounding box) calculation for this is pev_origin - pev_min (absmin) pev_origin + pev_max (absmax).

Simon Logic
11-30-2006, 05:18
Orangutanz, is it a correct conclusion that entity_set_origin() should be used for solid objects in general? I worked hardly with spawn points and i never called entity_set_origin(), just entity_set_vector(id, EV_VEC_origin, origin) or DispatchKeyValue(id, "origin", "x x x"). I did many tests and everything is Ok.

k007
11-30-2006, 10:37
i have a question about that too, could you use DispatchKeyValue on a index lower than 33(playa) or it doesn't matter it could be any index?

Simon Logic
11-30-2006, 11:24
i have a question about that too, could you use DispatchKeyValue on a index lower than 33(playa) or it doesn't matter it could be any index?
I used DispatchXXX only for my own created entities (with ID less than 33; the first assigned ID was 17) when i was spawning them. For existent entities with any ID i used entity_set_vector().

Orangutanz
11-30-2006, 13:00
I suppose entity_set_origin is more likely to be used on solid objects more than non-solid, but for like players you are able to move them using the other technique because they are thinking and constantly updating there bounding box, obviously some other entities will be fine as well.

DispatchKeyValue should be possible to use on any entity.

VMAN
02-12-2009, 23:07
How would I be able to manipulate an existing entity by getting its name?

Let's say I have func_button named "button". It currently is a dummy button with no target. But how would I be able to change the buttons target to "target?"

I assume it has to do with fm_get_string and fm_set_string right?

Hawk552
02-12-2009, 23:26
EngFunc_FindEntityByString, // edict) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue);

VMAN
02-13-2009, 00:25
I feel like such a noob for this.

But is this right?

new button = engfunc(EngFunc_FindEntityByString,engfunc(En gFunc_AllocString,"button"))
set_pev(button, pev_targetname, "target")

Hawk552
02-13-2009, 08:19
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
Try with field "classname" and value:"func_button"

Hawk552
02-13-2009, 12:19
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
new button = engfunc(EngFunc_FindEntityByString, edict) (edict_t *pEdictStartSearchAfter, const char *name, const char *mybutton);
set_pev(button, pev_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
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:


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
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
Getting an error compiling this


undefined symbol "EngFunc_FindEntByString"

Hawk552
02-13-2009, 21:10
EngFunc_FindEntityByString

VMAN
02-13-2009, 21:23
Thanks!

Mini_Midget
08-20-2010, 12:12
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!

hleV
08-22-2010, 11:09
I dislike monster_kats.

drekes
09-15-2010, 09:51
How do we retrieve the right size?
I don't know how to calculate the size so it would fit the model.

Alka
09-15-2010, 17:12
Size for the ent, so whole model will be touchable?

drekes
09-16-2010, 01:14
I'm making a plugin that makes admins able to place entities in a map, with models specified in a .cfg file, but for big models, the entity size doesn't match, so you can walk through a part of the model.

Here's an example: The left woman ent size is about right, but the right one is completely wrong.
http://forums.alliedmods.net/attachment.php?attachmentid=73459&stc=1&d=1284614740

Alka
09-16-2010, 02:28
You positioned the ent near to the ground? drop_to_floor()
As for model size , you can open the model with Jed's HLMV and do Option->Dump Model Info, as i can remember there was model or hitbox min/max size.

drekes
09-16-2010, 02:33
It can be positioned everywhere.
But is there no way to get the mins/max size in-game, without having to calculate everything yourself?

Exolent[jNr]
09-16-2010, 02:42
You positioned the ent near to the ground? drop_to_floor()
As for model size , you can open the model with Jed's HLMV and do Option->Dump Model Info, as i can remember there was model or hitbox min/max size.

I never knew about this, so I went and tried with 3 different models.
All had 0,0,0 for the values.

Eye Position: 0.000000 0.000000 0.000000
Min: 0.000000 0.000000 0.000000
Max: 0.000000 0.000000 0.000000
Bounding Box Min: 0.000000 0.000000 0.000000
Bounding Box Max: 0.000000 0.000000 0.000000
Flags: 0

drekes
09-16-2010, 05:01
;1300618']I never knew about this, so I went and tried with 3 different models.
All had 0,0,0 for the values.

Eye Position: 0.000000 0.000000 0.000000
Min: 0.000000 0.000000 0.000000
Max: 0.000000 0.000000 0.000000
Bounding Box Min: 0.000000 0.000000 0.000000
Bounding Box Max: 0.000000 0.000000 0.000000
Flags: 0
Same here.

Alka
09-16-2010, 10:34
Ah damn, i remember now, if it's a model with only one hitbox centred with model, then look at hitbox size, should work.

drekes
09-16-2010, 10:44
I think i understand it, Is there any way to get the size of that hitbox in game?

Ryokin
09-17-2010, 09:13
how can i make player can shoot an entity , and i set solid_bbox for ent but i still go through that ent ,why?

Hunter-Digital
09-17-2010, 11:39
Set it's movetype (see MOVETYPE_* in includes/hlsdk.inc) to allow it to have collisions.

ot_207
09-17-2010, 12:37
Set it's movetype (see MOVETYPE_* in includes/hlsdk.inc) to allow it to have collisions.

The shots are different from collisions. He needs to spawn the entity firstly as a func_breakable and after that add the health, properties, the SOLID_BBOX, the model and everything else!
I suggest seeing this plugin: http://forums.alliedmods.net/showthread.php?p=64516
Study the part where the entity is created! You will see everything there!

Hunter-Digital
09-17-2010, 17:06
Hmm, I seem to have skipped his first sentence when I wrote that, I answered to the second :}

Anyway, AFAIK, any type of entity can be killed if it has takedamage and health set.
The thing with func_breakable is that it automatically shoots out debris when killed, you need to set the type of debris projected... I don't really recall it's keyvalues.

ot_207
09-17-2010, 17:12
Hmm, I seem to have skipped his first sentence when I wrote that, I answered to the second :}

Anyway, AFAIK, any type of entity can be killed if it has takedamage and health set.
The thing with func_breakable is that it automatically shoots out debris when killed, you need to set the type of debris projected... I don't really recall it's keyvalues.

The key value name was "material". You can see in the plugin that I posted above.

Ryokin
09-17-2010, 23:32
i still dont know why the solid doesn't work , here's code
npc_Create( const Player, const Float:Origin)
{
new npc = create_entity( "info_target" );
if ( is_valid_ent( npc ) )
{
set_pev( npc, pev_classname, gNpcClassName );
set_pev( npc, pev_groupinfo, gNpcClassNameReference );
npc_Spawn( Player, npc, Origin );
engfunc(EngFunc_DropToFloor, npc);
return npc;
}
return 0;
}

npc_Spawn( const Player, const npc, const Float:Origin )
{
new Float:CurrentTime = get_gametime();
set_pev( npc, pev_movetype, MOVETYPE_BOUNCE );
set_pev( npc, pev_solid, SOLID_SLIDEBOX );
entity_set_model ( npc, npc_model );
entity_set_size ( npc, Float:{-16.0,-16.0,-36.0}, Float:{16.0, 16.0, 36.0} );
entity_set_origin( npc, Origin );
set_pev( npc, pev_nextthink, CurrentTime + 0.1 );
set_pev( npc, pev_RealOwner, Player ); // RealOwner
set_pev( npc, pev_flags, pev( npc, pev_flags ) | FL_MONSTER );
set_pev( npc, pev_health, get_pcvar_float( g_npchealth ) );
}

ot_207
09-18-2010, 02:14
You made 2 mistakes.


npc_Create( const Player, const Float:Origin)
{
new npc = create_entity( "func_breakable" );
if ( is_valid_ent( npc ) )
{
set_pev( npc, pev_classname, gNpcClassName );
set_pev( npc, pev_groupinfo, gNpcClassNameReference );
npc_Spawn( Player, npc, Origin );
engfunc(EngFunc_DropToFloor, npc);
return npc;
}
return 0;
}

npc_Spawn( const Player, const npc, const Float:Origin[3] )
{
new Float:CurrentTime = get_gametime();
set_pev( npc, pev_movetype, MOVETYPE_BOUNCE );
set_pev( npc, pev_solid, SOLID_SLIDEBOX );
entity_set_model ( npc, npc_model );
entity_set_size ( npc, Float:{-16.0,-16.0,-36.0}, Float:{16.0, 16.0, 36.0} );
entity_set_origin( npc, Origin );
set_pev( npc, pev_nextthink, CurrentTime + 0.1 );
set_pev( npc, pev_RealOwner, Player ); // RealOwner
set_pev( npc, pev_flags, pev( npc, pev_flags ) | FL_MONSTER );
set_pev( npc, pev_health, get_pcvar_float( g_npchealth ) );
}

1. origin is not a simple float, a vector Float:origin[3]
2. You must create the original entity as func_breakable or it will never work. That is why I told you to look at the plugin, but these days no one has patience anymore.

Ryokin
09-18-2010, 06:54
tried func_breakable too , but still not work

ot_207
09-18-2010, 12:07
tried func_breakable too , but still not work

2. You must create the original entity as func_breakable or it will never work. That is why I told you to look at the plugin, but these days no one has patience anymore.

jnnq.
09-18-2010, 20:40
Very nice tutorial men!

kotinha
04-03-2011, 21:46
I read the tutorial and it is very nice ! thanks man!


But i have a question, if i want an entity to have more than 5 custom properties how do i do that ??

Erox902
07-16-2011, 20:35
Quick question since I just wanna test this, about your example on spawning a car.
I did exactly like the example and it spawns an entity. But I can't see it. :?
So I guess my question is how to make it spawn at a specific place like "get_user_aiming" for instance?

liinuus
07-18-2011, 07:45
u get the origin of where they aim and then u set the origin of the entity there

Erox902
07-18-2011, 17:17
Just realized... How do I get the origin of where they aim? :?

Exolent[jNr]
07-18-2011, 17:18
get_user_origin() (http://www.amxmodx.org/funcwiki.php?search=get_user_origin&go=search)

Erox902
07-18-2011, 17:49
Well wont that just give me the origin of the player?
I mean how do I get the origin of where they aim like
new Float:Origin[3] = get_user_aiming(id)
entity_set_origin(Ent, ??? )
Tried this but first row gave me error about arguments.
Guess this is a little oftopic but anyways please help.
Will propably be helpful to some others too:)

Exolent[jNr]
07-18-2011, 17:50
I said get_user_origin(), not get_user_aiming().
You can set a specific mode to get the aim origin, if you would just read the page I sent you.

EDIT:

You will have to pass a non-Float array to get_user_origin(), then use IVecFVec (http://www.amxmodx.org/funcwiki.php?search=IVecFVec&go=search) to make it a float.

Erox902
07-22-2011, 12:17
Thank you Exolent, really helpful :)

Erox902
07-22-2011, 12:48
Now I have another question cuz' i've tried all solid constants for the ent
But none of them acually block me from going staight through it :?
Anyone who has a hint on what's causing this?

Or should I post the code?

Emp`
07-22-2011, 13:23
Now I have another question cuz' i've tried all solid constants for the ent
But none of them acually block me from going staight through it :?
Anyone who has a hint on what's causing this?

Or should I post the code?

Set size after you set solid type.

Erox902
07-23-2011, 10:45
Set size after you set solid type.

That's what I did :? I clicked "show hitbox", and then "dump model info"
And then setted solidity and then the hitbox sizes, but it's still not solid :?

Exolent[jNr]
07-23-2011, 16:04
That's what I did :? I clicked "show hitbox", and then "dump model info"
And then setted solidity and then the hitbox sizes, but it's still not solid :?

No, he means in code.

entity_set_int(entity, EV_INT_solid, /*SOLID_* constant*/)
entity_set_size(entity, /*mins*/, /*maxs*/)

Erox902
07-23-2011, 18:53
;1516945']No, he means in code.


Code:
entity_set_int(entity, EV_INT_solid, /*SOLID_* constant*/)</p><p>entity_set_size(entity, /*mins*/, /*maxs*/)


Yeah that's exactly what I did, and I've tried all solid constants:shock:
I'll post the code tommorow when I get home

Erox902
07-24-2011, 08:15
public spawn_entity(id)
{
new Origin[3]
get_user_origin( id, Origin, 3 )

new Float:SpawnOrigin[3]
IVecFVec( Origin, Float:SpawnOrigin )

new Ent = create_entity( "info_target" )
entity_set_string( Ent,EV_SZ_classname,g_Classname )
entity_set_model( Ent,g_Model )
entity_set_int( Ent,EV_INT_solid,SOLID_BBOX )
entity_set_size( Ent,Float:{-43.7,-118.1,0.0},Float:{43.1,117.5,98.7} )
entity_set_edict( Ent,EV_ENT_owner,id )
entity_set_origin( Ent, SpawnOrigin )
}

Hunter-Digital
07-25-2011, 09:56
You'll need to specify a movetype aswell I belive.
If you want gravity, MOVETYPE_TOSS would do, if not, MOVETYPE_FLY would do.

Erox902
07-25-2011, 18:47
You'll need to specify a movetype aswell I belive.
If you want gravity, MOVETYPE_TOSS would do, if not, MOVETYPE_FLY would do.

Tried that now, didn't make it solid either :(

liinuus
07-26-2011, 13:11
Tried that now, didn't make it solid either :(
do you have the right size set? if uve set a to small size not all of the model will be solid

Erox902
07-26-2011, 16:11
do you have the right size set? if uve set a to small size not all of the model will be solid

No I checked the dump info atleast 4 times :?
And absolutly nothing of the entity is solid:cry::cry:

kiki33hun
08-31-2013, 07:18
Can^t create func_vehicle?

ConnorMcLeod
08-31-2013, 10:01
You can create any class that is a default mod class.
For some entities, you may not be able to use them as you whish though.

SpliN
03-26-2021, 17:43
Nice Tutorial I Appreciate That
Thanks a Lot