Fist off, this is for Arma 2 OA not Arma 3, since so far every time I posted my problems I've gotten solutions that are Arma 3 specific. Just a heads up ;)
So I'm trying to get a "How would you like to respawn" script to work. You have the option to select between ground or parachute. I've gotten far enough to have the dialog screen pop up on respawn. Keep in mind, this is not suppose to happen in the beginning of the mission. Only when the player is killed and respawns.
What happens is, the respawn event handler doesn't wait. It just goes through the other initiation scripts. I want it to first continue after the action = "closeDialog 0; in the dialog.cpp
Any simple solutions would be appreciated.
dialog.cpp
class RespawnType {
idd = RESPAWN_TYPE_IDD;
movingEnable = 1;
onLoad = "";
class controlsBackground {
class Bkrnd {
type = CT_STATIC;
idc = UNDEFINED_IDC;
style = ST_HUD_BACKGROUND;
font = FontM;
colorText[] = { 1, 1, 1, 1 };
colorBackground[] = {0.0353,0.0588,0.0000,0.6235};
sizeEx = 0.028;
text = "";
x = 0.388542 * safezoneW + safezoneX;
y = 0.225 * safezoneH + safezoneY;
w = 0.223854 * safezoneW;
h = 0.37463 * safezoneH;
};
};
objects[] = { };
class controls {
class PopupText : RscStaticText {
type = CT_STATIC;
style = ST_CENTER;
text = "How would you like to respawn?";
font = FontM;
sizeEx = 0.028;
colorBackground[] = { 0, 0, 0, 0 };
colorText[] = { 1, 1, 1, 1 };
x = 0.391146 * safezoneW + safezoneX;
y = 0.478703 * safezoneH + safezoneY;
w = 0.218646 * safezoneW;
h = 0.0283333 * safezoneH;
};
class respawn_picture: RscPicture
{
idc = -1;
text = "images\spawntype.paa";
x = 0.404687 * safezoneW + safezoneX;
y = 0.254629 * safezoneH + safezoneY;
w = 0.191562 * safezoneW;
h = 0.202407 * safezoneH;
};
class btnYes : RscButton {
sizeEx = 0.028;
colorText[] = { 1, 1, 1, 1 };
colorBackground[] = {0.2157,0.2980,0.0000,1.0000};
x = 0.439062 * safezoneW + safezoneX;
y = 0.530556 * safezoneH + safezoneY;
w = 0.043125 * safezoneW;
h = 0.0375926 * safezoneH;
text = "Ground";
action = "closeDialog 0; SpawnSelected = true;";
};
class btnNo : RscButton {
sizeEx = 0.028;
colorText[] = { 1, 1, 1, 1 };
colorBackground[] = {0.2157,0.2980,0.0000,1.0000};
x = 0.517188 * safezoneW + safezoneX;
y = 0.530556 * safezoneH + safezoneY;
w = 0.043125 * safezoneW;
h = 0.0375926 * safezoneH;
text = "Air";
action = "closeDialog 0; SpawnSelected = true; [Player] execVM ""scripts\Halodrop.sqf""";
};
};
};
This post was edited by Officer D (2017-02-10 10:28, ago)
Your respawn eh isn't pausing because event handlers run in the unscheduled environment. Spawn the code, and use the dialog command instead of dealing with your own variable.
player addEventHandler ["Respawn", {
spawn {
createDialog "RespawnType";
waitUntil {!dialog};
// Do whatever
};
}];
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.
FYI: Even now, `(_this select 0)` is the same as `player`. You should stick to just one. Doesn't matter which, pick it and stay consistent. Future you will be thankful :D.
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.
Brilliant! It seems to work now. Thanks for the info and the examples. Much appreciated!
I believe the local checks where recommended by you on the other thread I opened, regarding respawning on a dedicated server and checking if players are near. For some reason it was executing the script for all players on the map.
#654wak654 :
It might be because you're adding the EH to all units, for all units. Change your current Respawn EH to this:
player addEventHandler ["Respawn", {if (local (_this select 0)) then {[] execVM "scripts\RandomSpawn.sqf"}}];
Think I suggested that because you had the respawn eh in units' init fields. Code in the init box runs seperately on all machines, that's why a check was needed. This time you're executing the code from the init.sqf, so we know the code runs only on the local computer.
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.