Jump to content
DPM

Script firing multiple times on dedicated

Recommended Posts

I'm playing a mission that has a supply drop script in it, the script runs fine in the editor, the plane arrives at the right location and drops one chute with a crate on it with inventory access to the gear inside. However on a dedicated server when the plane arrives at the location it drops multiple chutes with crates in relation to how many players are on the server and only one has gear with an inventory interaction available to get it, the rest are empty with no inventory interaction. Google suggests adding isServer/isDedicated etc, but no matter how I try applying that to the script or the call, the only thing it does is affect the contents of the extra crates and the ability to access the inventory, it still generates multiple chutes with crates. The ideal situation is for the plane to drop one chute with one crate regardless of how many are on the server. The author of the mission hasn't been seen since February so I haven't been able to ask them directly and I'd be grateful if anybody has any ideas?

 

It's a BR style mission so the drop plane goes to a randomly placed area on the map, it's called from the initserver.sqf

Spoiler

DropCargoInGame = {
DropPointPos = _this select 0;    
DropPointPos set [2,150];

0 = createMarker ["DropLootMarker", DropPointPos];
"DropLootMarker" setMarkerSize [250, 250];
"DropLootMarker" setMarkerShape "ELLIPSE";
"DropLootMarker" setMarkerColor "ColorYellow";

_infohint = format ["CARGO DROP INCOMING!"];
[1,[_infohint, "PLAIN DOWN", 0.6]] remoteExec ["cutText"];


PlanePos = [[[DropPointPos, 2500]],["water"]] call BIS_fnc_randomPos;
PlanePosZ = PlanePos select 2;
PlanePos set [2, 300];

//dropCargoPos = DropPointPos;
//PlanePosZ = dropCargoPos select 2;
//dropCargoPos set [2,PlanePosZ + 150];

LeavePos = [[[DropPointPos, 2500]],["water"]] call BIS_fnc_randomPos;
LeavePosZ = LeavePos select 2;
LeavePos set [2, 300];
   
lootPlane setPos PlanePos;
_grp = group lootPlane;
while {(count (waypoints _grp)) > 0} do{ deleteWaypoint ((waypoints _grp) select 0);};

_wp = _grp addWaypoint [DropPointPos, 0];  
_grp setBehaviour "CARELESS";           
_wp setWaypointType "MOVE";
_wp setWaypointStatements["true","0 = [] execVM 'planeDrop.sqf';"];
 
_wp = _grp addWaypoint [LeavePos,0];
_wp setWaypointType "MOVE";
_wp setWaypointStatements["true","lootPlane setPos [0,0,150]; _grp = group lootPlane; _wp = _grp addWaypoint [[0,0,150],0]; _wp setWaypointType 'LOITER'; "];
};
};

 

 

....and this is the script....

 

Spoiler

myfuncTD = compile preprocessFileLineNumbers "DropLootTake.sqf";
IsCargoLandedFlag = false;
LootBots = objNull;

IsCargolanded = {
_cargo = _this select 0;
0 = [_cargo] spawn {
    _cargo = _this select 0;
    _CargoMemoryZ = 0;
    _CargoPosZ = 1;
    while {_CargoPosZ != _CargoMemoryZ}
        do {
            _CargoPos = getPosATL _cargo;
            _CargoMemoryZ = _CargoPos select 2;
            sleep 2;
            _CargoPos = getPosATL _cargo;
            _CargoPosZ = _CargoPos select 2;
        };
        IsCargoLandedFlag = true;
    };
};

paraPos = getPosATL lootPlane;
paraPosZ = paraPos select 2;
paraPos set [2,paraPosZ-10];
cratePos = paraPos;
cratePos set [2,paraPosZ-10];
fireEffectPos= cratePos;
fireEffectPos set [2,paraPosZ-12];
para = createVehicle ["B_Parachute_02_F", paraPos, [], 0, ""];
supplyCrateToDrop = createVehicle ["C_T_supplyCrate_F", cratePos, [], 0, ""];

clearweaponcargo supplyCrateToDrop;
clearmagazinecargo supplyCrateToDrop;
clearItemCargo supplyCrateToDrop;
clearBackpackCargo supplyCrateToDrop;

ItemsInCargo =1;

_myweapon = "";
_mymagazine ="";
_itemAr = 0;
_itemtoGive = 0;
_itemBonus = 0;
_randWep = 0;

switch(ItemsInCargo) do {
case 0: {
_randWep = floor random (3);
_myweapon = ["srifle_GM6_LRPS_F","srifle_EBR_DMS_pointer_snds_F","srifle_LRR_LRPS_F"];
_mymagazine = ["5Rnd_127x108_Mag","20Rnd_762x51_Mag","7Rnd_408_Mag"];
_myweapon = _myweapon select _randWep;
supplyCrateToDrop addWeaponCargo [_myweapon, 1];
_mymagazine = _mymagazine select _randWep;
supplyCrateToDrop addMagazineCargo [_mymagazine, 2];
};
case 1: {
_randWep = floor random (2);
_myweapon = ["LMG_Mk200_MRCO_F","LMG_Zafir_pointer_F"];
_mymagazine = ["200Rnd_65x39_cased_Box","150Rnd_762x54_Box"];
_myweapon = _myweapon select _randWep;
supplyCrateToDrop addWeaponCargo [_myweapon, 1];
_mymagazine = _mymagazine select _randWep;
supplyCrateToDrop addMagazineCargo [_mymagazine, 2];
};
case 2: {
_itemBonus ="MineDetector";
_itemAr = ["SLAMDirectionalMine_Wire_Mag","APERSBoundingMine_Range_Mag","APERSTripMine_Wire_Mag"];
_itemtoGive = selectRandom _itemAr;
supplyCrateToDrop addItemCargo [_itemBonus,1];
supplyCrateToDrop addItemCargo [_itemtoGive,2];
};
case 3: {
_item = ["optic_tws","optic_tws_mg","optic_NVS","optic_Nightstalker"];
_itemtoGive = selectRandom _item;
supplyCrateToDrop addItemCargo [_itemtoGive,1];
};
};

