Jump to content
Sign in to follow this  
Silderoy

Teleport to group

Recommended Posts

Hey guys.

I made a kind of a DM mission, where teams of 4 players fight each other.

now I want to make a respawn system, where you respawn in a remote area of the map, and without any weapon. all players, no metter which team, will respawn there.

then, if at least one guys from your group is alive, you will be teleported to the group leader, and will get a preset gear list.

If the group leader is dead, you will teleport to the 2nd player, if he is dead then to the 3rd...

If no group members are alive, you will teleport to one of 5 locations randomly.

There are 5 teams, and in each team there is a TL, Grenadier, AR and medic. each one have a different gear preset...

I know its complicated (very), but it would be awsome if someone can make it work.

if you dont understand some part of my explenation about the respawn, pls ask.

This is what I got untill now. this is an example for one of the units:

while {true} do {
waitUntil {!alive s1};
waitUntil {alive s1};

sleep 0.001;

removeallweapons s1;
removeallitems s1;

sleep 0.001;

if (alive s2 && (damage s2) < 0.55) then
{
s1 setPos [ getpos s2 select 0, (getpos s2 select 1) + 2, getpos s2 select 2];
}
else
{
if (alive s3 && (damage s3) < 0.55) then
{
	s1 setPos [ getpos s3 select 0, (getpos s3 select 1) + 2, getpos s3 select 2];
}
else
{
	if (alive s4 && (damage s4) < 0.55) then
	{
		s1 setPos [ getpos s4 select 0, (getpos s4 select 1) + 2, getpos s4 select 2];
	}
	else
	{
		_randomrespawn = [s1] execVM "respawn.sqf";
	};
};
};
.
.
.
};

respawn.sqf:

//store the name of the unit that activated the eventhandler
_unit = _this select 0;

//choose random spawn point
_numb = round (random 5);

// array of available spawn points marked with invisible H's
_sp = [re1, re2, re3, re4, re5];
_undeadpos = (_sp select _numb);

//for debugging
hint format ["_sp = %1",(_sp select _numb)];

// move the repspawned unit to the selected invisible H
_nul = _unit setPos (getPos _undeadpos);

end;

the only respawn that works is the respawn on s2...

unit's name: s1.

group: s1 (lead), s2, s3, s4.

random respawn points: re1-re5.

Edited by Silderoy

Share this post


Link to post
Share on other sites

I don't think it can be working.

you have several lines which look like similar to this

s1 setPos [ getpos s2 select 0, getpos s2 select 1 + 3, getpos s2 select 2];

then need to be like this

s1 setPos [ getpos s2 select 0, (getpos s2 select 1 + 3), getpos s2 select 2];

also what are all these dots at the end?

};
.
.
.
};

I'd try this, I haven't tested it so it may not work.

while {true} do {
waitUntil {!alive s1};
waitUntil {alive s1};

sleep 0.001;

removeallweapons s1;
removeallitems s1;

sleep 0.001;
switch (true) do {
     case  (alive s2 && (damage s2) < 0.55) : {s1 setPos [ getpos s2 select 0, (getpos s2 select 1) + 2, getpos s2 select 2]};
     case  (alive s3 && (damage s3) < 0.55) : {s1 setPos [ getpos s3 select 0, (getpos s3 select 1) + 2, getpos s3 select 2]};
     case  (alive s4 && (damage s4) < 0.55) : {s1 setPos [ getpos s4 select 0, (getpos s4 select 1) + 2, getpos s4 select 2]};

default {_randomrespawn = [s1] execVM "respawn.sqf"};
               };//end switch case


};//end while

in the respawn.sqf script you have

_nul = _unit setPos (getPos _undeadpos);

it should be

_unit setPos (getPos _undeadpos);

are you using http://forums.bistudio.com/showthread.php?121163-Script-not-working-Use-the-showScriptErrors-parameter!

it will display possible scripting errors.

Share this post


Link to post
Share on other sites
I don't think it can be working.

you have several lines which look like similar to this

s1 setPos [ getpos s2 select 0, getpos s2 select 1 + 3, getpos s2 select 2];

then need to be like this

s1 setPos [ getpos s2 select 0, (getpos s2 select 1 + 3), getpos s2 select 2];

I made it with the (), but that way:

s1 setPos [ getpos s2 select 0, (getpos s2 select 1) + 3, getpos s2 select 2];

this way it gets the position, then adds 3 to it, not sure if (getpos s2 select 1 + 3) will work.

also what are all these dots at the end?

};
.
.
.
};

The script have more things in it after the respawn thing, but they are working fine...:confused:

I'd try this, I haven't tested it so it may not work.

while {true} do {
waitUntil {!alive s1};
waitUntil {alive s1};

sleep 0.001;

removeallweapons s1;
removeallitems s1;

sleep 0.001;
switch (true) do {
     case  (alive s2 && (damage s2) < 0.55) : {s1 setPos [ getpos s2 select 0, (getpos s2 select 1) + 2, getpos s2 select 2]};
     case  (alive s3 && (damage s3) < 0.55) : {s1 setPos [ getpos s3 select 0, (getpos s3 select 1) + 2, getpos s3 select 2]};
     case  (alive s4 && (damage s4) < 0.55) : {s1 setPos [ getpos s4 select 0, (getpos s4 select 1) + 2, getpos s4 select 2]};

default {_randomrespawn = [s1] execVM "respawn.sqf"};
               };//end switch case


};//end while

in the respawn.sqf script you have

_nul = _unit setPos (getPos _undeadpos);

it should be

_unit setPos (getPos _undeadpos);

Thank you, will fix it.

