Jump to content
Sign in to follow this  
Tankbuster

locally hosted mission and script behaves odd when on DS

Recommended Posts

I a bit gutted here, TBH. I've spent a long time getting my IED script to work locally, but when I put it's test mission on a dedi server, either running here on my machine, or my rented box, weird stuff happens.

Specifically, triggers don't work as expect. Usually, they just don't fire.

I'm generating clutter objects by the roadside, some of which have triggers on them. Some of them will spawn a large explosion and some will spawn a small explosion.

The trigger conditions are core of this script - for example it's possible to approach the IED in the crawl without them going off. The player can then place a satchel near it and use that to 'disrupt' the IED.

This is probably to do with the locality of the triggers. I assumed, perhaps naively, that all this stuff could run just on the server and everything would be cushty, but that's apparently not the case.

I don't know if more details would be helpful, but in the meantime, some general pointers would be really appreciated.

Tanky -Paul-

Share this post


Link to post
Share on other sites

You are probably on to locality as the issue. Triggers placed in the editor are local everywhere. Triggers created via createTrigger are local only to where they are created. If you want the trigger to be able to detect all units it has to be created on the server and all clients.

Edited by Loyalguard

Share this post


Link to post
Share on other sites

OK, all these triggers are made with createtrigger, so where do I go from here?

Originally, my script started with if (!isServer) exitWith {};

When I did that, none of the triggers fired at all. When I commented that line out, some of them worked as expected, yet some didn't. Most odd.

Share this post


Link to post
Share on other sites

So if you use !isServer to exit then the trigger will never be created on clients.

If you have no condition, then the triggers will be created where the script execs. How is the script exec'd? Init line, init.sqf?

Share this post


Link to post
Share on other sites

Ok. So. Without !isServer it should exec everywhere and create the trigs everywhere. When you say some dont work, what do you mean? The detection? The satchel disruption? Explosions?

Share this post


Link to post
Share on other sites

Hard to say exactly. Not tried satchel disruption yet.

I use a red barrel (as a streetside clutter object) for the small 'splodes and a green for the big splode. The red ones should go off everytime a player walks up to them, but some of them just don't.

I'll make a YT vid tomorrow, that'll make it clearer.

I'm gonna get some kip. Im knackered now, and a bit gutted. As you know because you've helped, this has been a big thing for me for ages, and to get it working locally, then see it break on DS was a real rollercoaster!

I might knock up a quite webpage describing the project as it's complex.

Share this post


Link to post
Share on other sites

Here's it working locally hosted. I'll plop it on a server and shoot some more vid today.

kd5KF6hGeBw

The problem is, as we reckon the triggers.

I've used an eventhandler on the clutter object that when it gets a hit of 50 (a satchel blast) it deletes the trigger that sets off the splode. That's never going to work hosted because of locality. Which is a shame because deleting the trigger is good for performance.

Instead of deleting the trigger, I can set an object namespace variable that hold if the IED is live or not, broadcast the variable and then check it in the trigger condition.

But that doesn't explain the odd behaviour of the IEDs not going off at all, when server hosted and the script runs on client and server. I need to troubleshoot this more and will fraps it later - got the kids at home with me today. :)

Share this post


Link to post
Share on other sites

Regarding the triggers not activating...there could be some weirdness there with terrain level. What would be helpful is a controlled test, that is, one clutter/IED/Trigger combo run in SP and then on DS to see what works and what doesn't.

Share this post


Link to post
Share on other sites

It may be from starting the script from the init.sqf. I have had some problems with dedicated hosting and getting scripts to run correctly especially with jip. Try this:

Start the script from two triggers:

On each trigger in the on-activation field execVM your script.

One with a condition of:

isServer

The other with a condition of :

local player

That should ensure that your script is running on every client and the server even for JIP.

Edited by Riouken

Share this post


Link to post
Share on other sites

Terrain level? I'm surprised you suspect that.

I'll do some more tests to see if terrain seems to be implicated.

