*SOLVED* script not working for more than one player

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

*SOLVED* script not working for more than one player

Post by wacko »

Another script right out of my weird brains. Its task is to make a saloon door close by swinging forth and back some times.
Here it is:

Code: Select all

main:
exec global/DMprecache.scr
level.script = maps/dm/test_swingdoor.scr
local.master=spawn ScriptMaster
for (local.i=1 ; local.i <= 9 ; local.i++ )  //same sound getting lower for the saloondoor
{
local.master aliascache ("saloondoor2_"+local.i) sound/mechanics/DoorWoodClose_stop3.wav soundparms (local.i/9.00) 0.2 0.5 0.2 256 1024 auto loaded maps "dm obj"
}
local.master aliascache saloondoor1 sound/mechanics/DoorWoodClose_03.wav soundparms 1 0.2 0.5 0.2 256 1024 auto loaded maps "dm obj"
level waittill prespawn

level waittill spawn
thread saloon_door_prep	
end

saloon_door_prep:
level.saloon_door_angle = 90	//how far the doors open
$right_door time 0.5			//speed of doors
$left_door time 0.5 
end

saloon_door:
$door_opener nottriggerable
local.doorblocked = 1
local.door_turn = 1
local.player= parm.other
local.door_dir = 0
if (local.player istouching $door_collision_out)
	{
	local.door_dir = -1
	}
if (local.player istouching $door_collision_in)
	{
	local.door_dir = 1
	}
$right_door rotateYup (level.saloon_door_angle * -1 * local.door_dir)
$left_door rotateYup (level.saloon_door_angle * local.door_dir)
$left_door playsound saloondoor1
$right_door move
$left_door waitmove

//doors wait until space is empty
while (local.doorblocked)
	{
	for( local.i = 1 ; local.i <= $player.size ; local.i++ ) 
		{ 
		if (!($player[local.i] istouching $door_collision_in) && !($player[local.i] istouching $door_collision_out))
	    	{ 
	        local.doorblocked = 0 
	        }
	    else
	    	{ 
	    	local.doorblocked = 1
	    	break
	    	}
		} 
	wait 0.1
	}
	
//now doors swing back and forth into start position	
for( local.k = 9 ; local.k >= 1 ; local.k-- )
	{
	local.door_turn=local.door_turn * -1
	local.saloon_closing_angle = level.saloon_door_angle / 10 * local.k * local.door_turn
	$right_door rotateYup (local.saloon_closing_angle * -1 * local.door_dir)
	$left_door rotateYup (local.saloon_closing_angle * local.door_dir)
	$right_door move
	$left_door waitmove
	$left_door playsound ("saloondoor2_" + local.k)
//being halfway, we check for players blocking the door
	for( local.j = 1 ; local.j <= $player.size ; local.j++ ) 
		{
		if(($player[local.j] istouching $door_collision_in) || ($player[local.j] istouching $door_collision_out))
			{

			goto cleanup
			}
		}
	$right_door rotateYup (local.saloon_closing_angle * -1 * local.door_dir)
	$left_door rotateYup (local.saloon_closing_angle * local.door_dir)
	$right_door move
	$left_door waitmove
	}

cleanup:
// setting doors in start position whereever they might be
if ($right_door.angle > 180)
{
$right_door rotateYupto 0
}
if ($right_door.angle < 180)
{
$right_door rotateYdownto 0
}
if ($left_door.angle > 180)
{
$left_door rotateYupto 0
}
if ($left_door.angle < 180)
{
$left_door rotateYdownto 0
}
$right_door move
$left_door waitmove
$left_door playsound saloondoor1	
$door_opener triggerable
//everything's fine again
end 
The way it is working:
Player use trigger $door_opener
Doorwings swing away from player and stay open until the player has left both triggers $door_collision_in and $door_collision_out
Once he left, doorwings swing back and forth with decreasing angle until they are in startposition again.
Now this works fine for one player but for a second, the door does not stay open.
Any ideas? Here's a pk3 with bsp, script and map if u wanted to take a look
Last edited by wacko on Mon Mar 21, 2005 9:50 pm, edited 1 time in total.
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

*raises hand*

why can't you just use the shutter-style for the door and if a player hits use it swings forward, and then back.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

lizardkid wrote:why can't you just use the shutter-style for the door and if a player hits use it swings forward, and then back.
if u test the pk3, u'd see. it's so pretty that way, when its closing with a wopp wopp wopp wopp woppwopp. I must have it like this :wink:
Also, the current problem is the collision detection and I wonder whether I'd have the same problem with the 'shutter' solution :?
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

oh, just saw it:
on one pc, I get console message: 'Delta parseEntitiesNum too old'
and on the other 'Wacko: Delta request from out of date entities.'
is this why the doors don't work? :? and what does it mean? :? :? and what can I do about it? :? :? :?
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

whats up here? Another error in the console, right after the 2nd player has entered: Net Packet Size Overflow in SV_SendClientMessages :shock:
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

doorblocked

Post by tltrude »

I think the problem is in the doorblocked loop. But, I don't know how to fix it. Why do you need a "for" loop in it? Can't you just use local.player or make it local.player.dmteam?
Tom Trude,

Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

u mean, I should make another thread that would set a level.doorblocked (instead of the local.doorblocked) to 1 if the collision triggers were touched? Atm, I use the for loop to check whether ANY player is in the way, not just the one who did use the $door_opener
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

hehe. tom, u might not know it but u're a genius :D or i'm rather an idiot :roll:
i did like i said in my last post and now its working 8-)
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

door

Post by tltrude »

It sure is a cool saloon door! I hope you added a player triggered piano.
Tom Trude,

Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Re: door

Post by wacko »

tltrude wrote:I hope you added a player triggered piano.
Errm :oops: No.... not yet. Problem is that the 4 stock piano sounds are rubbish. I searched my cds and found nothing that would fit the theme :(
If u knew something pretty of an acceptable filesize, well, let me know :)
Oh, btw, there's another piano in the church which would need another sound as well :wink:
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Saloon

Post by tltrude »

Try this site and type in "Saloon"--it was the first site I saw when I typed "saloonpiano.wav" in my search engine.

http://www.sounddogs.com/start.asp
Tom Trude,

Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Re: Saloon

Post by wacko »

wow. thanks m8 :D I googled for 'saloon piano wav' and got nothing but rubbish :roll:
Post Reply