DropLootBeh = "_grp setBehaviour 'AWARE'; [this] call myfuncTD; _grp setBehaviour 'COMBAT';";

vehSmoke = "#particlesource" createVehicleLocal fireEffectPos;       
vehSmoke setParticleClass "SmokeTrailEffect1";            
vehSmoke setParticleRandom [0, [0.0, 0.0, 0.0], [0, 0, 0.0], 0, 0.0, [0.2, 0.1, 0.1, 0.9], 0, 0];  
vehSmoke attachTo [supplyCrateToDrop];
supplyCrateToDrop attachTo [para];

0 = [] spawn {

[supplyCrateToDrop] call IsCargolanded;

        waitUntil {
            IsCargoLandedFlag isEqualTo true;
        };
deleteMarker "DropLootMarker";
        
LootAiTrg = createTrigger ["EmptyDetector", getPosATL supplyCrateToDrop];
LootAiTrg setTriggerArea  [250, 250, 0, false,500];
LootAiTrg setTriggerActivation ["ANY", "PRESENT", true];
LootAiTrg setTriggerStatements ["this",
"
if((count thislist) > 0) then {
LootBots = thisList;};
if (LootBots isEqualTo objNull) then {}
else {
0 = [thisList] spawn
{
_trPlayers = _this select 0;
{
if ((_x != vehicle player) && ((side _x) == sideEnemy)) then {
_grp = group _x;              
while {(count (waypoints _grp)) > 0} do{ deleteWaypoint ((waypoints _grp) select 0);};  
_wp = _grp addWaypoint [position supplyCrateToDrop, 0];
_wp setWaypointType 'MOVE';
_wp setWaypointStatements['true',DropLootBeh];
};}forEach _trPlayers;
};};", ""];

deleteVehicle vehSmoke;

if (LootBots isEqualTo objNull) then {}
else {
if (count LootBots > 0) then {
{    
_grp = group _x;
if ((_x != vehicle player) && ((side _x) == sideEnemy)) then {
//while {(count (waypoints _grp)) > 0} do{ deleteWaypoint ((waypoints _grp) select 0);};
[_x,SmallCircleSGlobal] call runner;
sleep 0.5;
};}forEach LootBots;
};
LootBots =objNull;
deleteVehicle LootAiTrg;
};
};

 

  • Like 1

Share this post


Link to post
Share on other sites

If it runs as many times as you have players plus one, then the script is running on each player as well as the server.

You need to add an isserver check. Sorry I can't be more specific, I'm replying from phone, but hopefully knowing the cause will help you find the solution.

  • Thanks 1

Share this post


Link to post
Share on other sites

Y'know. that was the first thing I tried and it didn't work, neither did IsDedicated and a few other variations in multiple places. Then because you confirmed it I tried it again and only one crate dropped. There's AI in the mission so it normally drops 2 without other human players on, so I'll have to wait to confirm, but it looks good. I don't know why it didn't get the same result the first time as I did the exact same thing, or some of the others, but it would've saved me a ton of time going in and waiting 10 mins for the drop to happen just to see it didn't work ...and I did that a LOT lol Arma!

 

Thanks for the reply, if it turns out it's just bluffing me, I'll be back.

  • Like 1

Share this post


Link to post
Share on other sites

It depends on your server type. Isdedicated only works on dedicated servers. Isserver might be best if you're not using a dedi

Share this post


Link to post
Share on other sites

It is a dedi, but at that point I was trying everything through furstration and a touch of desperation....I can only think the closing }; must've messed up and because it did actually do something to the crates I just kept doing the same thing wrong.

Share this post


Link to post
Share on other sites

My mantra is, what ever is breaking it in mp... If it isn't a missing bracket or a semi colon, then it usually is locality

Share this post


Link to post
Share on other sites

I did not look at much of your script, but the trigger statement works with the players.
That's not good for an MP mission.
Such things should only be done by the server.

Share this post


Link to post
Share on other sites
11 hours ago, Tankbuster said:

My mantra is, what ever is breaking it in mp... If it isn't a missing bracket or a semi colon, then it usually is locality

 

Yeah, I think once I didn't get the result I was hoping for, but actually got something else happening instead of what it had been doing default, then I couldn't see the forest for the trees and just kept digging myself a deeper hole.

 

10 hours ago, Lucullus said:

I did not look at much of your script, but the trigger statement works with the players.
That's not good for an MP mission.
Such things should only be done by the server.

 

That's no doubt correct, but it's not my script, or mission and trying to get it to function the way I wanted has melted my head to the point that I'll be happy enough if it just simply "works", let alone efficiently and compared to the win condition, this is has been easy. Perhaps the author wrote it that way because AI need to interact with it too, I have no idea.

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

×