OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: JasonO on 25 Jul 2006, 17:47:30
-
Hi
I have this script to run
_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:
[this,logicname] exec "respawn.sqs"
Whats wrong?
Thanks for your help ;)
-
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.
_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.
-
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.
-
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?
-
How do you execute it?
-
at the moment i have
[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?)
-
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
-
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... :-\
-
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.
-
In each units' init field:
[this,logicname] exec "respawn.sqs"
Then the script respawn.sqs
_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"
-
Problem solved.
Thanks everyone :D