Jump to content
treoctone

Passing Variable to Debriefing

Recommended Posts

I have been stuck on this and have exhausted what I feel like is every different scenario. I am trying to have a variable display in the endmission debriefing, but nothing is working. As always any help is greatly appreciated. I feel the result is easy, but I can't wrap my noob head around it.

This guy got it to work, but how is a mystery to me.

SQF

killz = 4;

player addEventHandler ["HandleDamage", {
if (_this select 2 >= 1) then {
endMission "enddeath" call BIS_fnc_endMission; }; // tried "Loot" instead of endeath and it gives mission completed.
}];

missionnamespace setvariable ["killz", str(killz)];
getkillz = missionNameSpace getvariable "killz"; // tried using both local and global variables for killz and getkillz.

Description

class cfgDebriefing
{
class Enddeath
{
	title = "Defeat";
	Description = "blah" ;


}; 

class CfgDebriefingSections
{
class Loot //tried changing this to enddeath as well. 
{
	title = "Total number of kills";
	getkillz = missionNameSpace getvariable str(killz); //tried this as variable = missionnam...
};
};

};

Edited by Treoctone

Share this post


Link to post
Share on other sites

//DESCRIPTION.EXT
class cfgDebriefing
{
class Enddeath
{
	title = "Defeat";
	Description = "blah";
};
};

class CfgDebriefingSections
{
class Loot
{
	title = "Total number of kills";
	variable = "killz";
};
};

//INIT.SQF
killz = str 4;

"enddeath" call BIS_fnc_endMission;

Share this post


Link to post
Share on other sites

Thanks for the reply Larrow. I tested this out removing the endmission from the start of the BIS_fnc_EndMission and placing it in init.sqf, but without it when my player dies it just gives me the default "you died" screen. Putting the below code into init.sqf gives me the same result as it did before. I'll mess around with it some more, but this mission is being coded to end on the players death which is why i have the eventhandler added.

//init.sqf
player addEventHandler ["HandleDamage", {
if (_this select 2 >= 1) then {
endmission "enddeath" call BIS_fnc_endmission };
}];

Edit:

I finally got it to work. I needed to add the missionnamespace setvariable into a while {true} loop since my intention is to be able to change that variable depending on kills any way. I had originally had a killz = 0 variable in my init.sqf, but realized with the below code it was not necessary. Updated and working code below.

//SQF file
killz = 0;
if (isDedicated) exitWith {};
waitUntil {!(isNull player)};

player addEventHandler ["HandleDamage",
{
if (_this select 2 >= 1) then
{
	endmission"enddeath" call BIS_fnc_endmission 
};
}];

while {true} do
{
missionnamespace setvariable ["killzSet", str(killz)];
sleep 1;	
};

//Description
class cfgDebriefing
{
class Enddeath
{
	title = "Defeat";
	Description = "blah";		
}; 
};	

class CfgDebriefingSections
{
class Loot
{
	title = "Total number of kills";
	variable = "killzSet";
};
};

Edited by Treoctone

Share this post


Link to post
Share on other sites

Edit : got it to work, solution in the post below

Hi, I'm new to scripting (just started yesterday) and I'm trying to make a Deathmatch (Free For All, not in teams).
I got everything to work, but now I'm trying to put the name of the winner in the debriefing and I can't get it to work.
This forum post is the only information I could find, and idk if anybody's going to respond because its been 7 years, but here's what I did:
This is my init.sql :

if(isServer) then {

	unitKilled = {
		{
			_x addPlayerScores [2,0,0,0,0]; //Add 1 kill to the player (2 because killing a friendly is -1 (this is deathmatch, everybody is on the same side))
			_playerScore = score _x;
			if (_playerScore == 2) then { 
				missionnamespace setvariable ["winnerName", name _x];
				//_myStringValue = missionNamespace getVariable "winnerName";
				//hint _myStringValue; // This is working, and returns the player name
				"endDM" call BIS_fnc_endMission;
			};
		} forEach allPlayers;
	};
	
	{
		_x addEventHandler ["killed", unitKilled];
	} forEach allUnits;
};

As you can see, when a player reaches 2 kills, I pass his name to the missionNamespace "winnerName" before ending the mission.
The hint is working as intended, and returns the player's name from the missionNamespace.


However, when I'm trying to use it in my Description.ext, it doesn't work anymore:

class CfgDebriefing
{
	class endDM
	{
		variable = winnerName;
		title = "End of game"; //Line 25
		subtitle  = "Winner: "+variable;
		description = variable+" got 20 kills.";
		pictureBackground = "credits.jpg";
	};
};

 This basically doesn't work, giving me the following error:
description.ext, line 25: 'CfgDebiefing/endDM.': '+' encountered instead of '='.

Why can it not concatenate variable to another string ? I tried to do it before and store it in a variable, then saying "subtitle = subtitleText" but I get the same error.
Trying to display "variable" with hint tells me it found 'v' instead of '='.
I don't understand why its not working, because when I hint the value of the missionNamespace in init.sqf it works !


Apparently what fixed it for you was to update it in a while loop, but I can't do that because it only decides the winner at the end of the game !
Someone please help 😞

Share this post


Link to post
Share on other sites

Figured it out, it works just fine with the setDebriefingText function:

if(isServer) then {

	unitKilled = {
		{
			_x addPlayerScores [2,0,0,0,0]; //Add 1 kill to the player (2 because killing a friendly is -1 (this is deathmatch, everybody is on the same side))
			_playerScore = score _x;
			if (_playerScore == 2) then { 
				"endDM" setDebriefingText ["End of match", name _x + " got 20 kills.", "Winner: " + name _x]; // this is the magic part
				"endDM" call BIS_fnc_endMission; // just end the match
			};
		} forEach allPlayers;
	};
	
	{
		_x addEventHandler ["killed", unitKilled];
	} forEach allUnits;
};

And the description doesn't need to be longer than this:

class CfgDebriefing
{
	class endDM
	{
		title = "End of game";
		subtitle  = "Someone got 20 kills.";
		pictureBackground = "credits.jpg";
	};
};

title and subtitle will be overwritten by setDebriefingText, but are needed if you want the overwritten text to appear on the player's UI when ending the mission.

Its kinda hard to explain so here's some screenshots :

Without setting up the subtitle in CfgDebriefing:

ZofjwUi.jpeg

Subtitle in CfgDebriefing (it can be whatever you want, cause setDebriefingText will override it, you're just saying if you want it to display "in-game" or not😞a3zkNgS.jpeg

 

Note that in both cases, you will see the subtitle in this ending screen, even if not setting it up in CfgDebriefing :GJ612dY.jpeg

Maybe this will help someone someday...

  • Like 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

×