Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to check if a entity was created or no? #431428
10/16/13 04:08
10/16/13 04:08
Joined: Aug 2011
Posts: 42
F
fabiomartins Offline OP
Newbie
fabiomartins  Offline OP
Newbie
F

Joined: Aug 2011
Posts: 42
my question is very simple
how to make a instruction that check if a entity was created?

Re: how to check if a entity was created or no? [Re: fabiomartins] #431430
10/16/13 05:16
10/16/13 05:16
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
One way could be:

Code:
var special_ent_created = 0;
..
void _myaction(){
   special_ent_created = 1;
}
void _creator(){
   ent_create ("any.mdl", vector (0,0,0), _myaction);
}
..
if (special_ent_created) { Entity "special_ent_created" was created }



Another way ( for more than one special ent ) is using skills. Fex check all created ents with a FOR-loop for a special skill.

Cheers


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
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 Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Another version of rayp's would be
Code:
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 Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Or even shorter yet:

Code:
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:

Code:
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 Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
off-topic: we need a stack-exchange like q&a site.


3333333333

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1