OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Lone-Wolf on 13 Apr 2009, 01:22:47

Title: Help!!! Querying magazines
Post by: Lone-Wolf on 13 Apr 2009, 01:22:47
I am writing a short script to get that Glock pistol working like it should...
And I mean a player action to put on and take off the silencer.  :D

However, I've run into that pesky problem of the two magazine types: glockmag and glocksmag

I have NO IDEA how I can query the number of magazines of a given type in the player's inventory.  ???
i.e. What do I type to find out how many "glockmag" magazines are in the player inventory, for instance?

Can anyone help?

Thanks in advance,
      Lone-Wolf
Title: Re: Help!!! Querying magazines
Post by: Walter_E_Kurtz on 13 Apr 2009, 02:25:42
NumberOfMagazines = {_x == "GlockMag"} count (Magazines player)

Note that this only counts the number of clips carried, not how much ammunition is in each. If you swap them one-for-one, it's possible for the player to game the system by running the script to replenish every mag. Most people in the past have removed one clip from the player each time, by assuming that at least one mag is likely to be mostly empty. Because this was generally done for primary weapons, it seems fair. For handguns, when you can carry at most 4 clips, this might be a bit harsh.
Title: Re: Help!!! Querying magazines
Post by: Lone-Wolf on 13 Apr 2009, 21:24:16
Okay, I got it working perfectly.

Fantastic, thanks!  :good:

However, I encountered some errors that seemed to be a problem with the OpFlash engine.  ::) If you change the player's weapon via scripting, then if the player drops the new weapon, all their pistol ammo (if any) disappears.

Anyone else experienced this???
Title: Re: Help!!! Querying magazines
Post by: Raptorsaurus on 19 Apr 2009, 20:21:13
It is not a bug. If you drop a weapon the magazines associated with that weapon are droped with the weapon. If someone them pick that weapon up, they get all the magazines also.