Forum Jump :

Author Message


Posts: 55
Rank:


Level: Member

Country: de
Location: Hamburg
Occupation:
Age: 20
In-game name: Nerodenecro

 
#1 Posted at 2015-10-28 19:25        
     
Hey guys,

I am currently this inside my Init.sqf
[] spawn {
while{not isnull Player1} do {"respawn_west_1" setmarkerpos getpos Player1; sleep 0.5;};
};
[] spawn {
while{not isnull Player2} do {"respawn_west_2" setmarkerpos getpos Player2; sleep 0.5;};
};
[] spawn {
while{not isnull Player3} do {"respawn_west_3" setmarkerpos getpos Player3; sleep 0.5;};
};
[] spawn {
while{not isnull Player4} do {"respawn_west_4" setmarkerpos getpos Player4; sleep 0.5;};
};

Obviously the Mission is for 4 Players.
So I want to improve this whole thing, the problem: I got the idea but not the Script skills.

My ideas.

Currently you can respawn on yourself an also on dead Players, which I don't want.
Well this is right now all I want, since that's the most importnant.

Thanks in advanced.

Regards,

Nerodenecro


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2015-10-28 20:49        
     
I don't know how respawn with multiple markers work. I hope deleting the marker makes it so it disables respawn, I've made this with that assumption:
spawn {
	while {true} do {
		{
			_mkr = format ["respawn_west_%1", (vehicleVarName _x) select [6]];
			if (alive _x) then {
				if (getMarkerColor _mkr == "") then {
					createMarker [_mkr, getPos _x];
				};
				_mkr setMarkerPos getPos _x;
			} else {
				if (getMarkerColor _mkr != "") then {
					deleteMarker _mkr;
				};
			};
		} forEach [Player1, Player2, Player3, Player4];
		sleep 0.5;
	};
};

If player is alive and there is no respawn marker, it creates it and positions it at the player.
If player is not alive and there is a marker, it deletes it.

That's pretty much all you need.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Advertisement


Author Message


Posts: 55
Rank:


Level: Member

Country: de
Location: Hamburg
Occupation:
Age: 20
In-game name: Nerodenecro

 
#3 Posted at 2015-10-28 21:07        
     
Hey wak,

you can choose a respawn position if you have the following in the description.ext
respawnTemplatesWest[] = {"MenuPosition"};

Thanks for the reply, I give it a try in some minutes.

