2 registered members (Ayumi, 1 invisible),
584
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: how to check if a entity was created or no?
[Re: rayp]
#431448
10/16/13 09:35
10/16/13 09:35
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
Another version of rayp's would be
ENTITY* myEnt = null;
..
//somewhere in your code
myEnt = ent_create ("any.mdl", vector (0,0,0), <some action of your own>);
..
//another place in your code
if (myEnt != null) {
//your entity was created.
}
3333333333
|
|
|
Re: how to check if a entity was created or no?
[Re: Quad]
#431468
10/16/13 14:25
10/16/13 14:25
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Or even shorter yet:
if(ent_create("any.mdl", vector(0, 0, 0), foobar))
{
// Your code here. You can use the you pointer to access the created entity
}
if you need a pointer other than you but keep it a one line, here you go:
if((bar = ent_create("any.mdl", vector(0, 0, 0), foobar)))
{
// Your code here.
// Note: You don't need the extra pair of parenthesizes around the if(),
// but any sophisticated compiler will warn about the assignment otherwise
}
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: how to check if a entity was created or no?
[Re: WretchedSid]
#431505
10/17/13 11:26
10/17/13 11:26
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
off-topic: we need a stack-exchange like q&a site.
3333333333
|
|
|
|