Y origin calculation?

Post your scripting questions / solutions here

Moderator: Moderators

jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yes you can glue it very tight 8-)
Image
User avatar
oddball
Corporal
Posts: 44
Joined: Tue May 27, 2003 3:49 pm
Contact:

Post by oddball »

i was thinking, i'm using if (isalive($player[local.p]) if it wouldn't be better to use while (isalive $player[local.p]

the if statement if only accessed while checking, if i add a while for each player, it scans all the time, or am i wrong in this ?
besides that 32 while loops, would that give a high server load ?

what you think is the best? while or a trigger ?
[VS-UK]Maj.OddBall[BnHQ]
User avatar
oddball
Corporal
Posts: 44
Joined: Tue May 27, 2003 3:49 pm
Contact:

Post by oddball »

ok, after some searching i added this to my script

Code: Select all

start:
for (local.h = 1; local.h <= $player.size; local.h++)
   {					
   level.num = int(local.h)
   thread playertrigger $player[local.h]
   }
end
and:

Code: Select all

playertrigger local.player:

level.trigger[level.num] = spawn trigger_use 
level.trigger[level.num].origin = $player[level.num].origin 
level.trigger[level.num] setsize ( -50 -50 -50 ) ( 50 50 50 ) 
level.trigger[level.num] glue local.player 
end 
So this means it spawned triggers for every player.
now the question,

how can i get the state of the trigger in an "if" statement?

something like : if trigger = 1 bla bla bla..

if possible, i don't want to use the waittill trigger
[VS-UK]Maj.OddBall[BnHQ]
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Post by tltrude »

if (level.trigger[level.num] == 1)

But, level.num must have a value or it will just use the last number it was set to.

if (level.trigger1 == 1)
if (level.trigger2 == 1)
if (level.trigger3 == 1)
Tom Trude,

Image
User avatar
oddball
Corporal
Posts: 44
Joined: Tue May 27, 2003 3:49 pm
Contact:

Post by oddball »

thanks,
Yes i know, i have another thread where it comes back and picks it up
[VS-UK]Maj.OddBall[BnHQ]
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

You will have to use waittill trigger I'm afraid :(... however it's quite easy to work-around it:

Code: Select all

$mytrigger thread watchtrigger

// ---

watchtrigger:
  self wait 0.05 // trigger every frame
  while(self)
  {
    self waittill trigger
    self.lasttriggertime = level.time
  }
end

isbeingtriggered:
end (level.time - self.lasttriggertime <= 0.10)
With this bit of code you can do neat things, i.e. call the watchtrigger thread once and after that you can simply do:

Code: Select all

if ($mytrigger waitthread isbeingtriggered)
{
  // etc
}
8-)
Image
User avatar
oddball
Corporal
Posts: 44
Joined: Tue May 27, 2003 3:49 pm
Contact:

Post by oddball »

hmmm, interesting, will give it a try
[VS-UK]Maj.OddBall[BnHQ]
Post Reply