Also, its simple to move this to another island or location. I'll try it at rasman where its much flatter.

---------- Post added at 04:08 PM ---------- Previous post was at 03:46 PM ----------

Terrain level? I'm surprised you suspect that.

I'll do some more tests to see if terrain seems to be implicated.

Also, its simple to move this to another island or location. I'll try it at rasman where its much flatter.

Share this post


Link to post
Share on other sites

Terrain level may just be speculation but I have had weird things like that happen before. If you are using the trigger condition code I think you are using, if the selection is lower than your desired height because of a difference in relative or absolute ground/terrain leves, it could explain why the trigger never fires. It may be a stretch but it popped in my head so I though I would mention it.

Share this post


Link to post
Share on other sites

Why have you not posted the trigger condition? That is very likely to be a part of the problem.

Generally if you just want to blow stuff up, you only need the trigger and explosion script on the server, but you need the trigger condition to work on any unit that walks in, obviously, and not just the player. If you post the condition you are using we can see what you might be doing wrong.

Disabling the trigger via damage taken can also be done on the server alone, with no related scripts running on clients.

If you want to add ability to disable the IED, though, you will need to add the action on all clients, and make the action broadcast to the server that the IED have been disabled, so that the server script can then delete the trigger (or disable the IED in any other way).

Share this post


Link to post
Share on other sites
Why have you not posted the trigger condition? That is very likely to be a part of the problem.

I will later on when I can get on the PC. Mrs Tank is working from home. :)

---------- Post added at 04:59 PM ---------- Previous post was at 04:56 PM ----------

Generally if you just want to blow stuff up, you only need the trigger and explosion script on the server, but you need the trigger condition to work on any unit that walks in, obviously, and not just the player. If you post the condition you are using we can see what you might be doing wrong.

So let me get this right. Does the trigger have to be on all machines or just on the server? The trigger condition, that we'll see later, excludes AI. It only fires on players.

---------- Post added at 05:01 PM ---------- Previous post was at 04:59 PM ----------

Disabling the trigger via damage taken can also be done on the server alone, with no related scripts running on clients.

What I'm actually doing is putting a hit eventhandler on the cutter object. If it gets more than 50 damage, it deletes the trigger. I was hoping this method would work when it's run on just the server, but it seems it won't

---------- Post added at 05:04 PM ---------- Previous post was at 05:01 PM ----------

If you want to add ability to disable the IED, though, you will need to add the action on all clients, and make the action broadcast to the server that the IED have been disabled, so that the server script can then delete the trigger (or disable the IED in any other way).

Quite early on, we took a decision to not let the players defuse the IED using wiresnippers and such like.

I think the best way to make the IED safe is to give the clutter object a namespace variable that flags whether the IED is safe or not. Because you can public these, that should get around any locality issues. I'd then include an extra check in the trigger condition looking at this variable.

---------- Post added at 05:06 PM ---------- Previous post was at 05:04 PM ----------

Terrain level may just be speculation but I have had weird things like that happen before. If you are using the trigger condition code I think you are using, if the selection is lower than your desired height because of a difference in relative or absolute ground/terrain leves, it could explain why the trigger never fires. It may be a stretch but it popped in my head so I though I would mention it.

OK, that's easy to check.

Share this post


Link to post
Share on other sites

If you don't want the players to have any sort of scripted interaction with the IED, and only their location or damage dealing actually do something, then you shouldn't need any client-side scripts nor triggers to make it work.

"hit" eventhandler *should* work when only on the server, assuming the trigger also only exists on the server.

If you use the player variable in the condition field, then obviously the trigger will not work on a dedicated server since on the dedicated server there is no player. Basically, if you check for player in thislist and do that check only on the server, then the only one who would trigger any IEDs would be the host on a hosted server.

To get things working correctly:

Either just change the condition back to this, or change to to something like ({isPlayer _x} count thislist) > 0 in order to make it work for any player that walks in, and not just the host.

