OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: JasonO on 25 Jul 2006, 17:47:30

Title: Spawn Script problem
Post by: JasonO on 25 Jul 2006, 17:47:30
Hi

I have this script to run

Code: [Select]
_player = _this select 0
_location = _this select 1

#alive
hint "alive"
? not alive _player : goto "notalive"
~0.5
goto "alive"

#notalive
hint "waiting for soldier to be alive"
@alive _player

#respawn
_player setpos getpos _location
hint "teleported"

This code is meant to make a unit transport to a game logic.. but it dont work.

I have the following in the units INIT field:
Code: [Select]
[this,logicname] exec "respawn.sqs"

Whats wrong?

Thanks for your help ;)
Title: Re: Spawn Script problem
Post by: Mr.Peanut on 25 Jul 2006, 18:17:34
Once the unit is dead the local variable that refers to it, in your case _player, no longer refers to anything.
Try using the player command instead.

i.e.
Code: [Select]
_location = _this select 0

#alive
hint "alive"
? not alive player : goto "notalive"
~2
goto "alive"

#notalive
hint "waiting for soldier to be alive"
@alive player

#respawn
player setpos getpos _location
hint "teleported"

Then call this code from the init.sqs.
Also, your goto loop is not going to save cpu unless you set the pause larger. Otherwise, just use @(not alive player) which is less cpu intensive than a fast loop, as long as the test condition is simple.


Title: Re: Spawn Script problem
Post by: Garcia on 25 Jul 2006, 18:37:54
Once the unit is dead the local variable that refers to it, in your case _player, no longer refers to anything.
Try using the player command instead.

The local variable will still refer to the body, so you can delete the old body with the _player variable, but of course, the _player variable won't refer to the player anymore, since he/she gets created into a new body.
Title: Re: Spawn Script problem
Post by: JasonO on 25 Jul 2006, 22:10:18
OK, thanks for your advice but it doesnt seem to work with more than one unit executing the script. They seem to respawn at the same place even though their locations are assigned differerent places.

I have 2 teams. with about 10 players each, how would i still do it?
Title: Re: Spawn Script problem
Post by: Garcia on 26 Jul 2006, 00:30:20
How do you execute it?
Title: Re: Spawn Script problem
Post by: JasonO on 26 Jul 2006, 13:10:21
at the moment i have
Code: [Select]
[this,logicname] exec "respawn.sqs"In the units init field, but i kinda figured out that the init field is at start of mission, not when the unit respawns (right?)
Title: Re: Spawn Script problem
Post by: Seven on 26 Jul 2006, 22:20:38
Are those 2 teams East & West?
If so it would be much easyer to make two markers named "respawn_east" & "respawn_west" and put respawn=3
in description.ext
Title: Re: Spawn Script problem
Post by: FiLL2d on 26 Jul 2006, 22:34:39
Quote
Are those 2 teams East & West?
If so it would be much easyer to make two markers named "respawn_east" & "respawn_west" and put respawn=3
in description.ext
It seems his problem is not the respawn, but the place of respawn for each unit.

I have a similar problem with this, _player is local, but player in multiplayer gives problems...  :-\
Title: Re: Spawn Script problem
Post by: JasonO on 27 Jul 2006, 00:04:37
Quote
Are those 2 teams East & West?
If so it would be much easyer to make two markers named "respawn_east" & "respawn_west" and put respawn=3
in description.ext
It seems his problem is not the respawn, but the place of respawn for each unit.

I have a similar problem with this, _player is local, but player in multiplayer gives problems...  :-\

I have some tents, and i want it so each player has their own tent to spawn in. The problem is, im not sure how i would do this. The script i have at the moment dont do what i want it to do.

If you look at my script, i can tell what _location should be, and make it the same as the game logics, so the unit spawns in his tent.
Title: Re: Spawn Script problem
Post by: Mr.Peanut on 27 Jul 2006, 04:19:40
In each units' init field:
Code: [Select]
[this,logicname] exec "respawn.sqs"
Then the script respawn.sqs
Code: [Select]
_unit = _this select 0
_location = _this select 1
if (_unit != player) then {exit}

#alive
hint "alive"
? not alive player : goto "notalive"
~2
goto "alive"

#notalive
hint "waiting for soldier to be alive"
@alive player

#respawn
player setpos getpos _location
hint "teleported"
;small pause for hint only
~2
goto "alive"
Title: Re: Spawn Script problem
Post by: JasonO on 27 Jul 2006, 14:09:46
Problem solved.

Thanks everyone :D