OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: granQ on 11 Nov 2008, 12:18:03
-
Hello..
Just checking if anyone got some good ideas to do this, want to do it for carry static weapons.. but it has to spawn magazines you can't carry on the ground.
-
I do not understand what you are asking here.
-
Same, can you elaborate granQ?
-
I think I know what you are saying. You want to have a player, or trigger, spawn a static weapon. You also want that player to have an increased amount of ammo. Is that right?
I believe you want is the command: creatVehicle. Checkout the link below.
http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=c#442 (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=c#442)
Someone correct me if I'm wrong. You could use creatVehicle to spawn a static weapon with a higher number of mags on it.
-
Well, see if I can express myself more clearly after a few beers.
Must first say I understand you don't understand my question since i barely did it myself.
But what I want to do is the following:
Spawning 1 (one) weapon on the ground, no matter how many clients there is connected.
That is what I want to do, the application for it would be for making a static vehicle that soldiers could carry much like in FDF/wgl.. (or old sfp.. but can't get our old code working)
-
You create a weapon holder, in it's init you place the commands to add the weapons/magazines to the holder.
-
G'day, this may or may not help, it is a WIP but I think it will work in MP from my tests
First you need to create an Invisable Heli pad, name it "sack" (the name is unimportant really) and add the to it's INIT
nil = [this] execVM "weaponsack.sqf"
Now all you need to do is add these two scripts to your mission folder.
weaponsack.sqf
//////////////////////////////////////////////////////////////////
// weaponsack.sqf
// Created by: Odin
//
// USAGE: Create an invisable Heli pad at the desired position and name it "sack"
// in its init write this line;
// nil = [this] execVM "weaponsack.sqf"
//
// When the game starts the weapons an ammo will be at the "sack" position, approach the sack
// and either choose a weapon or choose "Carry Sack", if you choose to carry it it will be deleted
// and a new action will be added "Drop Sack", move it to where ever you want and Drop it. A Marker will
// be created at the position.
//////////////////////////////////////////////////////////////////
_caller = _this select 1;
//id = _this select 2; // action param
if (_caller != player) exitWith {};
_caller removeAction dropsack;
myStash = _this select 0;
idsack = format["%1WeaponSack",(name player)];
if (_caller == player) then
{
_caller playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 3.0;
WaitUntil {animationState _caller != "AinvPknlMstpSlayWrflDnon_medic"};
sleep 0.1;
_pos = position myStash;
_plrTag = format["%1's WeaponSack",(name player)];
sackmarker = createMarker [idsack, _pos];
sackmarker setMarkerShape "ICON";
sackmarker setMarkerType "Marker";
sackmarker setMarkerColor "ColorRedAlpha";
sackmarker setMarkerText _plrTag;
sackmarker setMarkerSize [0.5, 0.5];
sackmarker setMarkerDir 45;
};
// Create WeaponHolder ====>
myRifle = "weaponholder" Createvehicle position myStash;
// Sniper Rifle ====>
myRifle addMagazineCargo ["10Rnd_127x99_M107",30];
myRifle addWeaponCargo ["m107",1];
myRifle addMagazineCargo ["5Rnd_762x51_M24",30];
myRifle addWeaponCargo ["M24",1];
// Rifle ====>
myRifle addMagazineCargo ["30Rnd_556x45_Stanag",30];
myRifle addWeaponCargo ["M4SPR",1];
// Rifle GL ====>
myRifle addMagazineCargo ["30Rnd_556x45_Stanag",30];
myRifle addMagazineCargo ["1Rnd_HE_M203",30];
myRifle addWeaponCargo ["M4A1GL",1];
// RPG ====>
myRifle addMagazineCargo ["M136",30];
myRifle addWeaponCargo ["M136",1];
// MG ====>
myRifle addMagazineCargo ["100Rnd_762x51_M240",30];
myRifle addWeaponCargo ["M240",1];
// Pistol ====>
myRifle addMagazineCargo ["15Rnd_9x19_M9",30];
myRifle addWeaponCargo ["M9",1];
// NVG ====>
myRifle addWeaponCargo ["NVGoggles",1];
// Mines and Thrown ====>
myRifle addMagazineCargo ["PipeBomb",5];
myRifle addMagazineCargo ["Mine",5];
myRifle addMagazineCargo ["HandGrenade",5];
myRifle setPosASL [ (getPosASL myStash select 0) + 0.199, (getPosASL myStash select 1) - 0.199, getPosASL myStash select 2];
// Mystery Object to AddAction to ====>
bogus = "bomb" Createvehicle position myStash;
bogus setPosASL [ (getPosASL myStash select 0) + 0.599, (getPosASL myStash select 1) - 0.599, getPosASL myStash select 2];
carrysack = bogus addAction ["Carry Sack", "carry.sqf"];
if (true) exitWith {};
carry.sqf
//////////////////////////////////////////////////////////////////
// carry.sqf
// Created by: Odin
//
// USAGE: Used in conjunction with the weaponsack.sqf,
// nothing need's to be done to make it work as it is called via the weaponsack.sqf
//////////////////////////////////////////////////////////////////
_caller = _this select 1;
//id = _this select 2; // action param
if (_caller != player) exitWith {};
_caller playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 3.0;
WaitUntil {animationState _caller != "AinvPknlMstpSlayWrflDnon_medic"};
sleep 0.1;
deleteMarker idsack;
bogus removeAction carrysack;
deleteVehicle myStash;
deleteVehicle myRifle;
deleteVehicle bogus;
dropsack = _caller addAction ["Drop Sack", "weaponsack.sqf"];
That is it :good:
If you Don't want that many weapons just alter it to suit BUT you must leave the bogus obj as this is how the action is called to carry the sack. If you use this could you let me know if it works in MP for you?
GL
Odin
-
But what I want to do is the following:
Spawning 1 (one) weapon on the ground, no matter how many clients there is connected.
- 1) Create a dummy unit somewhere off-map (eg at [0,0,0])
- 2) Remove all his weapons and mags
- 3) Add the weapon you wish to have "spawned" to that dummy unit
- 4) setPos the dummy at the desired drop point, but say 1000 m in the air
- 5) _dummy action ["DROPWEAPON", _dummy, "WeaponClassName"];
- 6) Wait one or two seconds
- 7) deleteVehicle _dummy
EDIT: It would seem that the setVehicleInit soluton suggested below works as it should in MP, and is a better solution than this old "dummy trick".
-
With the created weapon holder object you may use setVehicleInit command and then processinitcommands to ensure this is executed in every connected client.