Home   Help Search Login Register  

Author Topic: Gear Window  (Read 1412 times)

0 Members and 1 Guest are viewing this topic.

Offline Captain Crunch

  • Members
  • *
Gear Window
« on: 16 Jan 2008, 22:57:05 »
Hi there,

I was just wondering how I can get to open a gear window with a hand gun and ammo from a script.

The idea is that I added an addAction on a garbage bin through a trigger to search the bin then when the player falls on the right garbage bin, instead of saying "nothing here", a gear window opens and shows a MarokovSD and some clips.

Can someone help me?


Thank you
Back to the forest!

Offline Loyalguard

  • Former Staff
  • ****
Re: Gear Window
« Reply #1 on: 17 Jan 2008, 11:04:08 »
The key commands here are createVehicle, addMagazineCargo, and addWeaponCargo.  You use them to create a "weaponholder", which is an invisible object used to hold weapons, and then add the appropriate weapons and ammo to it for players to pickup.

Try something like this:

binWeapons.sqf
Code: [Select]
_bin = "WeaponHolder" createVehicle _position; // Create a weapon holder at the proper bin.
_bin addMagazineCargo ["15Rnd_9x19_M9SD",2]; // Add two M9SD magazines to the bin.
_bin addWeaponCargo ["M9SD", 1]; // Add one M9SD to the bin.

*NOTE: Be sure to add the position of where you want to put the gun and magazines in script above where I have typed _position.


 

Offline Captain Crunch

  • Members
  • *
Re: Gear Window
« Reply #2 on: 20 Jan 2008, 23:49:09 »
Hi Loyalguard,

I can't figure out how to use the _position variable. If I use your script just as it is, I get an error message saying that there is a ; missing in this line.

Can you help me again?

Thank You
Back to the forest!

Offline Loyalguard

  • Former Staff
  • ****
Re: Gear Window
« Reply #3 on: 21 Jan 2008, 11:36:34 »
Sorry for the confusion Captain.  I should have explained more clearly. That is just a fictional name of a variable I created for the example.  In order for it to be used we have to set it to the position of your trash bin.  Before going on, make sure you are familiar with these entries in the COMREF.

position (array type)
position (command)
getPos (same as the position command)
setPos (command)

Ok, now let's make the code more specific.  What are using for a trash bin?  Are using a barrel object that you have placed in the editor?  If so, put "bin" (without quotes) in the name field of that object.  If you are using an object that is already on the map, the process is a little different.  Assuming the barrel (or similar object you place) we are actually going to skip using _position, and just use getPos and setPos directly instead.  Try this code in your script:

Code: [Select]
_binWep = "WeaponHolder" createVehicle (getPos bin); // Create a weapon holder at the position of the bin (using getPos).
_binWep addMagazineCargo ["15Rnd_9x19_M9SD",2]; // Add two M9SD magazines to the bin.
_binWep addWeaponCargo ["M9SD", 1]; // Add one M9SD to the bin.
_binWep Setpos [(getPos bin Select 0), (GetPos bin Select 1), (getPos bin select 2) + .85] // Sets the weapon/mags "exactly" on top of the bin using setPos (otherwise it would be hidden within the barrel)

If you are using a object that already exists on the map, I recommend you create a game logic, name it bin, and place it exactly where you want the weapons to be.

FYI, you may have to move about a bit and try the action a couple of times before you see "Take M9 Silenced" in the action menu and can pick it up.

Good luck!





Offline HarvesteR

  • Members
  • *
Re: Gear Window
« Reply #4 on: 23 Jan 2008, 14:23:07 »
i'm kinda rusted on this... but wouldn't it be possible to create a game logic object and load weapons into that and make it your weapon holder....

i'm actually wondering for myself... i don't mean to 'outscript' anyone

HarvesteR