"Wait" Command?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

"Wait" Command?

Post by Sgt.Pepper »

Ok, I've given up on my searches and decided to ask on this one.

I'm making a script to protect the spawns in a DM game. I've created a trigger_multiple around the spawn area, and when the opposing team enters the spawn they get a message telling them that they shouldn't be there. I managed to get that far reading some of the great posts here. It works fine, only the message continually scrolls. I would like the message to appear every 2-5 seconds or so for the player in the spawn. I have a feeling a "wait" command could do it, but I have no idea where to put it. Any help would be appreciated. Here's the script:

//trigger multiple
local.trig = spawn trigger_multiple
local.trig.origin = ( -1114.00 3746.00 8.00 )
local.trig setsize ( -500.00 -500.00 -8.00 ) ( 500.00 500.00 100.00 )
local.trig setthread thread

level waittill spawn

thread:

local.player = parm.other
{
if ( local.player.dmteam == axis )
local.player iprint "Hey F***nut, out of the Allie spawn!"
}

That message is for testing and will be changed before it's used on the server. The map is Stadt, and the trigger is in the Allie spawn, if you wish to try it. Thanks again.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hmm well first of all this script will probably not work very well.

This is because a setthread is fired every frame the trigger is triggered, and only once per frame. This means that when there is an Allied player in the trigger it won't fire for Axis players anymore :?

You can try to use isTouching instead and use a while and for loop to check for all players whether they are in the trigger or not. Be advised however that spectators can also be considered 'touching' a trigger.

Sorry for not answering your question directly. I just think this needs fixing first ;).
Image
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post by Sgt.Pepper »

That's cool, I never tested it with an axis and allie in the trigger. Plus, I'd prefer to do it properly. This seems a little above me, so it should be good to learn some new commands.

Ok, taking your suggestions, and getting ideas on how to use them from the minefield.scr, how does this look? I haven't tried it in game yet, I want to make sure I'm using your suggestions in the right way.

thread:

local.player = parm.other
{
while ( local.player.dmteam == axis istouching local.trig )
local.player iprint "Hey F***nut, out of the Allie spawn!"
}
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Actually I was thinking of something like this:

Code: Select all

while(1)
{
  for(local.i = 1; local.i <= $player.size; local.i++)
  {
    local.player = $player[local.i]
    if(local.player.skip != 1)
    {
      if(local.player.dmteam == axis)
      {
        if(local.player isTouching local.trig) 
        {
            // f*cknut text here
            local.player.skip = 1
            local.player thread reset
        }
      }
    }
  }
  waitframe
}
end

reset:
  wait 5
  if(self != NIL && self)
    self.skip = 0
end
Image
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post by Sgt.Pepper »

Holy poop, that's really hard core scripting!

Ok, I'll mess with that then. It'll be interesting trying to understand it for future refernce, although I think I'm over my head on this one.

Thanks for the detailed reply.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Post by tltrude »

thread:
while (local.trig)
local.spawnkiller = parm.other
{
if ((local.spawnkiller.dmteam == axis) && (local.spawnkiller istouching local.trig ))
{
local.player iprint "Hey F***nut, get out of the Allied spawn area!"
wait 5
radiusdamage local.spawnkiller.origin 10 16
}
}
waitfarme
end

There has to be at least one wait in a while loop or it will spaz out. As is, the axis player will be damaged 10 points every 5 seconds he remains in the the trigger.

I think "iprint" only prints to the console. Try "iprintln" if yours doesn't work. You might also think about renaming the thread to "spawnkiller_allied" or something other than "thread".
Tom Trude,

Image
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post by Sgt.Pepper »

Ok, when I use the first suggestion, after I leave the trigger the game lags heavily, and I get this as a console error:

Image

I haven't tried the second suggestion yet. That hurt part would be interesting for spawn campers. Oh, the iprint does work, it appears under the compass. I had originally wanted it to appear as a line across the middle of the player's screen, but the message command was giving me errors.

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

Post by jv_map »

You get that error since parm.other isn't used properly here. You can only use parm.other if there actually was a trigger event but then my first remark (about problems without multiple players) comes into play.
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

whats local.player.skip do?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

It sets a variable so you only see the message once every 5 seconds. Maybe not a very neat way to do it but I think it will work :)
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

oh i thought it was predefined
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post by Sgt.Pepper »

Well, as is my usual, I've lost interest in scripting for a period. When I tried tltrude's reply I got a "possible infinate loop" error. So I'll giv ethis another try in the future. Hopefully with the suggestions here I can get it to work. Thanks.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

You got that error becuase the waitframe is outside the while loop ;).
Image
Post Reply