Jump to content
Sign in to follow this  
nullsystems

eventhandler problems...

Recommended Posts

Hi,

I placed this in the init.sqf

player addEventHandler ["fired", {[player] execVM "fired.sqf"}];

After an hour or so, I reconnected and it no longer worked.

Any idea why?

Does this need to be in the players init line from the editor?

Share this post


Link to post
Share on other sites

Welcome to the problems of join in progress =]

Quick questions to help diagnosis:

1. Is your eventhandler intended to work after player respawn?

2. Does it work after respawn?

3. Does it work for JIP players other than you?

4. Does the problem arise on dedicated or hosted servers or both?

5. Please insert your entire init.sqf using code tags so we can mull over it and make tutting noises while shaking our heads like car mechanics before announcing "It'll cost ya..."

Share this post


Link to post
Share on other sites
Welcome to the problems of join in progress =]

Quick questions to help diagnosis:

1. Is your eventhandler intended to work after player respawn?

2. Does it work after respawn?

3. Does it work for JIP players other than you?

4. Does the problem arise on dedicated or hosted servers or both?

5. Please insert your entire init.sqf using code tags so we can mull over it and make tutting noises while shaking our heads like car mechanics before announcing "It'll cost ya..."

1. Yes

2. Works fine after respawn

3. I have no idea if players already connected from mission start have this problem after new players connect.

4. Dedicated tested only.

5.

setViewDistance 1600;

waitUntil {local player};

sleep 0.001;

firecount = 0;

player addEventHandler ["fired", {[player] execVM "KHPack\fired.sqf"}];

if (true) exitWith {};

firecount is counted from the fired.sqf script. If it is 3, the script continues.

The script works perfectly fine, no problems. However, I suspect its either because I have "player" in the init, or because I have "firecount = 0"; Which if (>3) then it continues to some other stuff.

Without complaining about my fired.sqf script, would the above script work fine for JIP ?

It works fine right now, but as I say, after connecting to a mission which has already started, it doesnt work.

Edited by nullsystems

Share this post


Link to post
Share on other sites

Sounds like JIP problem. It doesn't add the eventHandler to units created after mission start. I don't know how to solve on my feet, but I know I've seen solutions on this forum to track/remember the name/ID of units when they respawn.

Share this post


Link to post
Share on other sites

Sometimes the Init.sqf wont be executed on JIP (looks like 2-4 hours of running missions).

Can you check if just the handler dont get added or the whole init.sqf code is missing after jip?

Share this post


Link to post
Share on other sites

firecount = 0 is a bit dodgy in init.sqf because it will set the global variable to 0 every time a client runs init/sqf (eg, every time a JIP player joins).

The waituntil {local player} should work fine, but I normally use this instead:

//=============== PLAYER SYNC ====================================

if ( (!isServer) && (player != player) ) then
{
   waitUntil {player == player};
   waitUntil {time > 10};
};

//============= END OF PLAYER SYNC ===============================

what is firecount actually counting? If it's something like an ammo count or artillery rounds, it would nice to know whether you want it to be a personal thing for each player or a global thing for the mission.

eg firecount increases by 1 for a client when detonating a satchel charge, but not for everyone else

vs firecount increases by 1 for all players when an artillery barrage is launched by any player

Share this post


Link to post
Share on other sites

firecount is personal to the user.

It counts how many times they have fired.

So, whats the solution then ?

Would the addeventhandler work fine if I just placed it in the units init from the editor?

What im thinking is:

Since the init file is executed for every unit when they connect...

If you have AI on the mission from the start, surely they execute the init too?

Which means the fired eventhandler is being added to the AI unit...

And when you connect into that slot, the fired eventhandler cannot be re-added to you?

---------- Post added at 05:47 PM ---------- Previous post was at 03:52 PM ----------

Here is my current new init.sqf

Both the addeventhandler and AIConSolve.sqf script do not fire when a new player connects...this can be from 30 seconds after start to hours.

setViewDistance 1600;

//Time 
if (!isNil "param1") then {
switch (param1) do {
	case 1: {skipTime 6};
	case 2: {skipTime 12};
	case 3: {skipTime 15;0 setOvercast 0.5;0 setRain 0};
	case 4: {skipTime 24;0 setOvercast 0.69;0 setRain 0};
};
} else {
skipTime 12;
};

if ( (!isServer) && (player != player) ) then
{
waitUntil {player == player};
waitUntil {time > 10};
};


