Forum Jump :

Author Message


Posts: 33
Rank:


Level: Member

Country: de
Location: K-Town
Occupation: Medic
Age: 35
In-game name: Officer D

 
#1 Posted at 2017-02-10 10:12        
     
Hello helpers!

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.

This is what I got:

init.sqf
SpawnSelected = false;
publicVariable "SpawnSelected";

  true spawn {  
	waitUntil {player == player};
	true execVM "scripts\EH_handlers.sqf";

EH_handlers.sqf
player addEventHandler
[
	"respawn",
	{
	    CreateDialog "RespawnType";
            waitUntil {SpawnSelected = true};
	    // initiation scripts, etc. follow after this.
	}
];

player addEventHandler 
[
	"killed",
	{
		SpawnSelected = false;
	}
];
description.ext
class Header
{
  gameType = DM;
  minPlayers = 1;
  maxPlayers = 20;
};

author="Officer  D";
onLoadMission = "Utes Battlefield";
OnLoadMissionTime = 1;
loadScreen = "images\title_screen.paa";

respawn = "BASE";
respawndelay = 20;
// etc.

#include "dialog\dialog.cpp"
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

This post was edited by Officer D (2017-02-10 10:28, 248 days ago)


Author Message


Posts: 1189
Rank:


Level: Member

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

 
#2 Posted at 2017-02-10 10:26        
     
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.

#define getDamage getDammage

Advertisement


Author Message


Posts: 33
Rank:


Level: Member

Country: de
Location: K-Town
Occupation: Medic
Age: 35
In-game name: Officer D

 
#3 Posted at 2017-02-10 11:00        
     
Did I do something wrong? Nothing in the respawn EH happens now.

player addEventHandler ["Respawn", {
        spawn {
               createDialog "RespawnType";
               waitUntil {!dialog};
               if (local (_this select 0)) then {[] execVM "scripts\RandomSpawn.sqf"};
	       if (local (_this select 0)) then {[player] execVM "scripts\loadout_system.sqf"};
	       if (local (_this select 0)) then {[player] execVM "scripts\Max_healthstatusbar.sqf"};
	       (_this select 0) execVM "cam\intro_cam.sqf";
	       (_this select 0) execVM "scripts\SpawnPro.sqf";
        };
    }];


Author Message


Posts: 1189
Rank:


Level: Member

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

 
#4 Posted at 2017-02-10 11:08        
     
Why have all the local checks? `_this select 0` won't work there, you probably want to pass the `_this` array of the eh to the spawn like this:
player addEventHandler ["Respawn", {
    _this spawn {
        createDialog "RespawnType";
        waitUntil {!dialog};
        [] execVM "scripts\RandomSpawn.sqf";
        [player] execVM "scripts\loadout_system.sqf";
        [player] execVM "scripts\Max_healthstatusbar.sqf";
        (_this select 0) execVM "cam\intro_cam.sqf";
        (_this select 0) execVM "scripts\SpawnPro.sqf";
    };
}];

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.

#define getDamage getDammage

Author Message


Posts: 33
Rank:


Level: Member

Country: de
Location: K-Town
Occupation: Medic
Age: 35
In-game name: Officer D

 
#5 Posted at 2017-02-10 11:38        
     
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"}}];


Author Message


Posts: 1189
Rank:


Level: Member

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

 
#6 Posted at 2017-02-10 12:34        
     
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.

#define getDamage getDammage