Entity that executes a function when touched.
Moderator: InsideQC Admins
9 posts
• Page 1 of 1
Entity that executes a function when touched.
How would i go about creating an entity, sort of like a weapon spawn, except the player doesn't pick up the item, that can be placed on a map, and when the player touches the entity, if an impulse is entered, then a function is executed.
Thanks.
Thanks.
Last edited by DusterdooSmock on Tue Nov 16, 2010 5:58 am, edited 1 time in total.
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
Re: Entity that executes a function when touched.
like a pickup system..?
i used a traceline with a constant of PLAYER_PICKUP_DISTANCE.
then you can just make a pickup impulse check the trace_ent if its a pickup(i created a field item_type)
if it is.. you run a function or something.
that way you have to be looking at the entity for it to work.
probably slower with a traceline though
i used a traceline with a constant of PLAYER_PICKUP_DISTANCE.
then you can just make a pickup impulse check the trace_ent if its a pickup(i created a field item_type)
if it is.. you run a function or something.
that way you have to be looking at the entity for it to work.
probably slower with a traceline though
- something
- Posts: 27
- Joined: Tue Apr 20, 2010 2:02 pm
- Location: Melbourne,Au
- Code: Select all
float FOOBAR_IMPULSE = 99;
void () foobar_touch =
{
if (other.impulse == FOOBAR_IMPULSE)
{
// does something
other.impulse = 0;
}
};
void () foobar_trigger =
{
(...)
self.touch = foobar_touch;
(...)
};
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Thanks, but how would i get it to remove the spawned model when the impulse is entered?
Is it just remove(self); ?
Is it just remove(self); ?
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
remove (self) will wipe out the entity for good. If what you want is something like deathmatch/coop item respawn you should take a careful look in items.qc.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Arkage wrote:setmodel(self, "");
Why did that have to be so easy?
Thanks to all of you.
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
