Jump to content
Sign in to follow this  
SpeedyDonkey

How to detect if a player has a weapon

Recommended Posts

The objective is to kill a dude. The dude has alot of guards... The problem is that i can walk around there with my weapon visible (ingram) and the guards couldn't care less, and imo thats very unrealisitc.

(In the mission im a west guy with a civilian outfit (edited in the mission.sqm) and in the start of the there's a trigger that makes me captive so they wont fire. As soon as i kill one of em' the trigger switches to setcaptive false and they try to kill me...)

SpeedyDonkey smile_o.gif

Share this post


Link to post
Share on other sites

BronzeEagle sugests:

Quote[/b] ]would it be possible to have a condition that states if your gun is out or in other words if you are in combat mode?  that way when your gun is in your hand they fire at you?

This sounds like a good idea. I just don't know exactly how to achieve this.

smile_o.gif

Share this post


Link to post
Share on other sites

At first glance your choices appear to be:

Quote[/b] ]combatMode grp

Operand types:

grp: Object or Group

Type of returned value:

String

Description:

Combat mode of given unit ("BLUE","GREEN","YELLOW","RED")

Example:

combatMode group player

and

Quote[/b] ]weapons vehicle

Operand types:

vehicle: Object

Compatibility:

Version 1.75 required.

Type of returned value:

Array

Description:

Returns array of names of all vehicle's weapons..

Example:

weapons player

I am not sure if combatMode follows your stance, ok I just checked, it does not.

Your only choice appears to be to check the weapons array.

Share this post


Link to post
Share on other sites

Thank you BN 880. But Im a really donkey when it comes to scripting so honestly i don't know where to type that {8^¤

/SD smile_o.gif

Share this post


Link to post
Share on other sites

Well this condition should be true if the player has any weapons, and false if the player has no weapons:

(count (weapons player) > 0)

I think.

So you can use that in a trigger or a script.

Share this post


Link to post
Share on other sites

okey but will they will shoot me wether my weapon is visible or not As long as i have a weapon.. ?

Share this post


Link to post
Share on other sites

Yep.

Sorry at the moment i don't have time to poke around more, but I think I have seen some posts about this problem before. Maybe several months back.

The only other thing that comes to mind is checking the players relative hight above ground to see his combat stance, but, I wouldn't set my hopes high.

Share this post


Link to post
Share on other sites

Okey thanks for the help anyway smile_o.gif

oh and if you come up with a solution, feel free to post it here wink.gif

Share this post


Link to post
Share on other sites

You could add an action to the player:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addaction ["Pull weapon", "weapon.sqs"]

weapon.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

player addweapon "weaponname"

~4

player setcaptive false

RED

Share this post


Link to post
Share on other sites

Hey that's a smart way to solve it!! cheers RED  smile_o.gif

btw, i realized that i cant have a custom weapons selection on the briefing but that's a small price considering the realism this adds smile_o.gif

Share this post


Link to post
Share on other sites

No you could do it, but it would be a bit more work. In the init.sqs (at the end of your code you have now) put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

~0.01

secondaryWeapon = secondaryWeapon player

primaryweapon = primaryWeapon player

removeAllWeapons player

In the weapon.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addweapon secondaryWeapon

player addweapon primaryweapon

~4

player setcaptive false

You could make the code better but I don't have time to do that for you smile_o.gif

RED

Share this post


Link to post
Share on other sites

tounge_o.gif Yep, I think that must have been the solution someone came up with when the problem was "unsolvable" a whiel back. . .

(sorry I couldn't assist more SpeedyDonkey, but some people have just wasted half my day ;) )

Share this post


Link to post
Share on other sites
Quote[/b] ](but some people have just wasted half my day ;) )

Sure my english sucks but it can hardly be that bad... redface2.giftongue2.gif

Share this post


Link to post
Share on other sites

LOL, no it wasn't you or anything to do with the forums or OFP. smile_o.gif

Share this post


Link to post
Share on other sites

Ok well that was a relief...

Anyway i made my stupid little mission (can be found in the user missions thread ^^) so you guys wont have to wory about me bitching and asking all kinds of basic newbie questions ... for a while

smile_o.gif

Share this post


Link to post
Share on other sites

QUOTE: BronzeEagle (cos' he cant post)

"hey, can't you do a:

player addEventHandler ["combat", {_this exec "guninhand.sqs"}]

you just have to know the event to match up with gun in hand then, right?  so what event would that be?    combat is a behaviour i think.  there are also combats modes that are the colors of a stoplight: red, green, yellow, orange, blue.  I'm not sure about orange but you do realize that with this in the script you could say: player setcaptive false."

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×