Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
UpperM

Switch player side when die

Recommended Posts

JShock: I think it's because you're setting the variable on the dead body, then trying to read it from the new body.

Well the killed EH sets the variable on the unit that was killed, then the respawn EH checks on the new unit, not the old.

EDIT: Nvm get what your saying Spike...try this (#brain dead):

player addEventHandler   
[  
   "Respawn",  
   {  
       if ((_this select 1) getVariable ["hasBeenInfected",false]) then  
       {  
           _newGrp = createGroup EAST;  
           [(_this select 0)] joinSilent _newGrp; 
           (_this select 0) setPos (getMarkerPos "respawn_east"); 
       }; 
       hintSilent format ["Are you infected?: ",(_this select 1) getVariable ["hasBeenInfected",false]]; 
   }  
];  

Share this post


Link to post
Share on other sites

I have this when I die :

b4a6436224.jpg

But i'm still BLUEFOR

In my Description.ext

Respawn = BASE;

My initPlayerLocal.sqf

/*

Fichier : initPlayerLocal.sqf
Auteur  :
Utilité :

*/

//--- Fatigue OFF

player enableFatigue false;
player addMPEventhandler ["MPRespawn", {player enableFatigue false}];

//---- Autre

execVM "intro.sqf";

//--- Auto Switch

if (side player isEqualTo WEST) then
{
   player setVariable ["hasBeenInfected",false,true];
}
else
{
   if (side player isEqualTo EAST) then
   {
       player setVariable ["hasBeenInfected",true,true];
   };
};

player addEventHandler
[
   "Killed",
   {
       if ((_this select 1) getVariable ["hasBeenInfected",false]) then
       {
           (_this select 0) setVariable ["hasBeenInfected",true,true];
       };
   }
];

player addEventHandler
[
   "Respawn",
   {
       if ((_this select 1) getVariable ["hasBeenInfected",false]) then
       {
           _newGrp = createGroup EAST;
           [(_this select 0)] joinSilent _newGrp;
           (_this select 0) setPos (getMarkerPos "respawn_east");
       };
       hintSilent format ["Are you infected?: ",(_this select 1) getVariable ["hasBeenInfected",false]];
   }
];

And i have my respawn_west and respawn_east.

Share this post


Link to post
Share on other sites

OMG, sorry long freaking day, forgot the "%1" in the format for the hint....

player addEventHandler
[
   "Respawn",
   {
       if ((_this select 1) getVariable ["hasBeenInfected",false]) then
       {
           _newGrp = createGroup EAST;
           [(_this select 0)] joinSilent _newGrp;
           (_this select 0) setPos (getMarkerPos "respawn_east");
       };
       hintSilent format ["Are you infected?: %1",(_this select 1) getVariable ["hasBeenInfected",false]];
   }
];

Share this post


Link to post
Share on other sites

I have : Are you infected?: False

Share this post


Link to post
Share on other sites

Ok, hmm, see if adding a 5 second respawn delay changes anything...

Share this post


Link to post
Share on other sites

Same "Are you infected?: False"

Share this post


Link to post
Share on other sites
Sign in to follow this  

×