OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: nominesine on 01 Jan 2006, 13:27:42

Title: handgun ID
Post by: nominesine on 01 Jan 2006, 13:27:42
Is there a comand that lets me check what handgun a player is carrying in the pistol slot, similar to the commands pimaryWeapon and secondaryWeapon???

I would like to create a string, consisting of all weapons the player is carrying at the moment, but I cannot include the handguns in the string.

EDIT: The command weapon does not work. I need to get the name of the handgun separate from the other weapons
Title: Re:handgun ID
Post by: macguba on 01 Jan 2006, 13:30:45
http://www.ofpec.com/editors/comref.php?letter=W#weapons
Title: Re:handgun ID
Post by: nominesine on 01 Jan 2006, 13:42:12
I'm making a script, checking if the player is armed. This is the code sample I'm having trouble with:
Code: [Select]
rifles = primaryWeapon player
bazookas = secondaryWeapon player

? player hasWeapon rifles or player hasweapon bazookas: goto "playerIsArmed"

goto: "playerIsNotArmed"

This allows me to check if the player is carrying any weapon in the first two slots. But I cannot check if the tricky bastard has hidden a handgun somewhere. Any suggestions?

EDIT: syntax above from memory, not the actual script code. It works in the script.
Title: Re:handgun ID
Post by: penguinman on 01 Jan 2006, 13:49:47
just use the weapons command

it returns an array of all weapons a unit is carring.

weapons player


and also,

Quote
rifles = primaryWeapon player
bazookas = secondaryWeapon player

? player hasWeapon rifles or player hasweapon bazookas: goto "playerIsArmed"

goto: "playerIsNotArmed"

you need the line things on a variable

Code: [Select]
_rifles = primaryWeapon player
_bazookas = secondaryWeapon player

? player hasWeapon _rifles or player hasweapon _bazookas: goto "playerIsArmed"

goto: "playerIsNotArmed"
Title: Re:handgun ID
Post by: THobson on 01 Jan 2006, 14:22:51
In case it is not clear from all the above try something like:

Code: [Select]
if (count weapons player < 1) then {goto"PlayerNotArmed"}
;he has a weapon if the script gets here.

It gets slightly more complicated if you need to know what weapon he has.
Title: Re:handgun ID
Post by: nominesine on 01 Jan 2006, 18:04:43
A count command. Brilliant. Thanks Thobson. Problem solved  :D