Jump to content
Tobur

Running scripts on dedicated server and vehicle respawn

Recommended Posts

Hi guys,

 

though I am getting better to tackle scripting in Arma I still have some issues for some of my functions despite having searched the internet..  a lot. I am not a programmer and have no real background about scripting. I combine the work and scripts from others in this community and alter them for my own needs. I have fun fullfilling ideas I have for my dedicated server and the small group of friends frequently coming together. During my research, trial and errors I found out how flexible and powerful Arma can be. But enough of that. To my problems:

 

1. Running scripts on dedicated servers/ locality in MP 

 

I run a helicopter supply drop script (credits: soolie) available for the players via the radio menu (radio trigger)

 

Problem: works well in single player. But in MP the script fires for all players (not only the initial caller) resulting in getting 1 helicopter for every player and multiple crates being dropped. Strangely when I am the only player on the server only one helicopter appears but it drops two crates simultaneously... tried different ways to call the script but I didn't get it running (lack of knowledge)

 

Caller: ["supply\supply.sqf", "BIS_fnc_execVM", true] call BIS_fnc_MP; (tried also _nul = execVM "supply\supply.sqf";)


Script:
    
 

   openMap [true,true];
    clicked = 0;
    hintc "Left click on the map where you want the supplies dropped";
    ["supplymapclick", "onMapSingleClick", {
        _supplyLocArray = [+1000,-1375,-1500,-1125,+1250,-1000,+1375,-1250,+1500,+1125];
//:::::::::::|USE THE ONE BELOW FOR TESTING, IT SPAWNS THE HELI MUCH CLOSER|:::::::::::
        //_supplyLocArray = [+500,-500];
        _supplyRandomLocX = _supplyLocArray select floor random count _supplyLocArray;
        _supplyRandomLocY = _supplyLocArray select floor random count _supplyLocArray;
        _supply = [[(_pos select 0)+_supplyRandomLocX,
                    (_pos select 1)+_supplyRandomLocY, 
                    (_pos select 2)+50], 180, "UK3CB_BAF_Merlin_HC3_24", WEST] call bis_fnc_spawnvehicle;
        _supplyHeli = _supply select 0;
        _supplyHeliPos = getPos _supplyHeli;
        _supplyMrkrHeli = createMarker ["supplyMrkrHeli", _supplyHeliPos];
        _supplyCrew = _supply select 1;
        _supplyGrp = _supply select 2;
        _supplyGrp setSpeedMode "FULL";
        _supplyGrp setBehaviour "CARELESS";
        _supplyWP1 =_supplyGrp addWaypoint [(_pos),1];
        _supplyWP1 setWaypointType "MOVE";
        _supplyWP2 = _supplyGrp addWaypoint [[(_pos select 0)+_supplyRandomLocX, 
                                            (_pos select 1)+_supplyRandomLocY, 
                                            _pos select 2], 2];
        _supplyMrkrLZ = createMarker ["supplyMrkrLZ", _pos];
        "supplyMrkrLZ" setMarkerType "Empty";
        "supplyMrkrHeli" setMarkerType "Empty";
        _supplyHeli flyInHeight 150;
        clicked = 1;
        openmap [false,false];
        onMapSingleClick '';}] call BIS_fnc_addStackedEventHandler; 
    waitUntil {(clicked == 1)};
        hint "The supplies are on the way";
        _supplyMrkrHeliPos = getMarkerPos "supplyMrkrHeli";
        _supplyMrkrHeliPos2 = [_supplyMrkrHeliPos select 0, 
                                _supplyMrkrHeliPos select 1, 
                                (_supplyMrkrHeliPos select 2)+50];
        _supplyHeli = _supplyMrkrHeliPos2 nearestObject "UK3CB_BAF_Merlin_HC3_24";
        _supplyMrkrLZPos = getMarkerPos "supplyMrkrLZ"; 
        _supplyLZ = createVehicle ["Land_Laptop_device_F", getMarkerPos "supplyMrkrLZ", [], 0, "NONE"];
        deleteMarker "supplyMrkrHeli";
        deleteMarker "supplyMrkrLZ";
        _supplyLZ hideObject true;
        
    waitUntil {( _supplyLZ distance _supplyHeli)<400};
        _supplyHeli animateDoor ["CargoRamp_Open",1];
    waitUntil {( _supplyLZ distance _supplyHeli)<200};
        sleep 2;
        _supplyHeli allowDammage false;
        _supplyBoxFnc = "B_CargoNet_01_ammo_F";
        _supplyBox = createVehicle [_supplyBoxFnc, position _supplyHeli, [], 0, "CAN_COLLIDE"];
                        clearBackpackCargoGlobal _supplyBox;
                        clearWeaponCargoGlobal _supplyBox;
                        clearMagazineCargoGlobal _supplyBox;
                        clearItemCargoGlobal _supplyBox;
                        _supplyBox addWeaponCargoGlobal ["UK3CB_BAF_L85A2", 2];
                        _supplyBox addWeaponCargoGlobal ["UK3CB_BAF_NLAW_Launcher", 2];
                        _supplyBox addWeaponCargoGlobal ["UK3CB_BAF_AT4_CS_AP_Launcher", 2];
                        _supplyBox addWeaponCargoGlobal ["rhs_weap_fgm148", 2];
                        _supplyBox addMagazineCargoGlobal ["UK3CB_BAF_762_100Rnd_T", 5];
                        _supplyBox addMagazineCargoGlobal ["UK3CB_BAF_762_L42A1_20Rnd", 5];
                        _supplyBox addMagazineCargoGlobal ["UK3CB_BAF_762_L42A1_20Rnd_T", 5];
                        _supplyBox addMagazineCargoGlobal ["UK3CB_BAF_127_100Rnd", 5];
                        _supplyBox addMagazineCargoGlobal ["UK3CB_BAF_556_30Rnd", 10];
                        _supplyBox addMagazineCargoGlobal ["UK3CB_BAF_556_30Rnd_T", 10];
                        _supplyBox addMagazineCargoGlobal ["13Rnd_mas_9x21_Mag", 4];    
                        _supplyBox addMagazineCargoGlobal ["rhs_fgm148_magazine_AT", 4];                            
                        _supplyBox additemcargoGlobal ["ACE_fieldDressing", 30];
                        _supplyBox additemcargoGlobal ["Laserdesignator", 5];
                        _supplyBox additemcargoGlobal ["ACE_morphine", 30];
                        _supplyBox additemcargoGlobal ["ACE_bloodIV", 10];
                        _supplyBox additemcargoGlobal ["ACE_bloodIV_250", 10];
                        _supplyBox additemcargoGlobal ["ACE_CableTie", 10];
                        _supplyBox additemcargoGlobal ["ACE_epinephrine", 20];
                        _supplyBox additemcargoGlobal ["HandGrenade", 10];
                        _supplyBox additemcargoGlobal ["Laserbatteries", 5];
                        _supplyBox additemcargoGlobal ["SmokeShellRed", 10];
                        _supplyBox additemcargoGlobal ["ACE_EarPlugs", 5];
                        _supplyBox additemcargoGlobal ["SmokeShell", 10];
                        _supplyBox additemcargoGlobal ["SmokeShellRed", 10];
                        _supplyBox additemcargoGlobal ["SmokeShellBlue", 10];
                        _supplyBox additemcargoGlobal ["ACE_DefusalKit", 5];
                        _supplyBox additemcargoGlobal ["ACE_CableTie", 10];
                        _supplyBox additemcargoGlobal ["ACE_Clacker", 5];
                        _supplyBox additemcargoGlobal ["DemoCharge_Remote_Mag", 5];
                        _supplyBox additemcargoGlobal ["NVGoggles_mas_h", 5];
                        _supplyBox additemcargoGlobal ["optic_Hamr", 5];
                        _supplyBox additemcargoGlobal ["tf_anprc152_2", 5];
                        _supplyBox additemcargoGlobal ["optic_Hamr", 5];
                        _supplyBox additemcargoGlobal ["tf_microdagr", 5];
                        _supplyBox addbackpackcargoGlobal ["B_Carryall_cbr", 1];    
                        _supplyBox addAction ["Arsenal", {["Open",true] spawn BIS_fnc_arsenal}];
        _supplyBox disableCollisionWith _supplyHeli;
        _supplyHeli disableCollisionWith _supplyBox;
        _supplyBox allowDammage false;
        _supplyBox attachTo [_supplyHeli, [0, 0, 0], "CargoRamp"]; 
        _supplyBox setDir ([_supplyBox, _supplyHeli] call BIS_fnc_dirTo);
        detach _supplyBox;
        
        //:::::::::::|Marker|:::::::::::
        _marker = createMarker ["SupplyMarker1", position _supplyLZ];
        _marker setMarkerType "mil_objective";
        "SupplyMarker1" setMarkerText "Supply Drop";
        "SupplyMarker1" setMarkerColor "ColorKhaki";
        //:::::::::::::::::::::::::::::::
        
        deleteVehicle _supplyLZ; 
    _supplyChute = createVehicle ["B_parachute_02_F", position _supplyBox, [], 0, "FLY"];
    _supplyBox attachTo [_supplyChute,[0,1,0]];    
    //_supplyChute hideObject true;
    _supplyChute setPos getPos _supplyBox;
                                                                            
