Jump to content
kerozen

Different group respawn points

Recommended Posts

Hello.

 

I'm trying to create different spawn points for different groups. The mission is going to have 3 different forces, the Pilots, the SOF guys and normal Army guys. I want each to have their own respawn point. Tried searching for something similar and came up with:

 

OnPlayerRespawn.sqf

 player addEventHandler ["Respawn", {

if (group player == "B Alpha 1-1") then {player setpos (getmarkerpos "PilotRespawn"); } else { if (group player == "B Alpha 1-2") then {player setpos (getmarkerpos "SOFRespawn");

}];

Tried using Respawn and MPrespawn EH, both didn't work.

Respawn is set as Custom Location and there are 3 markers (respawn_west, PilotRespawn and SOFRespawn and also tried on Position of Death but the code doesn't do anything and also doesn't work.

  • Like 1

Share this post


Link to post
Share on other sites

hi,

 

you can do what you want with :

player addEventHandler ["Respawn", {
if (groupId (group player) == "Alpha 1-1") then {player setpos (getmarkerpos "respawntroup"); } else {player setpos (getmarkerpos "respawnpilot");}
}];

if you want more than 2 pos you can use the switch command

ex :

player addEventHandler ["Respawn", {
  switch (groupId (group player)) do {
      case "Alpha 1-1": {
          player setpos (getmarkerpos "PilotRespawn");
      };
      case "Alpha 1-2": {
          player setpos (getmarkerpos "SOFRespawn");
      };
      case "Alpha 1-3": {
          player setpos (getmarkerpos "AnotherRespawnMarker");
      };
  };
}];

 

the command "groupId" return the group name

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

@pokertour

 

Thank you. I ended up using this:

 

player addEventHandler ["Respawn", {
if (groupId (group player) == "Alpha 1-1") then {player setpos (getmarkerpos "PilotRespawn"); } else {}
}];

player addEventHandler ["Respawn", {
if (groupId (group player) == "Alpha 1-2") then {player setpos (getmarkerpos "SOFRespawn"); } else {}
}];

because i couldn't get switch do working, i didn't get any errors it just didn't do anything

 

player addEventHandler ["Respawn", {

switch (groupId (group player)) do {
    case "Alpha 1-1"; { player setpos (getmarkerpos "PilotRespawn"); };
    case "Alpha 1-2"; {player setpos (getmarkerpos "SOFRespawn"); };
	default {player setpos (getmarkerpos "respawn_west"); };
};
}];

 

Share this post


Link to post
Share on other sites

if you don't use the else statement you can remove it and keep only your Then :

if (groupId (group player) == "Alpha 1-1") then {player setpos (getmarkerpos "PilotRespawn"); };

 

you can also regroup your two if in only one EventHandler:

player addEventHandler ["Respawn", {
	if (groupId (group player) == "Alpha 1-1") then {player setpos (getmarkerpos "PilotRespawn"); };
	if (groupId (group player) == "Alpha 1-2") then {player setpos (getmarkerpos "SOFRespawn"); };
}];

 

 

it's because in your case you have put ";" instead of ":"

case "Alpha 1-1";

need to be : 
case "Alpha 1-1":

 

  • Thanks 1

Share this post


Link to post
Share on other sites

@pokertour

 

Thanks for the help once again.

 

In terms of performance or possibility of "malfunction" which of the two is better to use? Switch do or If?

Share this post


Link to post
Share on other sites

I think " If " is faster than " switch do "

maybe someone can confirm ? @GEORGE FLOROS GR you make a lot of scripts maybe you have an idea :)

 

what do you mean by "malfunction" ?

  • Like 1

Share this post


Link to post
Share on other sites

I always read that arma sometimes breaks and stops running scripts correctly and stuff. I not a scripter so i don't know how to optimize code.

Share this post


Link to post
Share on other sites

Speed is never an issue with such a small script that is run only once in respawn. You should only have to optimize slow loops and such

  • Like 1
  • Thanks 1

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

×