And again, deleting the trigger on the server should work if it was created on the server. Just make sure you actually use the event handler correctly (ex: make the eventhandler set and publicVariable some test variable and then check its value on the client to see if the event handler is working correctly).

Edited by galzohar

Share this post


Link to post
Share on other sites

OK, When hosted on a dedi, I just tested it with the script running on server and clients, and some IEDs go off, some don't. If the script runs ONLY on the server, they never go off.

So, let's look at some code.

_t_rand = floor (random (count (_smallclutterobjects)));
_clutterclass = _smallclutterobjects select _t_rand;
_clutterclass = "Barrel1";

if (_clutterclass in ["WildBoar", "Sheep", "Fin", "Pastor"]) then
{
call compile format ["clutterobj%1 = createAgent ['%2', [%3,%4], [], 0, 'NONE']", _iedarraycounter, _clutterclass, _t_xpos, _t_ypos];
call compile format ["clutterobj%1 setdamage 1", _iedarraycounter];
} 
else
{
call compile format ["clutterobj%1 = createVehicle ['%2', [%3,%4], [], 0, 'NONE']", _iedarraycounter, _clutterclass, _t_xpos, _t_ypos];
};
//_realpos = getPos clutterobj; // createvehicle sometimes moves it's object away from other objects to prevent clipping. get new position
call compile format ["realpos = getPos clutterobj%1", _iedarraycounter];
_t_xpos = realpos select 0;
_t_ypos = realpos select 1;
//_iedobj = createVehicle ["BAF_ied_v3", [_t_xpos, _t_ypos], [], 0, "CAN_COLLIDE"];
call compile format ["t_iedtrigger%1 = createTrigger ['EmptyDetector', [_t_xpos, _t_ypos]]", _iedarraycounter];
call compile format ["t_iedtrigger%1 setTriggerArea[3, 3, 0, false];", _iedarraycounter];
call compile format ["t_iedtrigger%1 setTriggerActivation['ANY', 'PRESENT', false]", _iedarraycounter];
_t_strinf = format ["tankyied%1 = createVehicle ['SEK_TR_GUE_smallbomb', [%2,%3], [], 0, 'NONE']",_iedarraycounter,_t_xpos,_t_ypos];
call compile format ["t_iedtrigger%1 setTriggerStatements [""vehicle player in thisList && player selectionPosition 'Neck' select 2 > 0.5 && !(vehicle player isKindOf 'air')"", ""%2"", """"]" , _iedarraycounter, _t_strinf];
call compile format ["tnul = clutterobj%1 addEventHandler ['hit', {if (_this select 2 > 40) then {deleteVehicle t_iedtrigger%1}}]", _iedarraycounter];
diag_log format ["small ied create index %1, xpos %2, y pos %3, ied serial %4", _t_smalliedcount, _t_xpos, _t_ypos, _iedarraycounter];
call compile format ["iedarray set [%1, t_iedtrigger%1]", _iedarraycounter];// add the trigger to an array for later removal
_t_smalliedcount = _t_smalliedcount -1;
iedarraycounter = _iedarraycounter + 1;

Obviously, this is only part of the script, but you get the idea.

Share this post


Link to post
Share on other sites

OK, I think I know what the problem is.

This script creates clutter objects in random locations. If you run it on both the client and the server, the player sees double the number of red barrels (the ones that hide the IED), because he's seeing both client created ones and server created ones. It would seem to follow that only the ones created on the clients machine would explode as the trigger wont work on the barrels created on another machine. That might explain why some of the red barrels are exploding and some aren't.

I need to do further testing to confirm this, but this is my current favourite theory.

---------- Post added at 02:05 AM ---------- Previous post was at 01:42 AM ----------

And one last thing that wasn't helping... the setTriggerStatements need to be reworks for a server environment...

My trigger condition 'vehicle player in thisList' won't work on a server because there are no players on the server. isPlayer is the way that a server side script can tell between AI and players, so that need to be looked into too.

Thanks to chaps on the DH Skype for guidance. Much appreciated.

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  

×