Forum Jump :

Author Message


Posts: 29
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-01-31 02:17        
     
Hi there. I'm making adjustments to the respawn mechanincs of a PvP bomb defusal mission I have recently made. Originally I only used
Respawn = 4 and
respawn templates[]={"ace spectator"}
Meaning that a player only has one life, and upon death they enter the ace spectator mode. Which worked fine
My issue now is that I am trying to use the "MenuInventory" respawn template as well so players can spawn in and select a pre defined loadout. This means I have to change to respawn = "Base". Which gives players unlimited lives and does not force them into the spectator mode.
Originally I could call the spectate function when a player dies, but the "MenuInventory" kills and respawns the player at the beginning of the mission, which would lead to the player going straight to spectator mode.
Any help is GREATLY appreciated


Author Message


Posts: 146
Rank:


Level: Member

Country: my
Location: Sabah
Occupation: No Occupations
Age: 18
In-game name: Phantom_Wolf

 
#2 Posted at 2016-01-31 03:23        
     
https://community.bistudio.com/wiki/Description.ext#respawnOnStart

respawnOnStart = -1;//Dont respawn on start. Don't run respawn script on start.

I don't know where you put the spectator code, but i recommend you put it in onPlayerRespawn.sqf in this case to make things easier.

Added 1 minute later:

On second thought, this might complicate things even more.

I don't know if the loadout respawn menu will ever run if you put it like that, unconfirmed on my side though, so should be worth a try.

I have no signature.

Advertisement


Author Message


Posts: 29
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2016-01-31 05:01        
     
Yea unfortunately it doesnt work. respawn on start = -1 will not call the menu inventory function. But when you die, it calls both the menuinventory template AND the onplayerrespawn. Bohemia is stupid for making the Menuinventory function require the player be killed first to use it.

An alternative is to just use a loadout script that isn't bohemia's MenuInventory and just put it on an object. But there arent ANY out there that have predefined loadouts that tell you what is part of that loadout. I dont want to use something like the virtual arsenal becuase people stuff around and take too long when deciding what weapons and other objects they want.

I just want a loadout script that says. These are loadouts a b and c. This is what is in a b and C. No changing


Author Message


Posts: 146
Rank:


Level: Member

Country: my
Location: Sabah
Occupation: No Occupations
Age: 18
In-game name: Phantom_Wolf

 
#4 Posted at 2016-01-31 05:13        
     
Okay i think i got an alternative.

Run this on init.sqf for server or initPlayerLocal.sqf for non-server.

nul = [] spawn {waitUntil {!alive player}; waitUntil {alive player}; waitUntil {!alive player}; waitUntil {alive player}; CODE HERE};

Should wait until menu shows up, waits until player spawns, wait until player dies, wait until player respawned then execute spectator script. It is local by the way so it won't affect other players. PS: You don't need to use spawn command, but i recommend it so the whole script doesn't hang.

I have no signature.

Author Message


Posts: 29
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2016-01-31 05:36        
     
^ Hmm that half works. What happens is you 1.start the mission and are at the gear selector. 2.You spawn. 3. You die and the spectate script is called. 4. the gear selector is called again because "description.ext" respawntemplates[]="menuinventory" realises you have died.

I wonder if I could remove "menuinventory" and have a blank template. Then add the function into the code above

nul = [] spawn {waitUntil {!alive player}; MENUFUNCTION; waitUntil {alive player}; waitUntil {!alive player}; waitUntil {alive player}; ace_spectator_fnc_setSpectator};

Unfortunately I cant find the actual function that the "menuinventory" calls anywhere on the bohemia wiki

Added 1 minute later:

Maybe it's BIS_fnc_respawnMenuInventory


Author Message


Posts: 146
Rank:


Level: Member

Country: my
Location: Sabah
Occupation: No Occupations
Age: 18
In-game name: Phantom_Wolf

 
#6 Posted at 2016-01-31 06:12        
     
Confirmed, checked the MenuInventory config on cfgRespawnTemplates and it indeed executes said function.

A method would be to 'fake' that revive system is on, as you can see there's an if command with exitWith if that happens on top. Another method would be to find the GUI entry and force it to disable.

