Jump to content
Sign in to follow this  
Royal_Blackwatch

Init Eventhandler & MP

Recommended Posts

Hi everyone

Got another issue atm...

I have added this to my config:

Quote[/b] ]

class eventhandlers

{

init = _this exec "Infantry\data\script\init.sqs";

};

and have this testcode in my Script:

Quote[/b] ]

_plr = _this select 0

_plr2 = player

hint format ["%1, %2", _plr, _plr2]

exit

Now when I start the mission, I get the expected result ("East, Alpha...)

but when I respawn in MP I get no hint at all...

If I understood BIKI correct, the init eventhandler is persistent and should be launched when respawned, which it actually does because when I replace the hint text with a simple string, it is displayed after respawn.

I get no errormsg or something like that, it simply appears that the attached unit is not ported to the script after respawn.

Now can somebody please verify this being an ArmA issue or do I have a bad script? help.gif

Regards...

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_plr = _this select 0

_plr2 = player

hint format ["%1, %2", _plr, _plr2]

exit

Don’t know if your actual code is different from the sample you posted. But with that code, _plr2 ends up being assigned a null value on a client in MP.

Just in case and for the record, it should be:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_plr = _this select 0

~0.001

_plr2 = player

hint format ["%1, %2", _plr, _plr2]

exit

Quote[/b] ]If I understood BIKI correct, the init eventhandler is persistent and should be launched when respawned, which it actually does because when I replace the hint text with a simple string, it is displayed after respawn.

I get no errormsg or something like that, it simply appears that the attached unit is not ported to the script after respawn.

From the quick test I did, it looks as though the config init event will only be executed on the server after a respawn. You will have to use an additioanl method, to get your scripts running localy for each client when someone respawns.

BTW I'm running V1.08 and had the test mission’s decription.ext setup with:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">respawn=2

respawndelay=1

Share this post


Link to post
Share on other sites

Hi

thx, this at least gives me a hit in which direction I have to continue now. As you have assumed, the posted code was only for test purposes and is not the real script.

Gonna post here when I have dug some deeper into it smile_o.gif

regards

Share this post


Link to post
Share on other sites
Quote[/b] ]Gonna post here when I have dug some deeper into it

Please do, I've not done much with respawn scripts, curious to see what’s going on. I'm sure there will be some kicking about, perhaps they might help.

Share this post


Link to post
Share on other sites

There are additional event handlers around for onPlayerRespawn and the like.

Share this post


Link to post
Share on other sites

Init evenhandlers do not run again after respawn. It's as simple as that :-D

Every other eventhandler gets re-attached to a unit after respawn. But not Init eventhandlers.

Btw, may I suggest using XEH? (Extended Event Handlers Addon by Solus and Killswitch)

Share this post


Link to post
Share on other sites
Quote[/b] ]Init evenhandlers do not run again after respawn. It's as simple as that :-D

Well I can only talk about V1.08 with the respwan settings I mentioned above. But if you call this script from a config init event:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">If IsServer Then

       {

       MYTESTTIME=Time;

       PublicVariable "MYTESTTIME";

       };

Then setup a mission where you have a radio trigger executing this line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Hint Format ["Time %1",MYTESTTIME]

At the start of the mission, calling the radio triggers returns a hint value of 0. If wait a couple of seconds then select respawn from the menu, running the trigger again returns a value of 10. Keep repeating the steps to increment the hint value, after each respawn. I should point out that this only applies to players and not respawning AI.

To me that is enough evidence to say, the config init event is running on the server after each respawn.

Can't think of a simpler test than that, give it a try and see for yourself, it only takes five minutes to setup. Post back on how you get on.

I can post the test mission and addon for anyone else who is interested. It really is better to try these things out for yourself, and confirm things one way or another from multiple sources, rather than just taking someone’s word for it.

Share this post


Link to post
Share on other sites
I can post the test mission and addon for anyone else who is interested. It really is better to try these things out for yourself, and confirm things one way or another from multiple sources, rather than just taking someone’s word for it.

Please post the test mission/addon. I wouldn't mind taking a look at it.

Share this post


Link to post
Share on other sites
Init evenhandlers do not run again after respawn. It's as simple as that :-D

I read that they technically do but the reference to the original unit is changed by respawn?

Share this post


Link to post
Share on other sites

Here's the quick test mission I did, like I said it's only a basic test. The mission is setup with two triggers showing what’s returned via the players configs init event, for both the server and the client.

UNNMPInitTest.zip

Each time the server trigger, returns a reference to the newly respawned player. The local trigger just returns the reference from the first time the client joined the server.

From a mission editing point of view, there are probably better ways of keeping track of respawns than init events. I was interested in this because it could, in some cases, cause multiple copies of the same script, to be run on the server. If you weren’t aware that it was being fired on every respawn.