sleep 0.1;
firecount = 0;
player addEventHandler ["fired", {[player] execVM "KHPack\fired.sqf"}];
execVM "x_playerweapons.sqf";
execVM "KHPack\AIConSolve.sqf";
execVM "intro.sqf";

[] spawn {
if (isNil "town1") then {
	if (playerSide == EAST) then {
		execVM "briefinge.sqf";
	};

	if (playerSide == WEST) then {
		execVM "briefingw.sqf";
	};
};
};


if (true) exitWith {};

Edited by nullsystems

Share this post


Link to post
Share on other sites
firecount is personal to the user.

It counts how many times they have fired.

So, whats the solution then ?

Would the addeventhandler work fine if I just placed it in the units init from the editor?

What im thinking is:

Since the init file is executed for every unit when they connect...

If you have AI on the mission from the start, surely they execute the init too?

Which means the fired eventhandler is being added to the AI unit...

And when you connect into that slot, the fired eventhandler cannot be re-added to you?

1. firecount is a global var that is LOCAL!!! on the client... jip dont affect the var on other clients than the jip-player.

2. The init.sqf is just executed on clients at mission start. So it just affect players. If you want to add a handler to the ai, the server must place one. Best way is to add it to the init line of a unit (this affects playable units and players too)

Share this post


Link to post
Share on other sites

1. firecount is a global var that is LOCAL!!! on the client... jip dont affect the var on other clients than the jip-player.

I know this lol

2. The init.sqf is just executed on clients at mission start. So it just affect players. If you want to add a handler to the ai, the server must place one. Best way is to add it to the init line of a unit (this affects playable units and players too)

I dont want to add an eventhandler to AI.

If I add the addeventhandler to the init line in the editor, will this work for new players later?

If init.sqf is only executed at the mission start then why are they being updated with my briefing? Surely its executed as you connect, not just mission start.

---------- Post added at 07:22 PM ---------- Previous post was at 06:49 PM ----------

This also does not explain why...

execVM "KHPack\AIConSolve.sqf";

Does not execute either.

But the mission briefing does?

Share this post


Link to post
Share on other sites

If init.sqf is only executed at the mission start then why are they being updated with my briefing? Surely its executed as you connect, not just mission start.

init.sqf gets allways executed, even after hours for JIP players.

First of all, if you don't really need playable AI then turn it off in description.ext (was fixed in 1.02).

It seems that the player object does get handled differently in A2, maybe that causes a delay of init.sqf or whatever happens.

So, the safest way is to put a trigger in the editor, just add local player as condition and start a script that does all the player setup (it gets executed on all clients including JIP clients).

But... if you want briefing at mission start you still have to add it to the init.sqf as the local player trigger gets only fired when the player is actually ingame.

Btw, checking playerSide might not allways return the correct side at start.

Xeno

Share this post


Link to post
Share on other sites

Thats kinda what I was thinking.

So essentially, once again due to ArmA's buggy MP I have to compromise? lol

AiConSolve resets players to base if they arent within 400m of it.

So I guess thats out now.

Not really wanting to use the trigger method, but I guess its going to have to do.

Thanks.

---------- Post added at 09:42 PM ---------- Previous post was at 09:29 PM ----------

Why then, does the briefing always get set on connection...but nothing else?

That shows the init is working, just not other commands set in there.

Also, your "execVM "x_playerweapons.sqf";" works just fine, why not the others?

In both of my scripts being called I have " if (side _unit == WEST)" going on, could this be why ?

Edited by nullsystems

Share this post


Link to post
Share on other sites

Have you looked into the arma.rpt? Maybe there is a syntax error in a srcript or even the init...

init.sqf gets allways executed, even after hours for JIP players.

Thats not correct... as i already said, there is a bug in ArmA2 were after some hours of gameplay and a lot of players on a dedicated server the init wont get started for JIP-players.

I saw this bug 4 or 5 times... three times in warfare/crcti and two times on publicbetatest of my serialkiller mission

1. firecount is a global var that is LOCAL!!! on the client... jip dont affect the var on other clients than the jip-player.

I know this lol

I know yopu know it.... i said that for Turok

Share this post


Link to post
Share on other sites

Thats not correct... as i already said, there is a bug in ArmA2 were after some hours of gameplay and a lot of players on a dedicated server the init wont get started for JIP-players.

Hm, I've done many tests, all my missions rely on the init.sqf to get executed and I never had a problem with it. Even after hours of playing JIP players have no problems at all, init.sqf does allways run.

Though, I allways disable AI so it might be true for missions with enabled AI.

Xeno

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  

×