It executes BIS_fnc_showRespawnMenu. Found an interesting line of code:

	(uinamespace getvariable ["RscDisplayRespawn_display",displaynull]) closedisplay -1;

Might or might not work, i'm not good at GUIs.

Added 3 minutes later:

Maybe you could call BIS_fnc_respawnMenuInventory as code in between the waitUntil and delete MenuInventory template on description.ext.

I have no signature.

Author Message


Posts: 29
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2016-01-31 06:33        
     
Yea thats what I thought.
I've got
nul = [] spawn {waitUntil {!alive player}; BIS_fnc_respawnMenuInventory; waitUntil {alive player}; waitUntil {!alive player}; waitUntil {alive player};

But thats not currently working. Im slowly moving the BIS_fnc_respawnMenuInventory around to get it in the right place -_- haha

Added 5 minutes later:

Im going to try call the function BIS_fnc_showRespawnMenu and BIS_fnc_respawnMenuInventory in onplayerkilled.sqf to see which one works

This post was edited by danjoo (2016-01-31 06:39, 681 days ago)


Author Message


Posts: 146
Rank:


Level: Member

Country: my
Location: Sabah
Occupation: No Occupations
Age: 18
In-game name: Phantom_Wolf

 
#8 Posted at 2016-01-31 06:39        
     
You mean,

[] call BIS_fnc_respawnMenuInventory;

?

I have no signature.

Author Message


Posts: 29
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#9 Posted at 2016-01-31 06:45        
     
[] call BIS_fnc_respawnMenuInventory; in OnPlayerRespawn doesnt call the menu :(

Added 11 minutes later:

nul = [] spawn {waitUntil {!alive player}; waitUntil {alive player}; waitUntil {!alive player}; BIS_fnc_respawnMenuInventory};

and nul = [] spawn {waitUntil {!alive player}; waitUntil {alive player}; waitUntil {!alive player}; BIS_fnc_showRespawnMenu};

Dont work. Even though....

nul = [] spawn {waitUntil {!alive player};waitUntil {alive player}; waitUntil {!alive player}; waitUntil {alive player}; ace_spectator_fnc_setSpectator;};

Works fine. Had to remove the last waitUntil (alive player); because the inventory meny can only be accessed when dead.

So even when BIS_fnc_showRespawnMenu or BIS_fnc_respawnMenuInventory are being called. They dont actually seem to work once i've died

Added 7 minutes later:

call BIS_fnc_showRespawnMenu; worked for the first spawn at mission start but is telling me to disable serialzation because '_parent does not support serialization'

Added 8 minutes later:

onplayerkilled.sqf works
disableserialization;
call BIS_fnc_respawnMenuInventory;
call BIS_fnc_showRespawnMenu;

Added 4 minutes later:

Now I think i should make an external script called in the init.sqf and call it. Something like

disableserialization;
null = {waituntil {!alive player};
call BIS_fnc_respawnMenuInventory;
call BIS_fnc_showRespawnMenu;
waitUntil {alive player};
waitUntil {!alive player};
waitUnitl {alive player};
call ace_spectator_fnc_setSpectator;};

Added 26 minutes later:

Gonna have a break for a while nothing is working. I do know that BIS_fnc_showRespawnMenu and BIS_fnc_respawnMenuInventory can be called in onplayerkilled.sqf

This post was edited by danjoo (2016-01-31 07:46, 681 days ago)


Author Message


Posts: 146
Rank:


Level: Member

Country: my
Location: Sabah
Occupation: No Occupations
Age: 18
In-game name: Phantom_Wolf

 
#10 Posted at 2016-01-31 08:25        
     
First, make sure you already DISABLED THE TEMPLATE IN DESCRIPTION.EXT!

nul = spawn {
disableserialization;
null = {waituntil {!alive player};
call BIS_fnc_respawnMenuInventory;
call BIS_fnc_showRespawnMenu;
waitUntil {alive player};
waitUntil {!alive player};
waitUnitl {alive player};
call ace_spectator_fnc_setSpectator;

};

But i don't think you need to call showRespawnMenu, because a look at respawnMenuInventory shows that there is a code that calls showRespawnMenu.

On the other hand, using the spawn command is a great way to 'start a new script' without another SQF. For example, if i want to make a very short script to run when the player dies in the init, i could use spawn instead of making an SQF and using execVM. The spawn command also does not interfere with the script meaning if you put spawn on top of your init and a delay inside spawn, the script inside spawn will wait, while the rest of the init loads normally.

I have no signature.

Author Message


Posts: 1189
Rank:


Level: Member

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

 
#11 Posted at 2016-01-31 10:44        
     
BIS_fnc_respawnMenuInventory uses both disableSerialization and BIS_fnc_showRespawnMenu, it also needs a unit as a parameter, such as this:
[player] call BIS_fnc_respawnMenuInventory;

Problem is, once it's called, the menu shows up in every respawn, haven't found a way to show it only once somehow.

Here is what I have:
if (hasInterface) then {
	[west, "WEST1"] call BIS_fnc_addRespawnInventory;
	[player] call BIS_fnc_respawnMenuInventory;
	player addEventHandler ["Respawn", {
		//Close the respawn menu here somehow
		hint "SPECTATOR";
		//[] call ace_spectator_fnc_setSpectator;
	}];
};

Players still get the loadout selection screen, but when they click "Spawn", they're switched to spectators. Removing the template from description.ext makes it so it doesn't even show up in the first place.

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: 29
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#12 Posted at 2016-02-01 02:17        
     
Alright so far if i have this in the init. It calls the menu
nul = [] spawn {waitUntil {!alive player}; 
[player] call BIS_fnc_respawnMenuInventory;};

The thing is once you click spawn it doesn't actually spawn you with the actual loadout. It seems like it's missing a function to actually remove current items and add the new ones.

Once that is solved, I think the next thing to do is to just call a script that waits for you to die a second time before calling the spectator script.
I have no idea how to see what other functions is calling BIS_fnc_respawnMenuInventory, but Phantom_wolf seems to be good at that XD

Added 23 minutes later:

ok so it turns out if I use
[player] call BIS_fnc_respawnMenuInventory;
after i've already selected my loadout in the menu...it magically adds the gear. So what I did was just add a crate with
this addAction ["Confrim Loadout", {[player] call BIS_fnc_respawnMenuInventory;}];
The initial 2 lines of code
nul = [] spawn {waitUntil {!alive player}; 
[player] call BIS_fnc_respawnMenuInventory;};
Still need to be in the init, otherwerwise the scroll wheel action obviously won't work on the new crate.

We are so close guys! Hopefully phantom_wolf's inital code where it waits for the player to be killed a second time can just be added.

I've also moved the code from the init to an external .sqf, leaving it in the init causes the rest of the code below the waituntil to not run in my mission (I have further code adding markers etc)

Added 12 minutes later:

The code below isn't calling the spectate script on the second death :( Any suggestions.
nul = [] spawn 
{
waitUntil {!alive player};  //Initial death thanks to respawnonstart = 1; This lets us call the loadout menu
[player] call BIS_fnc_respawnMenuInventory; //Calling the loadout menu
waituntil (alive player);// Waits until the player is alive
waituntil (!alive player); //Waits until player has first offical death
waituntil (alive player); //Waits for the player to respawn
call ace_spectator_fnc_setSpectator; //Calls the spectate function
};

Added 5 hours 45 minutes later:

UPDATE

Ok so I have a clunky version working!!!!!!!!!!!!!!

SQF Executed from Init:
nul = [] spawn 
{
waitUntil {!alive player};  //Initial death thanks to respawnonstart = 1; This lets us call the loadout menu
[player] call BIS_fnc_respawnMenuInventory; //Calling the loadout menu
["spectate.sqf","BIS_fnc_execVM",true,true] spawn BIS_fnc_MP; //Load other script that waits for unit's second death
};

Spectate.sqf called by above script:
sleep 30; //Wait 30 seconds so the spectate function isn't called straight away whilst choosing loadout
nul = [] spawn 
{
waitUntil {!alive player};   //Wait for player to die in combat
call ace_spectator_fnc_setSpectator; //Send user to spectator mode
};

Unfortunately after the specate script is called, the player still respawns back at the BASE. I dont know how to disable the respawn after the intial death. So i think I will just wait for the player to die, then teleport the player to somewhere far away from the starting area.

This post was edited by danjoo (2016-02-01 08:40, 680 days ago)