UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: jjbradman on April 18, 2014, 04:54:47 am

Title: "is touching" help
Post by: jjbradman on April 18, 2014, 04:54:47 am
i am trying to use istouching to wait until an ent is being touched by the player can someone say me a better way of doing this as my while and for loops keep acting as if the player would be touching the ent while it's not D:
Title: Re: "is touching" help
Post by: MakeCents on April 18, 2014, 05:09:07 am
i am trying to use istouching to wait until an ent is being touched by the player can someone say me a better way of doing this as my while and for loops keep acting as if the player would be touching the ent while it's not D:

I use something like this:
Code Snippet
Plaintext
ent = getent("name","targetname");
ent thread touchme();
touchme(){
while(1){
players = get_players();
for(i=0;i<players.size;i++)
{
if(players[i] istouching(self)){
//do something if player is touching ent
}

}
wait(.5);
}
}
Title: Re: "is touching" help
Post by: jjbradman on April 18, 2014, 05:26:33 am
I use something like this:
Code Snippet
Plaintext
ent = getent("name","targetname");
ent thread touchme();
touchme(){
        players = get_players();
while(1){

for(i=0;i<players.size;i++)
{
if(players[i] istouching(self)){
//do something if player is touching ent
}

}
wait(.5);
}
}
thanks gonna try it :) this proves that im a noob using while(1) loops xD
Title: Re: "is touching" help
Post by: MakeCents on April 18, 2014, 05:57:24 am
thanks gonna try it :) this proves that im a noob using while(1) loops xD

NP.

I had to put the get players back inside the while loop for it to work for me though. I edited it above.
Title: Re: "is touching" help
Post by: YaPh1l on April 18, 2014, 08:26:58 am
Place a trigger_multiple around the entity and waittill("trigger")... Done.

- Phil.
Title: Re: "is touching" help
Post by: MakeCents on April 18, 2014, 03:21:50 pm
Place a trigger_multiple around the entity and waittill("trigger")... Done.

- Phil.

Side note, kind of....
I am assuming he wants this for the car ride (http://ugx-mods.com/forum/index.php?topic=1817.0) script, where the vehicle is moving. I have a moving thing in my map as well. I have been working through things I didn't like about it, just before this post. I attempted linking the trigger or moving the trigger, but failed. I just figured you were not able to and I addressed it other ways and finally settled with a script similar to the previous one I mentioned. I would prefer to link the trigger to it. Do you know if trigger move or trigger linkto is possible?
Title: Re: \"is touching\" help
Post by: jjbradman on April 18, 2014, 04:00:37 pm
no i dont want it for the car ride and i cant use a trigger cause the thing that player is supposed to touch spawns when a zombie dies. so i cant spawn a trigger or put one in the specific place where it died

Post Merge: April 18, 2014, 04:01:47 pm
and makecents, i dont think that trigger link to is posible cause yesterday i tried to use movez with a trigger and everything moved fine except for the trigger :/
Title: Re: "is touching" help
Post by: YaPh1l on April 18, 2014, 05:01:35 pm
It is possbile, you have to EnableLinkTo(). Also, you can spawn a trigger_radius via script. But if it is something powerup-like (where there might be more), it would indeed be better to use IsTouching() or even just a proximity check (DistanceSquared()) like the powerups do.

- Phil.
Title: Re: "is touching" help
Post by: MakeCents on April 18, 2014, 06:16:42 pm
It is possbile, you have to EnableLinkTo(). Also, you can spawn a trigger_radius via script. But if it is something powerup-like (where there might be more), it would indeed be better to use IsTouching() or even just a proximity check (DistanceSquared()) like the powerups do.

- Phil.

Wow, you're AWESOME.  :rainbow: :gusta: Can't believe that was the answer. Thanks so much. Now I can get rid of those nested loops and just thread a loop once.
Title: Re: "is touching" help
Post by: jjbradman on April 18, 2014, 06:20:54 pm
It is possbile, you have to EnableLinkTo(). Also, you can spawn a trigger_radius via script. But if it is something powerup-like (where there might be more), it would indeed be better to use IsTouching() or even just a proximity check (DistanceSquared()) like the powerups do.

- Phil.
actually the trigger radious idea i think is better o.O that way the script could wait till the trigger has been touched? o.O
Title: Re: "is touching" help
Post by: YaPh1l on April 18, 2014, 08:39:53 pm
It depends on how many you have. A trigger_radius is an entity just like anything else that is scriptable. It will count towards the entity limit.

- Phil.
Title: Re: "is touching" help
Post by: jjbradman on April 18, 2014, 09:01:13 pm
but the trigger radious would be deleted within 15 seconds of being spawned anywas and only 1 zombie in every 10 zombies would need the radious to be spawned
Title: Re: "is touching" help
Post by: YaPh1l on April 18, 2014, 10:51:00 pm
I'm not stopping you from anything, I'm just stating facts.

- Phil.
Title: Re: "is touching" help
Post by: jjbradman on April 18, 2014, 10:53:51 pm
oh, lol then how would i spawn a trigger radious?
also what is the entity limit? and what goes to that count?
Title: Re: "is touching" help
Post by: YaPh1l on April 18, 2014, 10:58:05 pm
oh, lol then how would i spawn a trigger radious?
Code Snippet
Plaintext
// flags = same as spawnflags when putting one down in Radiant
ent = Spawn("trigger_radius", origin, flags, radius, height);

also what is the entity limit?
I think it's 1024.

and what goes to that count?
As I said, all entities, basically any game object that can be accessed by script in any way, except script_structs.

- Phil.
Title: Re: "is touching" help
Post by: jjbradman on April 18, 2014, 11:04:06 pm
thanks man :D and  btw using the spawn funt can i spawn another type of trigger like a trigger multiple? o.o
ok thanks man i think im staying way below that limit cause i delete all ents after being used :)

and just one final question: do trigger radius work like trigger_multiples so they are activated when touched or player has to press f?
Title: Re: "is touching" help
Post by: YaPh1l on April 18, 2014, 11:06:47 pm
using the spawn funt can i spawn another type of trigger like a trigger multiple? o.o
Nein.

- Phil.
Title: Re: "is touching" help
Post by: jjbradman on April 18, 2014, 11:09:14 pm
damn it :L and about my last question?
Quote
and just one final question: do trigger radius work like trigger_multiples so they are activated when touched or player has to press f?
Title: Re: "is touching" help
Post by: YaPh1l on April 18, 2014, 11:11:29 pm
They act just like trigger_multiples...

- Phil.
Title: Re: "is touching" help
Post by: jjbradman on April 18, 2014, 11:16:07 pm
thanks :D with this i wont need to use a while loop in my script and it will make it easier :D