OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: BlackNight on 16 Oct 2002, 04:48:24
-
hi, could some one help me, i have 3 different units and i want them to respawn in 3 didferent places, they all are west units, i found a script that Backoff wrote but i cant get it to work, i put this in the trigger:
x:0
x:0
Activate: Repeatedly
Condition: !(alive S1)
Deactivation: [S1, 3] exec "respawn.sqs"
and this in the "respawn.sqs":
_player = _this select 0
_numzone = _this select 1
_radius = 50
_respawnzone = "Respawn_West"
;randomly choose a respawn zone:
_num = random(_numzone)
;get integer
_num = _num - (_num mod 1)
;Exit and respawn in normal zone if num is 0
?(_num == 0): Exit
_respawnzone = format ["%1%2", _respawnzone,_num]
;create random number to set the player position
_randx = random (_radius)
?(random(10) < 5): _randx = _randx * -1
_randy = random(_radius)
?(random(10) < 5): _randy = _randy * -1
;set the position
_player setpos [(_pos select 0) + _randx, (_pos select 1) + _randy, (_pos select2)]
Exit
and also i named my player the number S1 , i have a marker Respawn_West and i cant figure out what i am doing wrong. i have 8 guys at one position and 3 at another and 8 more at another place and none of them respawn. nad i have done it just like he said here is where i found it and it is the 7th one down http://www.ofpec.com/yabbse/index.php?board=;action=searchfaq
-
You need to create three markers called respawn_west1, respawn_west2, and respawn_west3. I.e. respawn markers whose names end with the number you supply as the second parameter when calling the script.
You'll see that the line
_respawnzone = format ["%1%2", _respawnzone,_num]concatenates the zone name and the number.
Happy scripting,
Pope Zog
-
I tried what you said and it didnt work, it gave me an Error message that said this:_player setpos [(_pos select 0) + _randx, (_pos select 1) + _randy, (_pos select2)] . And also at the end of that it said this : Error unknown select2
So i make a sample mission with 3 players , 3 triggers and 3 markers, and and it still didnt work, can you look at how i have it and see if you can see what is wrong.
in the first marker is put: Respawn_West1
the first trigger: axa0 axb0
activate:repeatedly
condition: !(alive S1)
deactivation: [S1, 1] exec "respawn.sqs"
first player name:S1
second marker: Respawn_West2
second trigger: axa0 axb0
activate: repeatedly
condition: !(alive S2)
deactivation: [S2, 2] exec "respawn.sqs"
second player S2
3rd marker: Respawn_West3
3rd trigger: axa0 axb0
activate: repeatedly
condition: !(alive S3)
deactivation: [S3, 3] exec "respawn.sqs
3rd player S3
and this is the respawn.sqs:
_player = _this select 0
_numzone = _this select 1
_radius = 50
_respawnzone = "Respawn_West"
;randomly choose a respawn zone:
_num = random(_numzone)
;get integer
_num = _num - (_num mod 1)
;Exit and respawn in normal zone if num is 0
?(_num == 0): Exit
_respawnzone = format ["%1%2", _respawnzone,_num]
;create random number to set the player position
_randx = random (_radius)
?(random(10) < 5): _randx = _randx * -1
_randy = random(_radius)
?(random(10) < 5): _randy = _randy * -1
;set the position
_player setpos [(_pos select 0) + _randx, (_pos select 1) + _randy, (_pos select2)]
Exit
-
Hi BlackNight,
There is a missing line just after:
_respawnzone = format ["%1%2", _respawnzone,_num]
add this code:
_pos = getMarkerPos _respawnzone
it should fix the script
-
thank you very much, i will try it :)
-
I tried it and it didnt work, any other ideas
-
> any other ideas
Yes, a few... :)
You're using the script a bit wrong. Let me explain.
I'll assume you'd like three different respawn areas for west. Create the markers respawn_west, respawn_west1, and respawn_west2. You need the good-old respawn_west in case the random number generator returns zero.
Second, your triggers to respawn the players should all be activated with 3 as their second parameter, e.g. [S1, 3] exec "respawn.sqs". This is because you have three different respawn zones. If you put 1 or 2 there then the first player will always respawn in respawn_west, and the second will respawn in either respawn_west or respawn_west1, but never in respawn_west2.
Now for the code that gives you the error:
_player setpos [(_pos select 0) + _randx, (_pos select 1) + _randy, (_pos select2)] You're likely to run into this one again, so examining it a little and understanding it will help you solve it next time.
The code is trying to set the position (setpos) of the player (_player) to a specific x, y, z coordinate (and you thought you'd never find a use for that boring geometry ;) ).
The x and y coordinates are determined by multiplying the x and y coordinates of the respawn marker by a random number, and the z coordinate (the height) is where the problem happens.
The variable _pos is an array with three elements: x, y and z. You can fetch the value of each using the select command. _pos select 0 gets the x coordinate, _pos select 1 gets the y coordinate, and _pos select 2 gets the z coordinate. So all you're missing in your code is a space between select and 2.
However, (this is for Backoff) instead of putting _pos select 2, I think you could put 0 (zero) there - the player is supposed to respawn at ground-level, isn't he?
Hopefully this solves your problem,
Pope Zog