Home   Help Search Login Register  

Author Topic: Respawning with no equipment  (Read 3275 times)

0 Members and 1 Guest are viewing this topic.

Offline Blacknite

  • Members
  • *
  • Chiefs runs the navy!
Respawning with no equipment
« on: 19 Jul 2009, 19:04:30 »
Alright, so I know how to respawn them, but I cant figure out how to make them respawn with no weapons and equipment.  Any solutions?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Respawning with no equipment
« Reply #1 on: 20 Jul 2009, 22:21:18 »
Code: [Select]
// Wait for respawn.
waitUntil { alive player };
// Wait until the unit has its equipment reset after the respawn.
waitUntil { (count (weapons player)) > 0 };
// Clear all weapons.
removeAllWeapons player;
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Blacknite

  • Members
  • *
  • Chiefs runs the navy!
Re: Respawning with no equipment
« Reply #2 on: 21 Jul 2009, 16:07:43 »
That script doesnt appear to be working, it also gives me an error with the "(" instead of "=" or something like that.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Respawning with no equipment
« Reply #3 on: 21 Jul 2009, 17:26:30 »
If you have an error, it helps to copy the message out of the arma.rpt file rather than be a bit vague about what is going wrong.

The most likely reason this doesn't work is that you a) think it is a complete solution (it isn't) and/or b) are running it as SQS using exec command.

Code: (respawnWithoutGear.sqf) [Select]
// Run from init.sqf/init.sqs with:
//   [] execVM "respawnWithoutGear.sqf";

if (isDedicated) exitWith {}; // Dedi server doesn't have a player.

waitUntil { alive player };

if (player iskindOf "Civilian") exitWith {}; // Civilians don't get gear anyway.

player addEventHandler ["KILLED", {
  [] spawn
  {
    // Wait for respawn.
    waitUntil { alive player };

    // Wait until the unit has its equipment reset after the respawn. 
    waitUntil { (count (weapons player)) > 0 };

    removeAllWeapons player; // Remove weapons and magazines.
    removeAllItems player; // Remove items like compass and map.
  };
}];
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)