Home   Help Search Login Register  

Author Topic: Loadout works only in a listen server not in a dedicated  (Read 2675 times)

0 Members and 1 Guest are viewing this topic.

Offline erebus1

  • Members
  • *
I have a script that is not working in 1.06 us version, Im not sure but I think it worked on the german 1.04 version.

Its a custom loadout script that removes all the weapons from the ammo boxes and then puts every weapon in the game back into it... and also i have a few loadouts for squad officers and a long range sniper loadout.

The ammo box loadouts work in a listen and dedicated server, the westofficer and westlrsniper only work in a listen server, and the officer and sniper get their default loadouts when the mission is run on a dedicated server.... anyone have any idea how to fix this?

heres the ammo.sqs file, and I exec it with  [this,"westofficer"] exec "ammo.sqs"

Code: [Select]
; *****************************************************
; EXAMPLE:
; Type this code into the INITIALIZATION box of the crate.
; [this,"eastlight" or "eastheavy"] Exec "ammo.sqs"
; *****************************************************

; Get the parameters given
_crate = _this Select 0
_loadout = _this Select 1

goto _loadout

#eastheavy
clearmagazinecargo _crate
clearweaponcargo _crate
_crate AddWeaponCargo ["AK74",10]
_crate AddWeaponCargo ["AK74GL",10]
_crate AddWeaponCargo ["AKS74U",10]
_crate AddWeaponCargo ["AKS74UN",10]
_crate AddWeaponCargo ["PK",10]
_crate AddWeaponCargo ["SVD",10]
_crate AddWeaponCargo ["KSVK",10]
_crate AddWeaponCargo ["Makarov",10]
_crate AddWeaponCargo ["MakarovSD",10]
_crate AddWeaponCargo ["RPG7V",10]
_crate AddWeaponCargo ["STRELA",10]
_crate AddWeaponCargo ["NVgoggles",50]
_crate AddWeaponCargo ["Binocular",50]
_crate AddMagazineCargo ["30Rnd_545x39_AK",50]
_crate AddMagazineCargo ["30Rnd_545x39_AKSD",50]
_crate AddMagazineCargo ["FlareWhite_GP25",20]
_crate AddMagazineCargo ["FlareGreen_GP25",20]
_crate AddMagazineCargo ["FlareYellow_GP25",20]
_crate AddMagazineCargo ["SmokeShellRed",20]
_crate AddMagazineCargo ["SmokeShellGreen",20]
_crate AddMagazineCargo ["SmokeShell",20]
_crate AddMagazineCargo ["1Rnd_HE_GP25",50]
_crate AddMagazineCargo ["FlareRed_GP25",20]
_crate AddMagazineCargo ["100Rnd_762x54_PK",50]
_crate AddMagazineCargo ["10Rnd_762x54_SVD",50]
_crate AddMagazineCargo ["5Rnd_127x108_KSVK",50]
_crate AddMagazineCargo ["8Rnd_9x18_Makarov",50]
_crate AddMagazineCargo ["8Rnd_9x18_MakarovSD",50]
_crate AddMagazineCargo ["PG7V",50]
_crate AddMagazineCargo ["PG7VR",50]
_crate AddMagazineCargo ["STRELA",50]
_crate AddMagazineCargo ["Pipebomb",50]
_crate AddMagazineCargo ["HandGrenade",50]
_crate AddMagazineCargo ["Mine",50]
_crate AddMagazineCargo ["MineE",50]
goto "done"

#westheavy
clearmagazinecargo _crate
clearweaponcargo _crate
_crate AddWeaponCargo ["M16A2",10]
_crate AddWeaponCargo ["M16A2GL",10]
_crate AddWeaponCargo ["M4",10]
_crate AddWeaponCargo ["M4GL",10]
_crate AddWeaponCargo ["M4AIM",10]
_crate AddWeaponCargo ["M4A1SD",10]
_crate AddWeaponCargo ["M4SPR",10]
_crate AddWeaponCargo ["M4A1",10]
_crate AddWeaponCargo ["M4A1GL",10]
_crate AddWeaponCargo ["G36K",10]
_crate AddWeaponCargo ["G36C",10]
_crate AddWeaponCargo ["G36A",10]
_crate AddWeaponCargo ["MP5A5",10]
_crate AddWeaponCargo ["MP5SD",10]
_crate AddWeaponCargo ["M249",10]
_crate AddWeaponCargo ["M240",10]
_crate AddWeaponCargo ["M24",10]
_crate AddWeaponCargo ["M107",10]
_crate AddWeaponCargo ["M9",10]
_crate AddWeaponCargo ["M9SD",10]
_crate AddWeaponCargo ["M136",10]
_crate AddWeaponCargo ["JAVELIN",10]
_crate AddWeaponCargo ["STINGER",10]
_crate AddWeaponCargo ["LaserDesignator",10]
_crate AddWeaponCargo ["NVgoggles",50]
_crate AddWeaponCargo ["Binocular",50]
_crate AddMagazineCargo ["30Rnd_556x45_Stanag",50]
_crate AddMagazineCargo ["30Rnd_556x45_StanagSD",50]
_crate AddMagazineCargo ["FlareWhite_M203",20]
_crate AddMagazineCargo ["FlareGreen_M203",20]
_crate AddMagazineCargo ["FlareYellow_M203",20]
_crate AddMagazineCargo ["SmokeShellRed",20]
_crate AddMagazineCargo ["SmokeShellGreen",20]
_crate AddMagazineCargo ["SmokeShell",20]
_crate AddMagazineCargo ["20Rnd_556x45_Stanag",50]
_crate AddMagazineCargo ["1Rnd_HE_M203",50]
_crate AddMagazineCargo ["FlareRed_M203",20]
_crate AddMagazineCargo ["30Rnd_556x45_G36",50]
_crate AddMagazineCargo ["200Rnd_556x45_M249",50]
_crate AddMagazineCargo ["100Rnd_762x51_M240",50]
_crate AddMagazineCargo ["5Rnd_762x51_M24",50]
_crate AddMagazineCargo ["10Rnd_127x99_M107",50]
_crate AddMagazineCargo ["30Rnd_9x19_MP5",50]
_crate AddMagazineCargo ["30Rnd_9x19_MP5SD",50]
_crate AddMagazineCargo ["15Rnd_9x19_M9",50]
_crate AddMagazineCargo ["15Rnd_9x19_M9SD",50]
_crate AddMagazineCargo ["M136",50]
_crate AddMagazineCargo ["JAVELIN",50]
_crate AddMagazineCargo ["STINGER",50]
_crate AddMagazineCargo ["Pipebomb",50]
_crate AddMagazineCargo ["HandGrenade",50]
_crate AddMagazineCargo ["Mine",50]
_crate AddMagazineCargo ["MineE",50]
_crate AddMagazineCargo ["LaserBatteries",30]
goto "done"

#westlight
clearmagazinecargo _crate
clearweaponcargo _crate
_crate AddWeaponCargo ["M4SPR",2]
_crate AddMagazineCargo ["30Rnd_556x45_Stanag",20]
_crate AddMagazineCargo ["20Rnd_556x45_Stanag",20]
_crate AddMagazineCargo ["5Rnd_762x51_M24",20]
_crate AddMagazineCargo ["Pipebomb",20]
goto "done"

#westlrsniper
removeallweapons _crate
_crate AddMagazine "10Rnd_127x99_M107"
_crate AddMagazine "10Rnd_127x99_M107"
_crate AddMagazine "10Rnd_127x99_M107"
_crate AddMagazine "10Rnd_127x99_M107"
_crate AddMagazine "10Rnd_127x99_M107"
_crate AddMagazine "10Rnd_127x99_M107"
_crate AddWeapon "M107"
_crate AddMagazine "Pipebomb"
_crate AddMagazine "Pipebomb"
_crate AddMagazine "HandGrenade"
_crate AddMagazine "SmokeShellRed"
_crate AddWeapon "Binocular"
goto "done"

#westofficer
removeallweapons _crate
_crate AddMagazine "30Rnd_556x45_Stanag"
_crate AddMagazine "30Rnd_556x45_Stanag"
_crate AddMagazine "30Rnd_556x45_Stanag"
_crate AddMagazine "30Rnd_556x45_Stanag"
_crate AddMagazine "30Rnd_556x45_Stanag"
_crate AddMagazine "30Rnd_556x45_Stanag"
_crate AddWeapon "M16A2"
_crate AddMagazine "M136"
_crate AddMagazine "M136"
_crate AddWeapon "M136"
_crate AddMagazine "SmokeShellRed"
_crate AddMagazine "SmokeShellRed"
;_crate AddWeapon "SmokeShellRed"
_crate AddWeapon "Binocular"
goto "done"

#done
exit

thanks for the help

Offline erebus1

  • Members
  • *
Re: Loadout works only in a listen server not in a dedicated
« Reply #1 on: 16 May 2007, 01:47:52 »
anyone?

I placed a game logic named server and tried

if (local server) then [this,"westofficer"] exec "ammo.sqs"
and also
if !(local server) then [this,"westofficer"] exec "ammo.sqs"

and both failed to add the weapons to the westofficer, but in the editor preview the if (local server) works.

WTF

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Loadout works only in a listen server not in a dedicated
« Reply #2 on: 16 May 2007, 21:55:50 »
Put all lines of the type [this,"westofficer"] exec "ammo.sqs" in the init.sqs not in the init field for each crate. (If you use an init.sqf make sure to add a semi-colon to the each of each line.
urp!

Offline erebus1

  • Members
  • *
Re: Loadout works only in a listen server not in a dedicated
« Reply #3 on: 16 May 2007, 23:18:15 »
thanks, I knew that fixed it, but ... Im also interested in why it fixed it.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Loadout works only in a listen server not in a dedicated
« Reply #4 on: 17 May 2007, 02:09:05 »
I not not 100% sure of the reason, though this behaviour was the same for OFP.  The loadout code needs to run on every machine, but for some reason code placed in the init field of a unit/vehicle is not guaranteed to do this. It looks like the code ran only on the server so on a listen server the player on the server would have the loadout, but no one else would. By placing the code in the init.sqf it is guaranteed to run on every machine. I rarely use the init field but when I do I make sure it does not matter if the code snippet inside only runs locally.

Chris Death had an interesting thread researching the relative order in which init fields get processed. Would I be correct in assuming that that are a lot of units on this map?

Edit: found that thread. It is here. Good stuff.
« Last Edit: 17 May 2007, 02:58:47 by Mr.Peanut »
urp!

Offline erebus1

  • Members
  • *
Re: Loadout works only in a listen server not in a dedicated
« Reply #5 on: 17 May 2007, 02:44:41 »
there isn't alot of units getting the loadout, but it is so much easier to change a few lines in a sqs file then have to fire up the editor and go through the whole process of checking and changing half a dozen different units init fields...

plus I am really interested in finding out the reasons for some things, so I can write better code.

Well thanks for the help, I guess ill just have to put it in the init fields until there is better documentation from bis.