//:::::::::::|LIGHT|:::::::::::
    _supplyLight = "Chemlight_green" createVehicle (position _supplyBox);
    _supplyLight attachTo [_supplyBox, [0,0,0]];
    _supplyFlare = "F_20mm_Red" createVehicle (position _supplyBox);
    _supplyFlare attachTo [_supplyBox, [0,0,0]];
//:::::::::::::::::::::::::::::        
    sleep 1;
    hint "The supplies have been dropped and can be found in the marked zone within a 200m radius.";
    _supplyChute hideObject false;
    _supplyChute allowDammage false;
    //_supplyHeli allowDammage true;
    //_supplyBox allowDammage true;
    _supplyHeli animateDoor ["CargoRamp_Open",0];
    
//:::::::::::|SMOKE|:::::::::::
    _supplySmoke = "SmokeShellPurple" createVehicle (position _supplyBox);
    _supplySmoke attachTo [_supplyBox, [0,0,0]];
//:::::::::::::::::::::::::::::
//:::::::::::|LIGHT II|:::::::::::
    sleep 10;
    _supplyLight = "Chemlight_green" createVehicle (position _supplyBox);
    _supplyLight attachTo [_supplyBox, [0,0,0]];
    _supplyFlare = "F_20mm_Red" createVehicle (position _supplyBox);
    _supplyFlare attachTo [_supplyBox, [0,0,0]];
