Problem: I wanted a script to check that the player had a M4. How do I do this?
Problem: I wanted a script to check that the player had a M4. How do I do this?
Oh... thats not wright...
He can also work with pirmaryWeapon and secondaryWeapon.
![]()
Um anyone got some code for PW and SW (primary weapon and secondary weapon)![]()
All I want to know is how can I check if a guy has this weapon: M4.![]()
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit hasWeapon "M4"[/QUOTE]
From comref:
Originally Posted by [b
Didnt work, or maybe I didnt use it right, anyone able to show me?![]()
You must use that syntax within a condition statement. Can you supply your script/trigger settings/ etc.. where you are intending to use this? It would be easier if we knew what you were doing....
EDIT:Also, the "M4" refers to the standard BIS M4... you are not using any add-on M4's are you?
Could this work?
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
_weapon = weapons Rommel
?( _weapon == "M4"): exit
[/QUOTE]
EDIT: This is the error message: "error ==: Type Array, expected Number,String,Object,Side,Group"
For your Info:
Rommel = Me
M4 = STANDARD BIS M4
Just Random Code - How to find out your weapon name and magazine. Quite handy if your OFP cant alt tab or the addon that your using doesnt tell you what the weapon names are in the readme or something (and or your to lazy to un-pbo the addon and read the config or you can but have no idea how to read a config).
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
hint format["weapons: %1, magazines: %2",weapons this,magazines this]
exit
[/QUOTE]
This displays your weapon and what magazines you have.
Its quite handy
@Crashdome
I used this:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
?(player hasWeapon "M16"): hint "You have an M16"; exit
[/QUOTE]
Nevermind I got the hasweapon thing to work.![]()
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
?(_this hasweapon "M4"): hint "You have a M4! How interesting!"; exit
exit
[/QUOTE]
the command //Weapons// returns an array, so you must do something like this:
? "M4" In Weapons Rommel : exit
MSI P55-GD65 | Core i5 750 @ 2.67GHz | 4GB DDR3 | ATI HD 5970 (Asus EAH5970/G/2DIS/2GD5) | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Home Premium | Catalysts 13.1 | ArmA2 OA 1.62.0.101480 (beta) +BAF +PMC +ACR | ArmA2 1.11.0.86734 | ArmA 1.18.0.5281 | OFP 1.0.0.96
Be smart, use Sprocket!