Home   Help Search Login Register  

Author Topic: Fill munition box in multiplayer  (Read 2074 times)

0 Members and 1 Guest are viewing this topic.

Offline BlackJackVr

  • Members
  • *
Fill munition box in multiplayer
« on: 02 Mar 2007, 09:12:25 »
So, i've done a script (called by an action i've attached to a munition box) that add new magazines and weapons in the munition box. This works only on the server but the client can't see any difference. How can i make it works on all pc connected to the match?

Thanks

Offline satexas69

  • Members
  • *
Re: Fill munition box in multiplayer
« Reply #1 on: 02 Mar 2007, 10:16:47 »
Here's a great script, I put in comments in the script itself telling you how to use it (dummy proof)

This is my "guns" crate - I have another I use for the LAW rockets and AA stuff.... but you'll figure it out :)

Code: [Select]
; Instructions:
;
; 1. In your mission directory, make a subdirectory called "reload" and put this
; script in it called "ammobox_1.sqs"
;
; 2. Make a crate in the game
;
; 3. PUt this as it's NAME:  ammo_1
;
; 4. Put this in the item's INIT field:   [ammo_1] exec "reload\ammobox_1.sqs
;
; Increment the ammobox tag for each individual box after that first one to load others
; IE: [ammo_2]... [ammo_5]...

; NOTE - This is my USA GUNS crate

; Get the crate parameter given
_crate = _this Select 0

; REMOVE STOCK ITEMS FROM THE CRATE:

ClearMagazineCargo _crate
ClearWeaponCargo _crate


; ADD THE ITEMS TO THE CRATE:

; West Weapons

;_crate addweaponcargo ["M21", 50]
;_crate addmagazinecargo ["M21", 50]
_crate addweaponcargo ["M9",100]
_crate addweaponcargo ["M9SD",100]
_crate addweaponcargo ["M16A2",100]
_crate addweaponcargo ["M16A2GL",100]
_crate addweaponcargo ["M4",100]
_crate addweaponcargo ["M4A1SD",100]
_crate addweaponcargo ["M4GL",100]
_crate addweaponcargo ["M4A1",100]
_crate addweaponcargo ["M4A1GL",100]
_crate addweaponcargo ["M4AIM",100]
_crate addweaponcargo ["M4SPR",100]
_crate addweaponcargo ["G36a",100]
_crate addweaponcargo ["g36c",100]
_crate addweaponcargo ["g36k",100]
_crate addweaponcargo ["m24",100]
_crate addweaponcargo ["mp5A5",100]
_crate addweaponcargo ["MP5SD",100]
_crate addweaponcargo ["M240",100]
_crate addweaponcargo ["M249",100]

_crate addweaponcargo ["M107",100]
_crate addmagazinecargo ["10Rnd_127x99_m107",100]

_crate addweaponcargo ["Laserdesignator",100]
_crate addweaponcargo ["Binocular",100]
_crate addweaponcargo ["NVGoggles",100]
_crate addmagazinecargo ["30Rnd_9x19_MP5",100]
_crate addmagazinecargo ["30Rnd_9x19_MP5SD",100]
_crate addmagazinecargo ["15Rnd_9x19_M9",100]
_crate addmagazinecargo ["15Rnd_9x19_M9SD",100]
_crate addmagazinecargo ["30Rnd_556x45_Stanag",100]
_crate addmagazinecargo ["30Rnd_556x45_G36",100]
_crate addmagazinecargo ["200Rnd_556x45_M249",100]
_crate addmagazinecargo ["5Rnd_762x51_M24",100]
_crate addmagazinecargo ["100Rnd_762x51_M240",100]
_crate addmagazinecargo ["1Rnd_HE_M203",100]
_crate addmagazinecargo ["Laserbatteries",100]


; East Weapons

_crate addweaponcargo ["PK",100]
_crate addmagazinecargo ["100Rnd_762x54_PK"]
_crate addweaponcargo ["SVD",100]
_crate addmagazinecargo ["10Rnd_762x54_SVD"]


Exit

Offline BlackJackVr

  • Members
  • *
Re: Fill munition box in multiplayer
« Reply #2 on: 02 Mar 2007, 10:42:28 »
This is my script and it works, but in multiplayer it works only on the client who exec the script, and i want that when someone reloads the crate also to the other players the crate is reloaded.

Code: [Select]
; Script che ricarica le armi e munizioni presenti nella cassa
; (primo parametro)

; Variabili locali
_cassa = _this select 0
_st = _this select 1
_qt = 10

?(_st == 1) : titleText ["Cassa munizioni rifornita!", "PLAIN"]

; Svuotamento cassa
clearWeaponCargo _cassa
clearMagazineCargo _cassa

; Riempimento cassa

