Home   Help Search Login Register  

Author Topic: Spawn Script problem  (Read 2621 times)

0 Members and 1 Guest are viewing this topic.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Spawn Script problem
« 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 ;)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Spawn Script problem
« Reply #1 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.


« Last Edit: 25 Jul 2006, 18:20:17 by Mr.Peanut »
urp!

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Spawn Script problem
« Reply #2 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.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Spawn Script problem
« Reply #3 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?

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Spawn Script problem
« Reply #4 on: 26 Jul 2006, 00:30:20 »
How do you execute it?

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Spawn Script problem
« Reply #5 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?)

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: Spawn Script problem
« Reply #6 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

Offline FiLL2d

  • Members
  • *
  • X.x
Re: Spawn Script problem
« Reply #7 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...  :-\

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Spawn Script problem
« Reply #8 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.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Spawn Script problem
« Reply #9 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"
urp!

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Spawn Script problem
« Reply #10 on: 27 Jul 2006, 14:09:46 »
Problem solved.

Thanks everyone :D