Closed markusa380 closed 3 years ago
I'll look into it.
I have created the script and it works with no trouble, however when you attempt to execute it upon different helipads, it's crashes the game, any suggestions?:
helipadMarker = (_this select 0);
helipad = (_this select 1);
nearObj = (getPos helipad) nearestObject "Air";
helipadPos = (getPos helipad);
[] spawn {
while { true } do {
if ((nearObj distance helipadPos)< 10) then {
helipadMarker setMarkerColor "colorRed";
}
else {
helipadMarker setMarkerColor "colorGreen";
};
};
};
It should work fine with a script for each object, but it has trouble executing the script with different targets at the same time even if execute individually.
You forgot to add sleep in your loop, e.g. sleep 5;
.
Also local variables should be named with _
prefix.
Also I doubt it's that simple in MP - you will probably have to remoteExec
some stuff, but I might be wrong.
Also you need to calculate nearObj
every loop not only in the beginning.
After conversing with Markus to sort the issue, it has been fixed with the following code:
if (isServer) exitWith {
_this spawn{
while { true } do {
sleep 5;
_helipadMarker = (_this select 0);
_helipad = (_this select 1);
_helipadPos = (getPos _helipad);
_nearObj = (getPos _helipad) nearestObject "Air";
if ((_nearObj distance _helipadPos)< 10) then {
_helipadMarker setMarkerColor "colorRed";
}
else {
_helipadMarker setMarkerColor "colorGreen";
};
};
};
};
@Halliwedge would you be able to give this a test and see if it works for more than one player? It's currently only on helipad 5 and 6.
Tested this out with Marc on the server and works with no issues. I'm going to keep this open until Helios have thoroughly tested it on Friday.
Just did some extra testing with Halli and it works fine. I will place the script on all the other helipads for mass testing this Friday.
After mass testing today, no bugs were found. If you find any problems with the helipads in the future, please open a new issue.
Thanks for your help @markusa380.
It's generally regarded as good practice to use script-based distance checks instead of triggers where the latter isn't super critical - triggers run at a low interval and will cause performance hits on the server. Script-based distance checks however can be controlled to run every 5 seconds or so.
Use nearestObject to check for the closest air vehicle and if the distance between the pad and the vehicle is smaller than ~5 meters the pad is occupied.