; Armi
_cassa addWeaponCargo ["M16A2", _qt]
_cassa addWeaponCargo ["M16A2GL", _qt]
_cassa addWeaponCargo ["M16A4", _qt]
_cassa addWeaponCargo ["M16A4_ACG", _qt]
_cassa addWeaponCargo ["M16A4_ACG_GL", _qt]
_cassa addWeaponCargo ["M4", _qt]
_cassa addWeaponCargo ["M4GL", _qt]
_cassa addWeaponCargo ["M4AIM", _qt]
_cassa addWeaponCargo ["M4A1SD", _qt]
_cassa addWeaponCargo ["M4SPR", _qt]
_cassa addWeaponCargo ["M4A1", _qt]
_cassa addWeaponCargo ["M4A1GL", _qt]
_cassa addWeaponCargo ["G36K", _qt]
_cassa addWeaponCargo ["G36C", _qt]
_cassa addWeaponCargo ["G36A", _qt]
_cassa addWeaponCargo ["MP5A5", _qt]
_cassa addWeaponCargo ["MP5SD", _qt]
_cassa addWeaponCargo ["M249", _qt]
_cassa addWeaponCargo ["M240", _qt]
_cassa addWeaponCargo ["M24", _qt]
_cassa addWeaponCargo ["M107", _qt]
_cassa addWeaponCargo ["M9", _qt]
_cassa addWeaponCargo ["M9SD", _qt]
_cassa addWeaponCargo ["M136", _qt]
_cassa addWeaponCargo ["JAVELIN", _qt]
_cassa addWeaponCargo ["STINGER", _qt]

; Munizioni
_cassa addMagazineCargo ["30Rnd_556x45_Stanag", _qt]
_cassa addMagazineCargo ["30Rnd_556x45_StanagSD", _qt]
_cassa addMagazineCargo ["FlareWhite_M203", _qt]
_cassa addMagazineCargo ["FlareGreen_m203", _qt]
_cassa addMagazineCargo ["FlareRed_m203", _qt]
_cassa addMagazineCargo ["FlareYellow_m203", _qt]
_cassa addMagazineCargo ["1Rnd_HE_M203", _qt]
_cassa addMagazineCargo ["30Rnd_556x45_G36", _qt]
_cassa addMagazineCargo ["30Rnd_9x19_MP5", _qt]
_cassa addMagazineCargo ["30Rnd_9x19_MP5SD", _qt]
_cassa addMagazineCargo ["200Rnd_556x45_M249", _qt]
_cassa addMagazineCargo ["100Rnd_762x51_M240", _qt]
_cassa addMagazineCargo ["5Rnd_762x51_M24", _qt]
_cassa addMagazineCargo ["10Rnd_127x99_m107", _qt]
_cassa addMagazineCargo ["15Rnd_9x19_M9", _qt]
_cassa addMagazineCargo ["15Rnd_9x19_M9SD", _qt]
_cassa addMagazineCargo ["M136", _qt]
_cassa addMagazineCargo ["JAVELIN", _qt]
_cassa addMagazineCargo ["STINGER", _qt]

Offline BlackJackVr

  • Members
  • *
Re: Fill munition box in multiplayer
« Reply #3 on: 03 Mar 2007, 09:43:38 »
I've tried also with: publicVariable "BoxName" to share the value with all pc but it doesn't work.

Offline Cheetah

  • Former Staff
  • ****
Re: Fill munition box in multiplayer
« Reply #4 on: 03 Mar 2007, 10:19:27 »
Could you tell me how you trigger the script? That would provide valuable information on the cause of the problem. Because it's pretty weird that only one client can see the result of the script.

Note that I'm not a good multiplayer scripter, but here's my solution (although I don't know much about the mission / activation of ammo script).

Let's say you want to activate the script when any US soldier comes into a forest. You place down a trigger covering the forest and select " west", "present" and "switch". Give the trigger a name if you want to, might be good to always do so, but it's not required for this method.

In the On Activation field type:
Code: [Select]
ammoIncrease = true; publicVariable "ammoIncrease";

Create another trigger, don't bother about the other fields/selection boxes but go to the condition field. In the field write down:
Code: [Select]
ammoIncreaseIn the On Activation field: [] exec "YourScript.sqs";

Then place a game logic named server.

Open up your script and paste the following code at the start of it:
Code: [Select]
?!(local Server): exit
Didn't have the chance to test this, but I think that it could work, the server executes the script and every client should then see the result.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline BlackJackVr

  • Members
  • *
Re: Fill munition box in multiplayer
« Reply #5 on: 03 Mar 2007, 10:33:11 »
The scripted is executed when a player uses and action i've added to the box... probably is for this reason it doesn't work as i want. Now i'll try with a normal trigger.