Jump to content
Sign in to follow this  
nickk13579

a little bit of help with this respawn...

Recommended Posts

i want to be able to spawn players in at various points on the map depending on what they select.. i have used a script that already did that with markers, but im not sure how to integrate the addition of characters spawning without any gear/weapons whenever they spawn. can someone please help?

-Nick

Share this post


Link to post
Share on other sites

There is only 2 ways to do what you want.

1. Have modified infantry units in the config whereby infantry units do not have weapons specified when they respawn.

and

2. Have a sqf (sqs) script that is run when a unit dies and monitors the units 'aliveness'.

The 2nd. is probably what you want to do.

To achieve this you will need to attach an eventHandler to the given infantry unit for the 'killed' event.

In the script for this event handler you will spawn another monitoring script that sits around waiting for the unit to become alive again and then removes the units weapons.

eg.

In an init.sqf file that will get run on any given client computer have the following. (alter the paths to suit)

init.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

KilledEH                = compile preprocessFileLineNumbers "scripts\mp_client\KilledEH.sqf";

OnRespawn               = compile preprocessFileLineNumbers "scripts\mp_client\OnRespawn.sqf";

aryUnits = [W1,W2,W3,W4,W5,W6,W7,E1,E2,E3];

{removeAllWeapons _x; _x addEventHandler ["killed", {_dummy = _this spawn KilledEH;}];} forEach aryUnits;

The above uses a hard coded array of playable infantry units as named in the editor and initially removes their weapons and adds a killed EH to each.

You can contruct this array from either hardcoding it or make it more dynamic by populating the array 'on the fly' with a trigger. Or, you could just specify 1 individual unit. Sup to you really.

KilledEH.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

private ["_Unit","_Killer"];

_Unit = _this select 0;

_Killer = _this select 1;

_handle = [_Unit] spawn OnRespawn; //spawn a watcher script thread

OnRespawn.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

private ["_Unit","_UnitName"];

_Unit = _this select 0;

_UnitName = vehicleVarName _Unit;

call compile format["waitUntil {alive %1};", _UnitName];

call compile format["removeAllWeapons %1;", _UnitName];

call compile format["if (!(isplayer %1)) then {%1 addEventHandler [""killed"", {_dummy = _this spawn KilledEH;}];};",  _UnitName];

The last line in the above 'OnRespawn.sqf' is a hack for AI units that this script is running against 'cause Event handlers do not persist between respawns for AI only 'player' characters.

Note. The Killed EH has to be attached locally on a given clients computer.

cheers.

Share this post


Link to post
Share on other sites

ok... well i was able to make all three of these .sqfs, but do i put them in the main directory of my mission? Sorry, im a bit of a noob.

Thank you very much for all of what you have given me above!

Share this post


Link to post
Share on other sites

you can put scripts (sqf & sqs) anywhere within your mission folder... you just need to reference them properly...

I suggest you make a folder within your mission folder called 'scripts'.

place the script files 'KilledEH.sqf' and 'OnRespawn.sqf' in this scripts folder.

place your init.sqf in the root folder of your mission. (where the mission.sqm is...)

alter the init.sqf file.

replace 'scripts\mp_client\KilledEH.sqf' with 'scripts\KilledEH.sqf'...

and

replace 'scripts\mp_client\OnRespawn.sqf' with 'scripts\OnRespawn.sqf'

good luck...

Share this post


Link to post
Share on other sites

Ok well I followed all those directions and my character named W1 now spawns without any weapons like i want.. but respawn is a different story. I just turn into a bird. Do i need to place a marker to specify a spawn location?

Share this post


Link to post
Share on other sites

you need a description.ext file in your mission root folder.

you should specify a respawn type in this file....

also, you need a marker placed on the map via the editor called 'respawn_west' or one of the other 'sides' as specified...

Share this post


Link to post
Share on other sites

eJay, that is the best script for respawning, but i dont know how to make it so that every time you spawn you have no weapon and also you can INITIALLY choose a spot to spawn rather than spawning at a specific place as directed in the script and having to die before getting a choice of spawn location.

So basically thats how i want my script to work but with a couple additions. Do you know what i would have to do to make that possible?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×