Jump to content
darkxess

Problem with MP Ammo Box Script

Recommended Posts

Hey guys, I am trying to get this to work on a dedicated server and it just keeps throwing up an error message - I have tried to find the problem but still with no result. Help please? thanks :)


if (!isServer) exitWith {};
private "_crate";

_crate = _this select 0;


while {alive _crate} do
{

// Clear box
ClearWeaponCargoGlobal _this;
ClearMagazineCargoGlobal _this;
ClearItemCargoGlobal _this;
ClearBackpackCargoGlobal _this;


// Weapons

_this addWeaponCargo ["hgun_Pistol_heavy_01_F",20];
_this addWeaponCargo ["arifle_MXC_F",20];
_this addWeaponCargo ["arifle_MX_SW_F",20];
_this addWeaponCargo ["srifle_EBR_Hamr_pointer_F",20];
_this addWeaponCargo ["LMG_Mk200_F",20];
_this addWeaponCargo ["srifle_LRR_LRPS_F",20];

// Ammo

_this addMagazineCargo ["30Rnd_65x39_caseless_mag",100];
_this addMagazineCargo ["100Rnd_65x39_caseless_mag",100];
_this addMagazineCargo ["11Rnd_45ACP_Mag",100];
_this addMagazineCargo ["20Rnd_762x51_Mag",100];
_this addMagazineCargo ["200Rnd_65x39_cased_Box",100];
_this addMagazineCargo ["7Rnd_408_Mag",100];
_this addMagazineCargo ["MiniGrenade",100];
_this addMagazineCargo ["HandGrenade",100];

// Items

_this addItemCargo ["Binocular",5];

sleep 100;
};



 

Share this post


Link to post
Share on other sites

I'm assuming that you're running the script through the crate's init. If not, the script won't work.

When calling the script through an init, "_this select 0" is selecting the unit or object that called the script. Change "_this" to "_crate".

 

For example, this:

// Clear box
ClearWeaponCargoGlobal _this;
ClearMagazineCargoGlobal _this;
ClearItemCargoGlobal _this;
ClearBackpackCargoGlobal _this;

Becomes this:

// Clear box
ClearWeaponCargoGlobal _crate;
ClearMagazineCargoGlobal _crate;
ClearItemCargoGlobal _crate;
ClearBackpackCargoGlobal _crate;

and so on...

Share this post


Link to post
Share on other sites

So everything else such as:

 

_this addWeaponCargo ["hgun_Pistol_heavy_01_F",20];

Will become:
 

_crate addWeaponCargo ["hgun_Pistol_heavy_01_F",20];

Correct?

Share this post


Link to post
Share on other sites
Just now, darkxess said:

So everything else such as:

 


_this addWeaponCargo ["hgun_Pistol_heavy_01_F",20];

Will become:
 


_crate addWeaponCargo ["hgun_Pistol_heavy_01_F",20];

Correct?

 

Correct, just leave "_crate = _this select 0" the same. You're basically creating a shortcut for "_this select 0" which you can call by entering "_cache".

Share this post


Link to post
Share on other sites

Ok, this is how it is now:

 


if (!isServer) exitWith {};
private "_crate";

_crate = _this select 0;


while {alive _crate} do
{

// Clear box
ClearWeaponCargoGlobal _crate;
ClearMagazineCargoGlobal _crate;
ClearItemCargoGlobal _crate;
ClearBackpackCargoGlobal _crate;


// Weapons

_crate addWeaponCargo ["hgun_Pistol_heavy_01_F",20];
_crate addWeaponCargo ["arifle_MXC_F",20];
_crate addWeaponCargo ["arifle_MX_SW_F",20];
_crate addWeaponCargo ["srifle_EBR_Hamr_pointer_F",20];
_crate addWeaponCargo ["LMG_Mk200_F",20];
_crate addWeaponCargo ["srifle_LRR_LRPS_F",20];

// Ammo

_crate addMagazineCargo ["30Rnd_65x39_caseless_mag",100];
_crate addMagazineCargo ["100Rnd_65x39_caseless_mag",100];
_crate addMagazineCargo ["11Rnd_45ACP_Mag",100];
_crate addMagazineCargo ["20Rnd_762x51_Mag",100];
_crate addMagazineCargo ["200Rnd_65x39_cased_Box",100];
_crate addMagazineCargo ["7Rnd_408_Mag",100];
_crate addMagazineCargo ["MiniGrenade",100];
_crate addMagazineCargo ["HandGrenade",100];

// Items

_crate addItemCargo ["Binocular",5];

sleep 100;
};


And I am calling it in the init of the box as such:
 

nul =[this] execVM "scripts\AmmoBox.sqf";

But when I go into game the box is empty. Nothing at all is in it :(

Share this post


Link to post
Share on other sites
20 minutes ago, darkxess said:

I am calling it in the init of the box as such:
 


nul =[this] execVM "scripts\AmmoBox.sqf";

But when I go into game the box is empty. Nothing at all is in it :(

 

I tested your script almost the exact same way, but my init was slightly different.

 

null = [this] execVM "BlahBlahBlah";

Maybe your lack of a space between "=" and "[this]" is messing it up.

Share this post


Link to post
Share on other sites

Still not working for me, its working fine client side, but upon loading it to my dedicated server there is nothing in the box. It's as if it doesn't work for a dedicated server.

Share this post


Link to post
Share on other sites
29 minutes ago, darkxess said:

its working fine client side, but upon loading it to my dedicated server there is nothing in the box.

 

Change

if (!isServer) exitWith {};

to

if (!isServer || !isDedicated) exitWith {};

or remove the line completey, and see if it works then.

I'm not familiar with scripting on dedicated servers, but that may be the issue. It's weird though, considering the "isServer" wiki page states that "isServer will return true for both, dedicated server and player hosted."

 

Edit: My script change will probably have the same effect. Whoopsie... Use this code:

if (!isDedicated) exitWith {};

 

Edited by rebitaay

Share this post


Link to post
Share on other sites

This is starting to pee me off now :(

I tried all of the below:

 

if (!isServer || !isDedicated) exitWith {};
if (!isDedicated) exitWith {};
if (!isServer) exitWith {};

And still nothing server side. Client side yes its working perfect, but I need this to work on my server.... grrrr

Thanks for the persistent help anyways :)

  • Like 1

Share this post


Link to post
Share on other sites
Just now, darkxess said:

Thanks for the persistent help anyways :)

 

No worries, I'm also sitting here smacking my head on the keyboard trying to get a script to work with no luck.

One last thing you can try is to just remove that line completely. If that doesn't work, I'm not sure what will, hopefully someone more experience in the subject will come along and give you an answer.

 

Good luck!

  • Like 1

Share this post


Link to post
Share on other sites

Forgot to mention that, I did remove it yes, still with no luck. Like I said, its working fine client side, exactly to how I've set it up. 

Clears the box, fills the box with what I put, everything. But server side there is nothing there lol.... :P

Share this post


Link to post
Share on other sites

Its running on the server ( dedicated ) but you are only using the local cargo commands. Use the global variants addWeaponCargoGlobal etc

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, Larrow said:

Its running on the server ( dedicated ) but you are only using the local cargo commands. Use the global variants addWeaponCargoGlobal etc

 

Perfect mate, thank you so much, its working now :)

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

×