Rommel 2 Posted March 12, 2005 Problem: I wanted a script to check that the player had a M4. How do I do this? Share this post Link to post Share on other sites
Blanco 0 Posted March 13, 2005 Use the HasWeapon or the Weapons command. If you are talking about the weapon in hand... you can't Share this post Link to post Share on other sites
buliwyf 4 Posted March 13, 2005 Oh... thats not wright... He can also work with pirmaryWeapon and secondaryWeapon. Share this post Link to post Share on other sites
Rommel 2 Posted March 14, 2005 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. Share this post Link to post Share on other sites
crashdome 3 Posted March 14, 2005 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit hasWeapon "M4" From comref: Quote[/b] ]unit hasWeapon weaponNameOperand types:   unit: Object   weaponName: String Type of returned value:   Boolean Description:   Check if unit has given weapon. Example:   player hasWeapon "M16" Share this post Link to post Share on other sites
Rommel 2 Posted March 14, 2005 Didnt work, or maybe I didnt use it right, anyone able to show me? Share this post Link to post Share on other sites
crashdome 3 Posted March 14, 2005 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? Share this post Link to post Share on other sites
Rommel 2 Posted March 15, 2005 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 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 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 Share this post Link to post Share on other sites
Rommel 2 Posted March 15, 2005 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 Share this post Link to post Share on other sites
5133p39 16 Posted March 15, 2005 the command //Weapons// returns an array, so you must do something like this: ? "M4" In Weapons Rommel : exit Share this post Link to post Share on other sites
crassus 0 Posted March 16, 2005 <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 Rommel, I'm just confirming, is this the correct syntax for what you want? Share this post Link to post Share on other sites
Rommel 2 Posted March 17, 2005 No, <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #Wait ?(_this hasweapon "M4"): goto "Loop" #Loop ?!(_this hasweapon "M4"): goto "Turn Off" goto "Loop" #Turn Off _this action ["light off"] goto "Wait" I havent decided whether to use @ or or loops. EDIT: @ didnt work, loops do work. I guess you might be able to tell what this is for. Share this post Link to post Share on other sites
redface 1 Posted March 17, 2005 If you are talking about the weapon in hand... you can't  in fact you can check if a unit has a weapon in his hand ... but only with a workaround if a unit pulls a gun his behaviour is changed from safe to not safe (!=safe) immediately however if he holsters the weapon again, it takes some time for the engine to change the unit back to safe how could you forget, blanco, I showed you my example mission more than one year ago Share this post Link to post Share on other sites
5133p39 16 Posted March 17, 2005 what redface wrote should work, but let me add - it will work only for AI for the Player (no matter if he's even got any gun) the Behaviour returns allways "AWARE", except when he is prone - then it will return "COMBAT" Share this post Link to post Share on other sites
Rommel 2 Posted March 18, 2005 Correction of script: When using a config this is how to make it work on init with a eventhandler: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _man = _this select 0 #Wait ?(_man hasweapon "Ak74Su"): goto "Loop" _man action ["light off"] goto "Wait" #Loop ?!(_man hasweapon "Ak74Su"): goto "Turn Off" goto "Loop" #Turn Off _man action ["light off"] goto "Wait" Is there anyway to check if its Multiplayer at the time? I am updating the script so it stops when he dies, if I can find out if its multiplayer at the time I can make it keeps on going until 5 minutes after he is dead, most respawns usually are not over 5 minutes . If he is alive within those 5 minutes it continues. Though I dont think this will work? z I can only hope I guess.... Share this post Link to post Share on other sites
Blanco 0 Posted March 26, 2005 Quote[/b] ]how could you forget, blanco, I showed you my example mission more than one year ago Yes, I remember now. It took 20 seconds or so before the behavior returned to safe again. But i'm pretty sure you did the test on the player and not on a AI unit  I tried it myself but it doesn't work, so I suppose you did something different than me. I don't think I have that test anymore, do you have the name of zip? Maybe I can find it back on my HD. Share this post Link to post Share on other sites
killswitch 19 Posted March 26, 2005 Is there anyway to check if its Multiplayer at the time? This expression will evaluate to true if there's a MP game playing:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{playersNumber _x>0}count[east,west,resistance,civilian]>0 Example usage: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> @(time>0) ?{playersNumber _x>0}count[east,west,resistance,civilian]>0:goto "mpgame" hint "This is a SP game" exit #mpgame hint "This is a MP game" exit Share this post Link to post Share on other sites