are you using http://forums.bistudio.com/showthread.php?121163-Script-not-working-Use-the-showScriptErrors-parameter!

it will display possible scripting errors.

Yes, I am, but it doesn't show any errors. same with the rpt file...

Share this post


Link to post
Share on other sites

Yes I had a typo myself in this line it should be

s1 setPos [ getpos s2 select 0, (getpos s2 select 1) + 3, getpos s2 select 2];

Share this post


Link to post
Share on other sites

The Switch cases work! Thank you!, but now I have a problem with the gear, and with the random respawn...

the respawn problem, the random respawn sometimes tell me with the hint "_sp = <null>", and it doesnt teleport... rare but happens.

the entire script, including Sel's fix:

while {true} do {
waitUntil {!alive s1};
waitUntil {alive s1};

sleep 0.001;

removeallweapons s1;
removeallitems s1;

sleep 0.001;

switch (true) do {
     case  (alive s2 && (damage s2) < 0.55) : {s1 setPos [ getpos s2 select 0, (getpos s2 select 1) + 2, getpos s2 select 2]; Hint "Rs2";};
     case  (alive s3 && (damage s3) < 0.55) : {s1 setPos [ getpos s3 select 0, (getpos s3 select 1) + 2, getpos s3 select 2]; Hint "Rs3";};
     case  (alive s4 && (damage s4) < 0.55) : {s1 setPos [ getpos s4 select 0, (getpos s4 select 1) + 2, getpos s4 select 2]; Hint "Rs4";};

   default {_randomrespawn = [s1] execVM "respawn.sqf"};
};//end switch case 

sleep 0.001;

s1 addweapon "ACE_Earplugs";
s1 addweapon "ACE_GlassesBalaklava";
s1 addweapon "ACE_GlassesLHD_glasses";
s1 addweapon "ACE_GlassesTactical";
s1 addweapon "ACRE_PRC343";
s1 addweapon "ACE_Map";
s1 addweapon "ItemCompass";
s1 addweapon "ItemGPS";
s1 addweapon "ItemWatch";
s1 addweapon "NVGoggles";
s1 addweapon "Binocular";
s1 addmagazine "HandGrenade_West";
s1 addmagazine "HandGrenade_West";
s1 addmagazine "SmokeShell";
s1 addmagazine "SmokeShell";
s1 addmagazine "SmokeShell";
s1 addweapon "ACE_Rucksack_MOLLE_DMARPAT";
s1 addmagazinecargo ["HandGrenade_West",2];
s1 addmagazinecargo ["SmokeShell",2];
s1 addmagazinecargo ["SmokeShellRed",1];
s1 addmagazinecargo ["SmokeShellBlue",1];
s1 addmagazinecargo ["IR_Strobe_Marker",1];
s1 addmagazinecargo ["ACE_Bandage",10];
s1 addmagazinecargo ["ACE_Tourniquet",2];
s1 addweapon "RH_m4a1aim";
s1 addmagazine "30Rnd_556x45_Stanag";
s1 addmagazine "30Rnd_556x45_Stanag";
s1 addmagazine "30Rnd_556x45_Stanag";
s1 addmagazine "30Rnd_556x45_Stanag";
s1 addmagazine "30Rnd_556x45_Stanag"; 
s1 addmagazine "30Rnd_556x45_Stanag";
s1 addmagazine "30Rnd_556x45_Stanag";
s1 addmagazinecargo ["30Rnd_556x45_Stanag",3];
s1 addweapon "RH_m9";
s1 addmagazine "15Rnd_9x19_M9";
s1 addmagazine "15Rnd_9x19_M9";
s1 addmagazine "15Rnd_9x19_M9";
s1 addmagazine "15Rnd_9x19_M9";
s1 addweapon "ACE_HuntIR_monitor";
};

Could you help me fix any mistakes of weapons\magazines? and the cargo things doesnt work...

Edited by Silderoy

Share this post


Link to post
Share on other sites

I think the problem is with the random number, your selecting numbers from 0-5 (0 to 5 is 6 numbers) but you only have 5 locations, I also think floor would be a better option.

_numb = floor (random 4);//0-4 = 5 numbers

Share this post


Link to post
Share on other sites
I think the problem is with the random number, your selecting numbers from 0-5 (0 to 5 is 6 numbers) but you only have 5 locations, I also think floor would be a better option.

_numb = floor (random 4);//0-4 = 5 numbers

would this work? so it chooses 0, 1, 2, 3 or 4, and cant be 5.

_numb = floor (random 4.99);

because _numb = floor (random 4); would make re5 allmost non active, as it would have to be 4 exactly in order to work.

_numb = floor (random 5); would be mostly good, but will have a very small chance to get 5, and thats a problem...

Share this post


Link to post
Share on other sites

I think I forgot to adjust for floor rounding down.

so _numb = floor (random 5) will chose between 0-4

I ran a few tests and it never picks 5, 4.9's seems to be the max number I found which when rounded down with floor is 4

Share this post


Link to post
Share on other sites
I think I forgot to adjust for floor rounding down.

so _numb = floor (random 5) will chose between 0-4

I ran a few tests and it never picks 5, 4.9's seems to be the max number I found which when rounded down with floor is 4

thanks!

and what about the gear? might have some addmagazine instead of addweapon and such, and the addmagazinecargo doesnt work.

Share this post


Link to post
Share on other sites

I don't have ACE so I can't help with that, just got trough then add a few at a time and see what happens.

Share this post


Link to post
Share on other sites

I fixed the gear problem. well script works perfect! now just 20 more duplicates... with many many (I calculated 1300!!) small changes :butbut:

Thanks for all the help Sel!

Edited by Silderoy

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  

×