"Wait" Command?
Moderator: Moderators
-
Sgt.Pepper
- Sergeant
- Posts: 69
- Joined: Tue Feb 25, 2003 5:41 pm
- Location: Canada
"Wait" Command?
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.
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.
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
.
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
-
Sgt.Pepper
- Sergeant
- Posts: 69
- Joined: Tue Feb 25, 2003 5:41 pm
- Location: Canada
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!"
}
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!"
}
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
-
Sgt.Pepper
- Sergeant
- Posts: 69
- Joined: Tue Feb 25, 2003 5:41 pm
- Location: Canada
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".
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".
-
Sgt.Pepper
- Sergeant
- Posts: 69
- Joined: Tue Feb 25, 2003 5:41 pm
- Location: Canada
Ok, when I use the first suggestion, after I leave the trigger the game lags heavily, and I get this as a console error:

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.

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.
-
Sgt.Pepper
- Sergeant
- Posts: 69
- Joined: Tue Feb 25, 2003 5:41 pm
- Location: Canada