Ah forgot. If Player1 dies, his respawn point(respawn_west_1 is suppost to disappear but if he respawns, it's suppost to be back.

Regards,

Nerodenecro


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#4 Posted at 2015-10-28 22:19        
     
# Nerodenecro :
Ah forgot. If Player1 dies, his respawn point(respawn_west_1 is suppost to disappear but if he respawns, it's suppost to be back.

That's what I tried to do:
# 654wak654 :
If player is alive and there is no respawn marker, it creates it and positions it at the player.
If player is not alive and there is a marker, it deletes it.
This happens in a loop.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 55
Rank:


Level: Member

Country: de
Location: Hamburg
Occupation:
Age: 20
In-game name: Nerodenecro

 
#5 Posted at 2015-10-28 22:33        
     
Hey wak,

looks like I didn't read problerly, sorry for that.
Will try it tomorrow probaly, pretty sure it's gonna work.

Regards,

Nerodenecro

Added 13 hours 15 minutes later:

Hey wak,

I ran over the following issue.


Link if Image doesn't work


Code which I am currently using in my Init.sqf for the Spawn.
[] spawn {
while{not isnull Player1} do {"respawn_west_1" setmarkerpos getpos Player1; sleep 0.5;};
};
[] spawn {
while{not isnull Player2} do {"respawn_west_2" setmarkerpos getpos Player2; sleep 0.5;};
};
[] spawn {
while{not isnull Player3} do {"respawn_west_3" setmarkerpos getpos Player3; sleep 0.5;};
};
[] spawn {
while{not isnull Player4} do {"respawn_west_4" setmarkerpos getpos Player4; sleep 0.5;};
};
spawn {
    while {true} do {
        {
            _mkr = format ["respawn_west_%1", (vehicleVarName _x) select [6]];
            if (alive _x) then {
                if (getMarkerColor _mkr == "") then {
                    createMarker [_mkr, getPos _x];
                };
                _mkr setMarkerPos getPos _x;
            } else {
                if (getMarkerColor _mkr != "") then {
                    deleteMarker _mkr;
                };
            };
        } forEach [Player1, Player2, Player3, Player4];
        sleep 0.5;
    };
};

Hope you can help me with this.

Regards,

Nerodenecro

This post was edited by Nerodenecro (2015-10-29 11:48, 777 days ago)


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#6 Posted at 2015-10-29 15:19        
     
Why did you keep your own code? Mine does the repositioning too.

The spawn command was missing the [] before itself, didn't know arma could fail at that. Also added isServer check.

if (isServer) then {
	[] spawn {
		while {true} do {
			{
				_mkr = format ["respawn_west_%1", (vehicleVarName _x) select [6]];
				if (alive _x) then {
					if (getMarkerColor _mkr == "") then {
						createMarker [_mkr, getPos _x];
					};
					_mkr setMarkerPos getPos _x;
				} else {
					if (getMarkerColor _mkr != "") then {
						deleteMarker _mkr;
					};
				};
			} forEach [Player1, Player2, Player3, Player4];
			sleep 0.5;
		};
	};
};

This post was edited by 654wak654 (2015-10-29 15:28, 776 days ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 55
Rank:


Level: Member

Country: de
Location: Hamburg
Occupation:
Age: 20
In-game name: Nerodenecro

 
#7 Posted at 2015-10-29 18:26        
     
Hey wak,

gonna try it in a few minutes. Pretty sure it's gonna work now :P
Thanks so far.

Regards,

Nerodenecro

Added 7 minutes later:

Hey wak,

I am still able to respawn on myself, when I died.
Also I am able to respawn on others when they're dead.

Regards,

Nerodenecro

This post was edited by Nerodenecro (2015-10-29 18:33, 776 days ago)


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#8 Posted at 2015-10-30 08:02        
     
Last try, if it doesn't work I have no idea how to do this with the default respawn templates. I feel like BI isn't checking if that markers exists or not as fast as the script.

[] spawn {
	if (!isServer) exitWith {};
	while {true} do {
		{
			_mkr = format ["respawn_west_%1", _forEachIndex + 1];
			if (alive _x) then {
				if (getMarkerColor _mkr == "") then {
					createMarker [_mkr, getPos _x];
				};
				_mkr setMarkerPos getPos _x;
			} else {
				if (getMarkerColor _mkr != "") then {
					deleteMarker _mkr;
				};
			};
		} forEach [Player1, Player2, Player3, Player4];
		sleep 0.5;
	};
};

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 55
Rank:


Level: Member

Country: de
Location: Hamburg
Occupation:
Age: 20
In-game name: Nerodenecro

 
#9 Posted at 2015-10-30 19:31        
     
Hey wak,

tried it. No Error message but it's like there's nothing running.
Basicly like the game is running as usual.

Looks like the script is faster than BI :D

Regards,

Nerodenecro


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#10 Posted at 2015-10-31 16:32        
     
The problem could come from your choice in config.cpp or description.ext. When you respawn playable units (or players) They are not dead. In fact status always changes for alive (playing in game), dead (very momentarily), alive (time to be healed by a fellow), dead (if suicide or recovery time elapsed), alive if healed or respawned.
Along with that, dead position travels to [0,0,0] (and you can find your marker here depending on what you script).

I place i my description.ext:
respawn = 3; // base (always useful with a safe place, + positions only if modified by init sqf)
respawnDelay = 10;
respawnDialog = 1;
respawnTemplates[]= {"Counter","Menuposition"};
respawnonstart = -1;

and in init.sqf:

if (!isServer) exitwith {};
{_x setvariable ["mark_unit",_foreachindex];
}foreach playableUnits+switchableUnits; // Treat also possible JIP

{_x addMPEventHandler ["MPkilled", {
_unit = _this select 0;
if (!isPlayer _unit) exitWith {removeSwitchableUnit _unit}; // compulsory , i don't like AI respawns
{
deleteMarkerLocal format ["respawn_west_i%1", _x getVariable "mark_unit"]; // always use local markers!
if (alive _x) then { // added for you if you don't want to have dead men position for spawning
_mark = createMarkerLocal [format ["respawn_west_i%1", _x getVariable "mark_unit"],getPosATL _x];
  _mark setMarkerTypeLocal "empty"; //or "selector_selectable"
  _mark setMarkerTextLocal (name _x);
  0 = [_x, _mark] spawn {while {true} do { // loop to refresh positions
  _unit = _this select 0;
  _marker = _this select 1;
  _marker setMarkerPosLocal (getPosATL _unit);
  }; // end if
  sleep 0.5;
  };
  };
} forEach playableUnits + switchableUnits - [player];// exclude player itself then treat player apart:

deleteMarkerLocal format ["respawn_west_i%1", player getVariable "mark_unit"];
_mark2 = createMarkerLocal [format ["respawn_west_i%1", player getVariable "mark_unit"],getPosATL player];
  _mark2 setMarkerTypeLocal "empty"; //"selector_selectable"
  _mark2 setMarkerTextLocal (name player);
  _mark2 setMarkerPosLocal (getPosATL player);
}]} forEach playableUnits + switchableUnits;

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS