an advice for triggers

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: an advice for triggers

Post by Drofder2004 » June 9th, 2010, 8:52 pm

...


Ok, just to provide a little proof into your misunderstanding on this said "random event"...
I have adjust the codjumper mod to spawn 30 players (21 including myself). I have then created a map and a script that will move all players and drop them on to the top of a trigger.
The mod will also put a timescale of 0.5 to help show you what is being done...

Firstly: 30 people hit the trigger. All 30 names appear (I would assume in order of the for() loop).
Then, while ALL the bots and I are in the trigger zone, the mod will show a "iprintln()" of the name of the player being threaded on.

Now as you watch this video, please take note:
- There is no wait time between each player being captured by the trigger
- The multiple times the players are captured, at no time are they collected ina random order (the order repeats over)
- The "wait" between the prints are not only in 50% speed but also (I think) caused by the server refresh time, not the code).

http://www.megavideo.com/?v=9NPPNNC8

I hope you can finally understand, code is NEVER random.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: an advice for triggers

Post by megazor » June 10th, 2010, 3:17 am

Code: Select all

for (i = 0; i < players.size; i++)
{
               trig waittill ("trigger", user);
               iprintln("caught "+user.name);
}
here there is no time between being caught.
but i was sometimes getting the same names. how can you explain it?

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: an advice for triggers

Post by megazor » June 10th, 2010, 3:29 am

maybe in cod4 waittill works in the right way.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: an advice for triggers

Post by Drofder2004 » June 10th, 2010, 7:37 pm

megazor wrote:

Code: Select all

for (i = 0; i < players.size; i++)
{
               trig waittill ("trigger", user);
               iprintln("caught "+user.name);
}
here there is no time between being caught.
but i was sometimes getting the same names. how can you explain it?
Why are you looping the players when the players are automatically detected by the trigger?
Only loop on players when you ar either running a check on them or if you wish to run a thread on the lot of em.

This has got nothing to do with CoD4, I learned my map based scripting in CoD1.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: an advice for triggers

Post by megazor » June 10th, 2010, 10:31 pm

Why are you looping the players when the players are automatically detected by the trigger?
i want the waittill to run as many times in one frame as how many players are there. should catch everyone who touches it, shouldn't it?

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: an advice for triggers

Post by megazor » June 10th, 2010, 10:35 pm

imagine the players amount is 5, then it is the same as for (i = 0; i < 5; i++)
so the waittill function runs 5 times.

according to what you wrote, waittill function has no wait time between each other, so it is the same as it was without the loop - i just use the loop for a handy check.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: an advice for triggers

Post by Drofder2004 » June 11th, 2010, 2:31 am

"waittill" is its own wait timer. I do not know the exact limitations, but it will detect every trigger, I cannot tell you how it does it, but I know it does. It catches every player in a trigger multiple, you do not need to try and "improve" it by adding a more complex loop.

You for loop will do:

Loop 1:
Wait for trigger
Do something:
Loop 2:
Wait for trigger
Do something:
Loop 3:
Wait for trigger
Do something:
Loop 4:
Wait for trigger
Do something:
Loop 5:
Wait for trigger
Do something:
-> Stop

My way will do:

Loop 1:
Wait for trigger
Do something
-> go to loop 1.


The waittill function will detect any and every player that touches it and will loop as many times as it requires to, you do not need to set preferences.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: an advice for triggers

Post by megazor » June 11th, 2010, 5:09 am

please answer my question: why doesn't the code i posted choose different places constantly?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: an advice for triggers

Post by Drofder2004 » June 12th, 2010, 3:56 pm

Not sure what you are trying to say?

If you are having problems with your code, don't use it. I have explained with good enough reasoning to show you why your code is wrong.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests