Home   Help Search Login Register  

Author Topic: Problem assigning gear at start  (Read 1435 times)

0 Members and 1 Guest are viewing this topic.

Offline Zorasht

  • Members
  • *
    • 4th Perrus Squadron
Problem assigning gear at start
« on: 08 Mar 2008, 19:07:42 »
hi.
I use a script to assign the weapons to each player. It works ok if I'm hosting, I mean, I am the server and the player.

The script is the following:
Code: [Select]
_unit = player;

switch(_unit)do
{
//sniper gear
case Sni1:
{
removeAllWeapons _unit;
{_unit removeMagazines _x} foreach magazines _unit;
_unit addMagazine "10Rnd_127x99_m107";
_unit addMagazine "10Rnd_127x99_m107";
_unit addMagazine "10Rnd_127x99_m107";
_unit addMagazine "10Rnd_127x99_m107";
_unit addMagazine "10Rnd_127x99_m107";
_unit addMagazine "10Rnd_127x99_m107";
_unit addMagazine "10Rnd_127x99_m107";
_unit addMagazine "10Rnd_127x99_m107";
_unit addWeapon "M107";
_unit selectWeapon "M107";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addWeapon "M9SD";
_unit addMagazine "HandGrenade";
_unit addMagazine "HandGrenade";
_unit addMagazine "SmokeShell";
_unit addMagazine "SmokeShell";
_unit addWeapon "Binocular";
_unit addWeapon "NVGoggles";

};
//Spotter gear
case Spo1:
{
removeAllWeapons _unit;
{_unit removeMagazines _x} foreach magazines _unit;
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addMagazine "30Rnd_556x45_StanagSD" ;
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addMagazine "30Rnd_556x45_StanagSD";
_unit addWeapon "wip_m4acog_sd";
_unit selectWeapon "wip_m4acog_sd";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addMagazine "15Rnd_9x19_M9SD";
_unit addWeapon "M9SD";
_unit addMagazine "LaserBatteries";
_unit addWeapon "LaserDesignator";
_unit addMagazine "HandGrenade";
_unit addMagazine "HandGrenade";
_unit addWeapon "NVGoggles";

};

//standard gear(rest of soldiers)
default
{
removeAllWeapons _unit;
{_unit removeMagazines _x} foreach magazines _unit;
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "HandGrenade";
_unit addMagazine "SmokeShell";
_unit addMagazine "1Rnd_HE_M203";
_unit addMagazine "1Rnd_HE_M203";
_unit addMagazine "1Rnd_HE_M203";
_unit addMagazine "1Rnd_HE_M203";
_unit addMagazine "1Rnd_HE_M203";
_unit addMagazine "1Rnd_HE_M203";
_unit addMagazine "1Rnd_HE_M203";
_unit addMagazine "1Rnd_HE_M203";
_unit addWeapon "wip_m4aim_m203_sd";
_unit selectWeapon "wip_m4aim_m203_sd";
_unit addWeapon "NVGoggles";

};
};
I call the script in my init.sqf and as I said, it works fine if I am the player and the host.
However, it doesn't work when I uploaded to our dedicated server. It just load the default unit gear.

Any idea why is this happening?

Thanks in advance.
"When you're pushed, killing is as easy as breathing"
John Rambo

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Problem assigning gear at start
« Reply #1 on: 09 Mar 2008, 10:31:10 »
There are a number of issues with assigning equipment in MP (on dedicated clients). e.g. you must:
  • wait until the client has been assigned a player object (waitUntil { not (isNull player) };
  • wait until after the game has assigned the default weapons, otherwise your changes might be unset (This might just be for AI; I can't remember any more).
  • re-equip soldiers manually at respawn or they go back to default configured equipment

I would highly recommend you use my SPON Kits script for this, which does exactly what you desire and overcomes all the above issues as well as a few others (to the best of my knowledge, anyway :whistle:). Any problems with installation, just ask in the release thread.

If you really don't want to use my script, then you could always just look at it to learn how to overcome the problems with your script.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Zorasht

  • Members
  • *
    • 4th Perrus Squadron
Re: Problem assigning gear at start
« Reply #2 on: 09 Mar 2008, 15:57:50 »
Thanks. Your script is perfect  :clap:
The funny thing is that I looked in your list of script and I missed it.  :dunno:
I works very nice, and the kits are very easy to modify.

I'm not looking no more.  :D
"When you're pushed, killing is as easy as breathing"
John Rambo