First of all this forum is great, I've learned so much just by reading. I'm a noob, so please go easy on me. I'm trying to reduce the number of duplicate scripts I have to get the mission file size down. Yes, apparently there's still scripting noobs out there, I feel like I should have taken this up years ago it's so much fun.
I have an extra_rc class set up like this
class EvKobalt { class Kobalt5 { text = "Spawn OP AH6J"; script = "execVM 'custom\admindeploy\opah6j.sqf'"; }; };
and opah6j.sqf looks like this:
_itemsPlayer = items player; if (dayz_combat == 1) then { cutText [format["You are in Combat and cannot build an AH6J."], "PLAIN DOWN"]; } else { player playActionNow "Medic"; r_interrupt = false; _dis=10; sleep 6; _object = "AH6J_EP1" createVehicle (position player); _object setVariable ["ObjectID", "1", true]; _object setVariable ["ObjectUID", "1", true]; _object setVariable ["MalSar",1,true]; _object addWeapon "GAU8"; _object addMagazine "1350Rnd_30mmAP_A10"; _object addWeapon "HellfireLauncher"; _object addMagazine "8Rnd_Hellfire"; _object addWeapon "SidewinderLaucher_F35"; _object addMagazine "2Rnd_Sidewinder_F35"; _object addWeapon "BombLauncherF35"; _object addMagazine "2Rnd_GBU12"; _object attachto [player,[0.0,5.0,2]]; _object setfuel 0.5; sleep 3; detach _object; player reveal _object; cutText [format["You've made a AH6J!"], "PLAIN DOWN"]; r_interrupt = false; player switchMove ""; player playActionNow "stop"; sleep 10; cutText [format["Warning: Spawned AH6Js DO NOT SAVE after server restart!"], "PLAIN DOWN"]; };
What? Don't judge me. I pay the rent on the server, and if I decide I was a little bird with a Gau-8, helfire, and GBU-12s then I'mma spawn it!
What I'd like to do is convert this script so I can pass a vehicle classname to it in the extra rc file, but I'm not clear on how this works. I think what I need to do is something like this, but I can't get the syntax right.
script = [bAF_Apache_AH1_D] "execVM 'custom\admindeploy\opah6j.sqf'";
then
_itemsPlayer = items player; if (dayz_combat == 1) then { cutText [format["You are in Combat and cannot build an AH6J."], "PLAIN DOWN"]; } else { player playActionNow "Medic"; r_interrupt = false; _dis=10; sleep 6; _object = %1 createVehicle (position player); _object setVariable ["ObjectID", "1", true]; _object setVariable ["ObjectUID", "1", true]; _object setVariable ["MalSar",1,true]; _object addWeapon "GAU8"; _object addMagazine "1350Rnd_30mmAP_A10"; _object addWeapon "HellfireLauncher"; _object addMagazine "8Rnd_Hellfire"; _object addWeapon "SidewinderLaucher_F35"; _object addMagazine "2Rnd_Sidewinder_F35"; _object addWeapon "BombLauncherF35"; _object addMagazine "2Rnd_GBU12"; _object attachto [player,[0.0,5.0,2]]; _object setfuel 0.5; sleep 3; detach _object; player reveal _object; cutText [format["You've made a AH6J!"], "PLAIN DOWN"]; r_interrupt = false; player switchMove ""; player playActionNow "stop"; sleep 10; cutText [format["Warning: Spawned AH6Js DO NOT SAVE after server restart!"], "PLAIN DOWN"]; };
But that doesn't work. Am I supposed to declare a private variable like this
private ["_spawnveh"]
and then
_spawnveh = %1
and then
_object = _spawnveh createVehicle (position player);
Or maybe I'm supposed to use the (to me) strange
_spawnveh = _this select 0
Another question I have is is it ok to move this script to server side? Is there any reason it woudln't work if I called it with
/z/dayz_server/script.sqf
Any guidance is appreciated. Thank you all.