Advertisement

Author Topic: Change weapon script help [SOLVED]  (Read 843 times)

0 Members and 1 Guest are viewing this topic.

Offline RicoADF

  • Members
  • *
Change weapon script help [SOLVED]
« on: 25 Jan 2009, 20:26:19 »
Aim: To be able to change the F-35's loadout in mission from some preset loadouts.

Method: I need to make a script that changes the loadout of the plane when the script is activate by a user action, this script needs to remove the old loadout and add the new one. It doens't need to turn textures on and off since all the weapons are internal and thus invisible to the player anyway, I just need to change the loadout of the plane itself so the player can drop a different bomb for example.

I've tryed some ideas on how to do it but Franzes way is way too complex, I'm after a script that simply reloads the plane depending on which action menue you choose, eg: if you choose "CAS" action menue then the action menue would call up the CAS script that removes all weapons and adds the weapons its been told to add.
Also this needs to be MP friendly.

I know this is far from easy, but should be easier then a full change weapon script that needs to turn hidden selections on etc, so I'm hoping someone out there has the knowledge (and will) to help.

Thanks for any help and sorry if I've put this in the wrong section

EDIT: Ok I got a script made, it works, I'm just doing a last touchup to fix a minor bug and then its finished  :good:, thanks goes to Loki for the help. Once done I'll post the script and User action menues so others can use it if they choose to do so  :)

EDIT #2:
Heres the User actions:
Code: [Select]
class ArmAir_1
{
displayName ="Arm GBU-32";
position = "pilotcontrol";
radius =15;
condition = "(this distance (nearestObject [this, ""Truck5tReammo""]) < 15) && (damage (nearestObject [this, ""Truck5tReammo""]) < 1) && (speed this < 1) && (getpos this select 2< 1)";
statement = "this execvm ""\GDI_AD\scripts\arm_GBU32.sqf""; ";
onlyforplayer = False;
};
class ArmAir_2
{
displayName ="Arm GBU-39";
position = "pilotcontrol";
radius =15;
condition = "(this distance (nearestObject [this, ""Truck5tReammo""]) < 15) && (damage (nearestObject [this, ""Truck5tReammo""]) < 1) && (speed this < 1) && (getpos this select 2< 1)";
statement = "this execvm ""\GDI_AD\scripts\arm_GBU39.sqf""; ";
onlyforplayer = False;
};
Heres the script:
Code: [Select]

hint "Air Vehicle Re-armed...";

private ["_types"];


_types = ["GDI_F35"];


if ((typeOf (vehicle player)) in _types) then
{


(vehicle player) removeWeapon "GDIJDAM39Launcher";
(vehicle player) removeMagazine "GDI2Rnd_GBU32";
(vehicle player) removeMagazine "GDI8Rnd_GBU39";
(vehicle player) addMagazine "GDI2Rnd_GBU32";
(vehicle player) addWeapon "GDIJDAM32Launcher";


};
GDI_F35 is the plane
JDAM32 is the weapon being attached, and the JDAM39 is the weapon being removed as well as their mags accordingly, if anyone has issues understanding and wants to get this working just ask, otherwise its set  :good:
Once again thanks to Loki, top bloke  :clap:
« Last Edit: 25 Jan 2009, 23:51:14 by RicoADF »