Share this post


Link to post
Share on other sites

Well this would either mean problems since v1.09 or for some reason my testing situation was for some reason not water tight.

I will look at your test mission and do some tests again, I find it very weird that it 'works' on your side. smile_o.gif

Thanks a lot for sharing though :-D Will get back to you after testing.

Quote[/b] ]From the quick test I did, it looks as though the config init event will only be executed on the server after a respawn
Hmm, I guess this is somehow the problem then, only working on server? Did you check Dedicated & Ingame Difference?

Share this post


Link to post
Share on other sites
Here's the quick test mission I did, like I said it's only a basic test. The mission is setup with two triggers showing what’s returned via the players configs init event, for both the server and the client.

UNNMPInitTest.zip

Each time the server trigger, returns a reference to the newly respawned player. The local trigger just returns the reference from the first time the client joined the server.

From a mission editing point of view, there are probably better ways of keeping track of respawns than init events. I was interested in this because it could, in some cases, cause multiple copies of the same script, to be run on the server. If you weren’t aware that it was being fired on every respawn.

Tried this but not entirely sure what results I'm looking for. Basically I'm seeing the same results after multiple respawns after hitting both radio commands.

This tells me if I'm understanding this correctly that no init events are re-firing after respawn. Am I reading this incorrectly.

This was performed using a NON dedicated server. Will test with a dedicated server next.

Ok, interesting. Dedicated server shows the respawn time increasing so it definitely is a different outcome than the NON dedicated server.

On closer inspection after looking at the mission I don't think this proves anything at all to do with inits. All you are doing is displaying LOCALTIME, LOCALUNIT, SERVERTIME, SERVERUNIT through a trigger and nothing else. I can't find reference to these in the BIKI so I'm not even sure what they are but basically it just looks like a reference to the time and unit on either the server or client. The results I get when running a dedicated server vs non dedicated server is potentially absolutely correct.

Again, this has nothing to do with INIT event handling. This test proves nothing there at all.

Share this post


Link to post
Share on other sites
Quote[/b] ]On closer inspection after looking at the mission I don't think this proves anything at all to do with inits. All you are doing is displaying LOCALTIME, LOCALUNIT, SERVERTIME, SERVERUNIT through a trigger and nothing else. I can't find reference to these in the BIKI so I'm not even sure what they are but basically it just looks like a reference to the time and unit on either the server or client. The results I get when running a dedicated server vs non dedicated server is potentially absolutely correct.

The mission is there just to display the content of certain global variables. LOCALUNIT, SERVERTIME and SERVERUNIT are all global variables initialised by this script:

Script.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Unit=_This Select 0;

If IsServer Then

       {

       SERVERTIME=Time;

       SERVERUNIT=_Unit;

       PublicVariable "SERVERTIME";

       PublicVariable "SERVERUNIT";

       }

       Else

       {

       LOCALTIME=Time;

       LOCALUNIT=_Unit;

       };

It creates a couple of variables on the server and clients. The server side variables are broadcasts to all the clients using the PublicVariable command. The script is launched using InitTest.pbo’s config init event handler.

InitTest.pbo:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class cfgVehicles

       {

       class SoldierWB;

       class InitTest : SoldierWB

               {

               Scope=2;

               DisplayName="My Test Soldier";

               class EventHandlers

                         {

                         init = "[_this select 0] Execvm ""\InitTest\Script.sqs""";

                         };

               };

       };

Quote[/b] ]Hmm, I guess this is somehow the problem then, only working on server? Did you check Dedicated & Ingame Difference?

Yeah, it could very well be just for dedicated servers, as I didn't test it with the ingame server.

Share this post


Link to post
Share on other sites

My bad, I didn't think of looking at the AddOn included in the example. I actually forgot it came with the mission. No wonder I couldn't find reference to these global variables. It must have been a late night when I looked at this.

Interesting to say the least then.

Share this post


Link to post
Share on other sites
Quote[/b] ]My bad, I didn't think of looking at the AddOn included in the example.

No worries, I should have included a better description of what was going on. Thanks for taking the time to try it out.

Quote[/b] ]Tried this but not entirely sure what results I'm looking for. Basically I'm seeing the same results after multiple respawns after hitting both radio commands.

This tells me if I'm understanding this correctly that no init events are re-firing after respawn. Am I reading this incorrectly.

This was performed using a NON dedicated server. Will test with a dedicated server next.

Ok, interesting. Dedicated server shows the respawn time increasing so it definitely is a different outcome than the NON dedicated server.

Yeah, that is a bit odd. I thought a server would behave the same, either way. But I suppose the main thing is to make sure your init event scripts account for potential respawns.

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
Sign in to follow this  

×