Jump to content
Sign in to follow this  
fuerst_von_butz

Player localized crates

Recommended Posts

Hello,

I would like to have player localized crates in my coop mission, that means every player sees a crate at the same position but with different content. And I think I already achieved this, but I would like some advanced scripters to check my solution, mainly for me to improve.

- placed a maker with name ammo_local

- placed a trigger with condition local player; and on activation nul = ["ammo_local"] execVM "scripts\ammo_local.sqf";

- named the playable units s01, s02, s03...

And this is the script:

// Locality: Players only
if (isDedicated) exitWith {};

// Variables
_crate_pos = getMarkerPos (_this select 0);
_crate = "Box_NATO_Wps_F" createVehicleLocal _crate_pos;

// Get started
clearMagazineCargo _crate;
clearWeaponCargo _crate;

switch (player) do {
case s01: {
	// Ammo
	_crate addMagazineCargo ["30Rnd_65x39_caseless_green_mag_Tracer", 16];

	// Basic Gear
	_crate addWeaponCargo ["arifle_MX_F", 1];
	_crate addWeaponCargo ["arifle_MXM_F", 2];
	_crate addWeaponCargo ["arifle_MXC_F", 3];

	_crate addWeaponCargo ["optic_Hamr", 3];
	_crate addWeaponCargo ["optic_Arco", 4];
	_crate addWeaponCargo ["optic_Holosight", 5];
};

case s02: {};

case s03: {};
};

This works in the editor preview, as player s01 I see the specified content. Will this work on a dedicated server? Are there caveats?

Side question: Why am I not able to use those optics on any of those weapons, is it a bug?

Cheers!

Share this post


Link to post
Share on other sites

That's a pretty solid plan. There's a fillcrate script from Tonic that does something similar, hides the global box and replaced it with a local copy.

_box = _this select 0;
_type = _this select 1;
// snip
_bType = typeOf _box;
_bPos = getPos _box;

//Hide the global ammo box & create a local one *temp fix for locality issues).
if(!local _box) then
{
   _box hideObject true;
   _boxn = _bType createVehicleLocal [0,0,0];
   _boxn setPosATL [_bPos select 0,_bPos select 1,0];

}
   else
{
   _boxn = _box;
};

clearWeaponCargo _boxn;
clearMagazineCargo _boxn;
clearItemCargo _boxn;
clearBackpackCargo _boxn;
// more script

From @file Version: v0.2

@file name: fillCrate.sqf

@file Author: TAW_Tonic

Share this post


Link to post
Share on other sites
Side question: Why am I not able to use those optics on any of those weapons, is it a bug?
Use addItemCargo for the scopes instead.

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  

×