Jump to content
Sign in to follow this  
aceking

Weapon and Magazine Limit Script

Recommended Posts

I am looking for a script that will work in MP where I can choose what kinds of weapons and magazines each specific players can take from an ammocrate. Does anyone have any such script or can me one? Something like the Domination weapon limit script, but I don't know how to implement that in a regular MP coop mission. The purpose of this script is so that each player can only take the weapons and magazines for his designated role.

Share this post


Link to post
Share on other sites

To define the weapons you want your players to have, use the Addweapon and addmagazine commands in conjunction with removeallweapons.

In INIT line of a man:

removeallweapons this; this addweapon "M16A4"; this addmagazine "30Rnd_556x45_Stanag";

etc.

Edited by speeder

Share this post


Link to post
Share on other sites

here is something you can test, read instructions in top of script, should be pretty self explanatory:

/*
Different Ammobox v 1.0
by Demonized.

1: place a marker named DMZ_DA anywhere you want the players to see their ammobox, all will see their box in same position.
2: place this in init line of any unit.
	_null = this execVM "DMZ_DA.sqf";
3: save this script as DMZ_DA.sqf and place it in your mission folder.

For more classnames on ammoboxes or weapons and magazines go here:
	http://forums.bistudio.com/showthread.php?t=73241&page=2
*/

_marker = "DMZ_DA";  // marker used to spawn.
_boxType = "USBasicWeapons_EP1";  // the type of ammobox used.
_timer = 600;  // time in seconds until box is refilled.

if (_this != player) exitWith {};  // exit all other clients.
_weapons = []; _magazines = [];

// load available to unitname1 only.
if (_this == unitname1) then {
_weapons = 
[
	["SCAR_L_CQC_EGLM_Holo",1],
	["SCAR_L_STD_EGLM_RCO",1],
	["SCAR_L_STD_EGLM_TWS",1],
	["HandGrenade_West",3]  // notice that there is no , at the end of the last weapon.
];

_magazines = 
[
	["30Rnd_556x45_Stanag",20],
	["1Rnd_HE_M203",5],
	["1Rnd_Smoke_M203",5]  // notice that there is no , at the end of the last magazine.

];
};

// load available to unitname2 only.
if (_this == unitname2) then {
_weapons = 
[
	["m107_TWS_EP1",1],
	["SmokeShell",3]  // notice that there is no , at the end of the last weapon.
];

_magazines = 
[
	["10Rnd_127x99_m107",10]  // notice that there is no , at the end of the last magazine.
];
};

// create and fill the box.
_box = _boxType createVehicleLocal (getMarkerPos _marker);
_box allowDamage false;

while {true} do {
// empty it.
clearWeaponCargo _box;
clearMagazineCargo _box;

// add in all weapons.
{_box addWeaponCargo [(_x select 0),(_x select 1)]} foreach _weapons;

// add in all magazines.
{_box addMagazineCargo [(_x select 0),(_x select 1)]} foreach _magazines;

// wait x amount of seconds then refill box.
sleep _timer;
};

Edited by Demonized

Share this post


Link to post
Share on other sites
here is something you can test, read instructions in top of script, should be pretty self explanatory:

/*
Different Ammobox v 1.0
by Demonized.

1: place a marker named DMZ_DA anywhere you want the players to see their ammobox, all will see their box in same position.
2: place this in init line of any unit.
	_null = this execVM "DMZ_DA.sqf";
3: save this script as DMZ_DA.sqf and place it in your mission folder.

For more classnames on ammoboxes or weapons and magazines go here:
	http://forums.bistudio.com/showthread.php?t=73241&page=2
*/

_marker = "DMZ_DA";  // marker used to spawn.
_boxType = "USBasicWeapons_EP1";  // the type of ammobox used.
_timer = 600;  // time in seconds until box is refilled.

if (_this != player) exitWith {};  // exit all other clients.
_weapons = []; _magazines = [];

// load available to unitname1 only.
if (_this == unitname1) then {
_weapons = 
[
	["SCAR_L_CQC_EGLM_Holo",1],
	["SCAR_L_STD_EGLM_RCO",1],
	["SCAR_L_STD_EGLM_TWS",1],
	["HandGrenade_West",3]  // notice that there is no , at the end of the last weapon.
];

_magazines = 
[
	["30Rnd_556x45_Stanag",20],
	["1Rnd_HE_M203",5],
	["1Rnd_Smoke_M203",5]  // notice that there is no , at the end of the last magazine.

];
};

// load available to unitname2 only.
if (_this == unitname2) then {
_weapons = 
[
	["m107_TWS_EP1",1],
	["SmokeShell",3]  // notice that there is no , at the end of the last weapon.
];

_magazines = 
[
	["10Rnd_127x99_m107",10]  // notice that there is no , at the end of the last magazine.
];
};

// create and fill the box.
_box = _boxType createVehicleLocal (getMarkerPos _marker);
_box allowDamage false;

while {true} do {
// empty it.
clearWeaponCargo _box;
clearMagazineCargo _box;

// add in all weapons.
{_box addWeaponCargo [(_x select 0),(_x select 1)]} foreach _weapons;

// add in all magazines.
{_box addMagazineCargo [(_x select 0),(_x select 1)]} foreach _magazines;

// wait x amount of seconds then refill box.
sleep _timer;
};

ah, this looks like what I'm looking for. how can i make it so that i can correctly assign multiple units to a loadout availability, such as like this==[unit1, unit2, unit3]. (im not good at scripting so thats the best i can explain what im talking about, im guessing this is an array, but i don't know how to type it correctly that it will work. i have over 30 slots, so i don't wanna have to put a whole bunch of blocks for every unit in the script

Edited by aceking

Share this post


Link to post
Share on other sites

You might want to consider a mix between Dominations method of limiting what you can pick up, with Dominations (needs modifications) method of handling ammo boxes on a local level.

So that in an ammobox you will only see the weapons you're allowed to pickup, unlike seeing a shitload of stuff that will only be frustrating not to be able to pickup. But it depends on what kind of mission. If going for something realistic, and only have limited selections in the first place, limited weapon pickup alone may be suitable.

Also you should be careful limiting ammo pickups, as often people carry ammo for eachother, typically for squad weapons like MAAWS, M240, and even M249.

Share this post


Link to post
Share on other sites
how can i make it so that i can correctly assign multiple units to a loadout availability, such as like this==[unit1, unit2, unit3].

You were looking for the in command.

replace this for unitname1 only:

if (_this == unitname1) then {

with this for multiple units unitname1,unit2,rambo,MJ:

if (_this in [unitname1,unit2,rambo,MJ]) then {

Share this post


Link to post
Share on other sites

nice, it seems to work well, thx for the help Demonized. i got a question tho... if a gave a player a weapon with the addWeapon command in his init, and if he was to place that weapon into the DMZ_DA ammo crate as a result of swapping for another weapon, then would other players be able to see that weapon he placed in there and be able to take it?

Share this post


Link to post
Share on other sites
nice, it seems to work well, thx for the help Demonized. i got a question tho... if a gave a player a weapon with the addWeapon command in his init, and if he was to place that weapon into the DMZ_DA ammo crate as a result of swapping for another weapon, then would other players be able to see that weapon he placed in there and be able to take it?

no, each player has its own ammocrate, player 1 will never see whats in player 2 box.

they all think they pick out of same box, but there really is just an illusion :D

if he drops on ground, then other players would see ofc, and if player puts something inside box, then when it refills it, it will remove all weapons and addd what you specified at start in script.

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
Sign in to follow this  

×