//:::::::::::::::::::::::::::::        
    
    waitUntil {(getPos _supplyBox select 2)<2};
    //detach _supplyBox;
    _supplyHeli allowDammage true;
    _supplyBox allowDammage true;
        _supplyChute setPos [ (getPos _supplyChute select 0)+0.75, getPos _supplyChute select 1, getPos _supplyChute select 2];
        hint "";
        sleep 5;
        {deleteVehicle _x;}forEach crew _supplyHeli;deleteVehicle _supplyHeli;
        //hint "end";
// Cleanup
sleep 1500;
deleteMarker "SupplyMarker1"; 

2. Running scripts for respawned vehicles

 

My vehicles (and crates) have customized inventories. Instead filling every single vehicles manually in the editor I run a script and I can change the amounts very easy:

    

//Settings 
_weaponAmount = 2;
_magAmount = 20;
_itemAmount = 10;
_atAmount = 5;
_drugAmount = 40;
_bandageAmount = 50;
//_this allowDamage false;
//Clear Box
                        clearBackpackCargoGlobal _this;
                        clearWeaponCargoGlobal _this;
                        clearMagazineCargoGlobal _this;
                        clearItemCargoGlobal _this;
//_this addmagazinecargo ["SatchelCharge_Remote_Mag", _magAmount];
//_this addmagazinecargo ["SLAMDirectionalMine_Wire_Mag", _magAmount];
//_this addmagazinecargo ["SmokeShell", _magAmount];
                        
                        
                        _this addWeaponCargoGlobal ["UK3CB_BAF_L85A2", _weaponAmount];
                        _this addWeaponCargoGlobal ["UK3CB_BAF_NLAW_Launcher", _weaponAmount];
                        _this addWeaponCargoGlobal ["UK3CB_BAF_AT4_CS_AP_Launcher", _weaponAmount];
                        _this addWeaponCargoGlobal ["rhs_weap_fgm148", _weaponAmount];
                        _this addMagazineCargoGlobal ["UK3CB_BAF_762_100Rnd_T", _magAmount];
                        _this addMagazineCargoGlobal ["UK3CB_BAF_762_L42A1_20Rnd", _magAmount];
                        _this addMagazineCargoGlobal ["UK3CB_BAF_762_L42A1_20Rnd_T", _magAmount];
                        _this addMagazineCargoGlobal ["UK3CB_BAF_127_100Rnd", _magAmount];
                        _this addMagazineCargoGlobal ["UK3CB_BAF_556_30Rnd", _magAmount];
                        _this addMagazineCargoGlobal ["UK3CB_BAF_556_30Rnd_T", _magAmount];
                        _this addMagazineCargoGlobal ["13Rnd_mas_9x21_Mag", _magAmount];    
                        _this addMagazineCargoGlobal ["rhs_fgm148_magazine_AT", _atAmount];                            
                        _this additemcargoGlobal ["ACE_fieldDressing", _bandageAmount];
                        _this additemcargoGlobal ["Laserdesignator", _itemAmount];
                        _this additemcargoGlobal ["ACE_morphine", _drugAmount];
                        _this additemcargoGlobal ["ACE_bloodIV", _drugAmount];
                        _this additemcargoGlobal ["ACE_bloodIV_250", _drugAmount];
                        _this additemcargoGlobal ["ACE_CableTie", _itemAmount];
                        _this additemcargoGlobal ["ACE_epinephrine", _drugAmount];
                        _this additemcargoGlobal ["HandGrenade", _itemAmount];
                        _this additemcargoGlobal ["Laserbatteries", _itemAmount];
                        _this additemcargoGlobal ["SmokeShellRed", _itemAmount];
                        _this additemcargoGlobal ["ACE_EarPlugs", _itemAmount];
                        _this additemcargoGlobal ["SmokeShell", _itemAmount];
                        _this additemcargoGlobal ["SmokeShellRed", _itemAmount];
                        _this additemcargoGlobal ["SmokeShellBlue", _itemAmount];
                        _this additemcargoGlobal ["1Rnd_SmokeGreen_Grenade_shell", _itemAmount];
                        _this additemcargoGlobal ["UK3CB_BAF_1Rnd_HE_Grenade_Shell", _itemAmount];
                        _this additemcargoGlobal ["1Rnd_SmokeGreen_Grenade_shell", _itemAmount];
                        _this additemcargoGlobal ["ACE_SpottingScope", _itemAmount];
                        _this additemcargoGlobal ["ACE_Tripod", _itemAmount];
                        _this additemcargoGlobal ["ACE_DefusalKit", _itemAmount];
                        _this additemcargoGlobal ["ACE_CableTie", _itemAmount];
                        _this additemcargoGlobal ["ACE_Clacker", _itemAmount];
                        _this additemcargoGlobal ["DemoCharge_Remote_Mag", _itemAmount];
                        _this additemcargoGlobal ["NVGoggles_mas_h", _itemAmount];
                        _this additemcargoGlobal ["optic_Hamr", _itemAmount];
                        _this additemcargoGlobal ["tf_anprc152_2", _itemAmount];
                        _this additemcargoGlobal ["tf_rt1523g_bwmod", _itemAmount];
                        _this additemcargoGlobal ["ItemAndroid", _itemAmount];
                        _this additemcargoGlobal ["tf_microdagr", _itemAmount];
                        _this additemcargoGlobal ["ToolKit", 1];                        
                        _this addbackpackcargoGlobal ["B_Carryall_cbr", _itemAmount];    

