Jump to content
Sign in to follow this  
ToejaM

Why does my script not work on my server but does in the editor?

Recommended Posts

_point1 = getmarkerpos "unload"; // this is where the player will be dropped off.
_point2 = getmarkerpos "troublelaunch";   // this is where the trouble1 will fly off to at the end.
trouble1 allowdamage false;
trouble1 setfuel 1;
trouble1 setdamage 0;
ch2 setCombatMode "BLUE";
dt=true;
rt=true;
titleText ["Indicate LZ on map by map-click","PLAIN DOWN"];
openMap true;
onMapSingleClick "loc = _pos;dt=false";
waitUntil {!dt};
titleText ["Co-ordinates received, evac inbound.","PLAIN DOWN"];

"lz" setMarkerPos loc;
_landpad = "Land_HelipadEmpty_F" createVehicle getMarkerPos "lz";

_wp0 = ch2 addWaypoint [loc, 10];	
_wp0 setWaypointType "MOVE";
_wp0 setWaypointStatements ["true", ""];
_wp0 setWaypointSpeed "FULL";


_wp1 = ch2 addWaypoint [loc, 20];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointStatements ["true", "(vehicle this) land ""GET IN"""];
waitUntil {!(player in trouble1)};

_wp2 = ch2 addWaypoint [_point2, 5];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointStatements ["true", "(vehicle this) land ""GET OUT"""];

titleText ["Insertion Asset has RTB","PLAIN DOWN"];
waitUntil {trouble1 distance [_point2 select 0, _point2 select 1] < 10};
trouble1 setfuel 0;

So thats my script, I know it has a few other markers defined but its because I've used the script several times for slightly different purposes and didnt remove the extra locations... anyway, the script works fine in the editor but doesnt work in multiplayer past the point of clicking on the map to send the chopper to where I want it to go. I'm confused!

Share this post


Link to post
Share on other sites

Either the script you posted here is incomplete or you have other scripts which initialize public variables used in this one. Because "trouble1", "ch2", "dt" and "rt" are not defined anywhere.

Then, do you execute this file in the mission PBO ("MissionName.Altis.pbo") or do you have it in an addon PBO? Because this script as it is can only be used in the mission PBO as variables like "player" do not exist serverside.

Share this post


Link to post
Share on other sites

This is all in the mission file which is downloaded to the client.

trouble1 is the name of the chopper being used (because of the issues with the arma 3 transport module, i decided to name the chopper trouble :P)

ch2 is the group its assigned to in the vehicles init:

ch2 = group trouble1;

dt is set true so that when you click it gets set to false as there is a "waitUntil {!dt};" - so it doesnt continue with the script before the mouse click is done.

Script is called through an addaction menu

---------- Post added at 14:36 ---------- Previous post was at 14:25 ----------

It seems another issue with the init, adding ch2 = group trouble1; above ch2 setCombatMode "BLUE"; works.

Why is the init so useless!? lol - any additional suggestions would be appreciated.. I'm trying to make a better set of scripts than the arma3 modules. I have insertion, extraction, medivac, supply drop, artillery - which if anyone wants, I will happily share as the arma 3 modules are awful!

Share this post


Link to post
Share on other sites
trouble1 is the name of the chopper being used (because of the issues with the arma 3 transport module, i decided to name the chopper trouble :P)[/code]

You should name it MPdisaster1. :D

Share this post


Link to post
Share on other sites

Is that because I cant script for toffee? :D

I tried using the virtual transport support module, out of 6-7 choppers called in, one of them landed in a safe area.. not in trees, not in tight alleyways both of which wrecked the choppers engines/rotor.. then we got in and the menu to set a transport point disappeared :/

---------- Post added at 15:52 ---------- Previous post was at 14:42 ----------

Ok the only thing I cannot get to work now is the setFuel portion of it.. something to do with locality that is beyond my comprehension!

Share this post


Link to post
Share on other sites
Ok the only thing I cannot get to work now is the setFuel portion of it.. something to do with locality that is beyond my comprehension!

setFuel and allowDamage need to be executed on the computer where the objects they're applied to are local. Since addAction is only executed for the client that runs the action, you might want to use BIS_fnc_MP.

[{
trouble1 allowDamage FALSE;
trouble1 setFuel 1;
},
"BIS_fnc_spawn", trouble1] call BIS_fnc_MP;

[{
trouble1 setFuel 0;
},
"BIS_fnc_spawn", trouble1] call BIS_fnc_MP;

If you know for sure that the helicopter will be local on the server, you can use "BIS_fnc_spawn", FALSE] instead of "BIS_fnc_spawn", trouble1]. The wiki has info on the parameters:

target:

Boolean - true to execute on each machine (including the one where the function was called from), false to execute it on server only

Object - function will be executed only where unit is local [default: everyone]

Share this post


Link to post
Share on other sites

I dont want to cheap out on the learning.. I've enjoyed learning about scripting but somethings just go over my head. So as a cheap out question:

If I put

[{

trouble1 setFuel 0;

},

"BIS_fnc_spawn", trouble1] call BIS_fnc_MP;

In the places where I want there to be no fuel in the vehicle, will that work or is there some more wizardry to it? I only ask as we're planning on a mission tonight :)

Edit: I tried it with allowdamage false and it works great, thanks! Was having an issue with the crate from my supply drop doing damage to the chopper rotor heh! So I asumme itll work with setfuel, it seems that the waypoint statment for "LAND" works on multiplayer but doesnt really work in the preview so my work around is something ill try tonight, if for some reason it bugs out I'll force the fuel to drain.

Thanks a bunch for the help, thats amazing.. I dont quite understand what the BIS funcs do so I'll have to look into these.

Edited by ToejaM

Share this post


Link to post
Share on other sites
will that work or is there some more wizardry to it?

Should work like that, yeah.

These parts might be all clear to you already, but in case they're not: Usually you can check the wiki for the scripting commands' locality (or at least get hints on how it goes). For example with setFuel there's the three icons under the header - after the version it's arguments "local" and effects "global", meaning it only has effect if its executed on the client where the target is local, but the effect (the amount of fuel changing) is visible on every client.

The regular hideObject, for example, has them around the way - you can hide any object regardless of its locality, but the effect will only be visible on the client executing the command.

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  

×