OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: JasonO on 05 Aug 2006, 23:56:02
-
Hi
How would i make it so if a unit respawns, he respawns in a vehicle. This vehicle would have to be created and not already in the mission.
How would i do this?
Thanks
-
Have a "killed" eventhandler with a black in;
create vehicle & assign the unit as driver/cargo while black I'd try
Hope it works for you!
Greetz 8)
-
Hi
How would i make it so if a unit respawns, he respawns in a vehicle. This vehicle would have to be created and not already in the mission.
How would i do this?
Thanks
if this was a respawning AI, it requires a bit of complexity because the only way of tracking a respawning ai is by the unit name, as this is the only attribute that is common to the old "unit" and the newly respawned "unit" (this imo just about enters the advance scripting area)
if this is only meant to work on a Player unit, then it's fairly easy and utilising a killed event handler on the player as Seven indicated is by far the most efficient way to do this (this is fairly basic) unless the type of vehicle you want to respawn into differs from player to player
INIT.SQS
Tx_A =player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
playerkilled.sqs
_veh = "classname" createvehicle position
Player removeventhandler ["killed",Tx_A]
@ alive player
Tx_A =player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
@ ! isnull _veh
Player moveindriver _veh
exit
uou will have to add the
classname
and
position
to the script yourself
-
Thanks.
I try it now ;)
EDIT : The position. Would this be a game logic? or would it be a coordinate?
Also would this work for 1 player, or multiple players.
I want this for a DM, but looking at the script player is global, so it wouldnt work ?
-
"player" is always local.
-
I think it would be better to use random respawn points when it's for a DM;
you can either do that with different spawnpoints by calling them (those are markers) west_respawn west_respawn_1 west_respawn_2 and so on for the player to respawn. Or use a bunch of gamelogics and make a random respawn script for the player.
Create the vehicle out of sight at a gamelogic;
Then
_veh = "classname" createvehicle myGL
Player removeventhandler ["killed",Tx_A]
@ alive player
_pos = getpos player
titlecut [" ","BLACK OUT",0.001]
Tx_A =player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
@ ! isnull _veh
_veh setpos _pos
Player moveindriver _veh
tittlecut ["","BLACK IN",0.1]
exit
Hope that works.
For random respawn points perform a search there's many topics on that
-
I think it would be better to use random respawn points when it's for a DM;
you can either do that with different spawnpoints by calling them (those are markers) west_respawn west_respawn_1 west_respawn_2 and so on for the player to respawn. Or use a bunch of gamelogics and make a random respawn script for the player.
Create the vehicle out of sight at a gamelogic;
Then
_veh = "classname" createvehicle myGL
Player removeventhandler ["killed",Tx_A]
@ alive player
_pos = getpos player
titlecut [" ","BLACK OUT",0.001]
Tx_A =player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
@ ! isnull _veh
_veh setpos _pos
Player moveindriver _veh
tittlecut ["","BLACK IN",0.1]
exit
Hope that works.
For random respawn points perform a search there's many topics on that
Sorry for the slow reply, but ive been on holiday but im back now so lets continue..
I got an error when player died saying unknow operator removeventhandler.
EDIT: I found problem, a little typo :) Also i found another typo for the fade-in to many 't's in titlecut :D
So now the script to use now is :
_veh = "vehiclename" createvehicle gamelogicname
Player removeeventhandler ["killed",Tx_A]
@ alive player
~0.05
_pos = getpos player
titlecut [" ","BLACK OUT",0.001]
Tx_A = player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
@ ! isnull _veh
_veh setpos _pos
Player moveindriver _veh
_veh lock true
titlecut ["","BLACK IN",0.1]
exit
I added the lock feature since i didnt want ppl getting out of the vehicle.
I also added a small time delay because when the player respawns he randomly ends up in a marker area. Inside the marker area there is 9 triggers. Each takes the player to a diffrent game logic on the map. Therefore random respawn (I use it in all my DM's to avoid scripts :p )
Im gonna see if it works now. ::)
EDIT II : OK, when it trys to create the vehicle it says the following error :
'_veh = "M1Abrams" CreateVehicle vehspawn|#|' Error createvehicle: Type Object, expected Array
Thanks for your help
-
'_veh = "M1Abrams" CreateVehicle vehspawn|#|' Error createvehicle: Type Object, expected Array
ehm
_vspawn = getpos vehspawn
_veh = "vehiclename" createvehicle _vspawn
Player removeeventhandler ["killed",Tx_A]
@ alive player
~0.05
_pos = getpos player
titlecut [" ","BLACK OUT",0.001]
Tx_A = player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
@ ! isnull _veh
_veh setpos _pos
Player moveindriver _veh
_veh lock true
titlecut ["","BLACK IN",0.1]
exit
Greetz
-
Thanks.
I also added to the script that after you respawn you and your vehicle would be transported to one of the 9 random places on the map.
Works great.
Thanks a lot for your help ;D