Caller: null = this execVM "Z_Crate.sqf"; (in init field of every vehicle)

 

Problem: works fine at the start of the mission. If destroyed the vehicles respawn via the Arma vehicle respawn module. But they are then empty / have standard items (=script does not fire after respawn). 

 

Bonus: Any ideas how to combine 2. into 1. (running the inventory script from 2 in the supply drop box instead filling it individually)

 

I would really like to get this working, any ideas highly appreciated 

 

Thanks guys


 

Share this post


Link to post
Share on other sites
Caller: ["supply\supply.sqf", "BIS_fnc_execVM", true] call BIS_fnc_MP; (tried also _nul = execVM "supply\supply.sqf";)

 

You need to check the localities of the command you are using, some of them are global like createVehicle. Therefore, you don't need to execute them globally, just on the server.

Share this post


Link to post
Share on other sites

That's pretty much my boat!

46 minutes ago, tobur said:

though I am getting better to tackle scripting in Arma I still have some issues for some of my functions despite having searched the internet..  a lot. I am not a programmer and have no real background about scripting. I combine the work and scripts from others in this community and alter them for my own needs. I have fun fullfilling ideas I have for my dedicated server and the small group of friends frequently coming together. During my research, trial and errors I found out how flexible and powerful Arma can be.

 

Try this for the supply

_nulsupply = [player] execVM "supply\supply.sqf";

Read through this to see if it helps

Good Luck!

Share this post


Link to post
Share on other sites

 

58 minutes ago, tobur said:

Problem: works fine at the start of the mission. If destroyed the vehicles respawn via the Arma vehicle respawn module. But they are then empty / have standard items (=script does not fire after respawn). 

 

Have you tried to execute the inventory script via the "Expression" field of the respawn module? That should asure that it's executed properly.

Share this post


Link to post
Share on other sites

Hey,

 

thanks for the quick replies! Will look into it.

 

27 minutes ago, R3vo said:

 

 

Have you tried to execute the inventory script via the "Expression" field of the respawn module? That should asure that it's executed properly.

yes tried that (I put the same there as in the initial container. sorry, did not mention this. But how I call the script might be wrong again. Would be the easiest solution. Will look into it again. Thx

Share this post


Link to post
Share on other sites

for me the respawn module is not very good, it stops working after awhile.

i much prefer a respawn script, that lets me set init of respawned vehicles.

 

il give you an example mission so you can see if this works for you. i set vehicles to respawn after a few seconds if moved or destroyed

http://www.mediafire.com/file/9ddchv41nbwlgtu/vehicle+respawn.Stratis.rar

 

the unarmed hunter respawns with virtual arsenal in an addaction. after respawn the addaction vil only show up inside vehicle.

to add addaction u need to name the respawned vehicle

 

the armed one i added some xtra weapons to... this is not needed to be named

but u can look at the files to see how it works.

Share this post


Link to post
Share on other sites

1-

2-

use Vehicle respawn module expresion field to init your code one each linked vehicle when respawned

Share this post


Link to post
Share on other sites

Thanks guys, you helped me a lot! Finally I was able to solve #2 using the expression field in the support module (thanks R3vo). To run the script for different vehicles I added this

 

0 = {_x execVM "Z_Gear\Z_Crate_small.sqf"} forEach [Coyote_GMG,Coyote_HMG,warrior,jkl_GMG,jkl_hmg,Wldct_cas];

Could be more elegant but it works... 

 

Regarding #1: this

_nulsupply = [player] execVM "supply\supply.sqf";

didn't work, still fires for all players but I am looking into davidoss' supply script now.

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

×