Home   Help Search Login Register  

Author Topic: Need help with script: How to detect when gun is holstered  (Read 2117 times)

0 Members and 1 Guest are viewing this topic.

Offline Bebbe

  • Members
  • *
I am making an Prison Break Mission where you will be able to buy weapons from people. but ofc i want the script to be like when i draw my gun the guard will shot me. but if my gun is holstered they wont.

sorry for my bad english :p and thanks for the help.
« Last Edit: 01 Jun 2007, 00:33:58 by Mr.Peanut »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Need help with script
« Reply #1 on: 31 May 2007, 01:03:59 »
what u cud do is add action... seting ur player captive wen he have no weapon

heres quick idea... didnt had tim 2 develop it yet... but if no1 gives beter reply ill look into it more deeply

1st if ur unit is civie u have 2 edit da mission.sqm nd make him on 1 of da sides (depends wich side is da police... police west, player east)

now u put in da players init (put da type of weapon instead of weap... everytime player gets new weapon use weap = "nameOfWeapon" in da script or nywere

Code: [Select]
this addaction ["Draw weapon","draw.sqs"]; this setcaptive true; weap = "nameOfWeapon"
heres da script

draw.sqs

Code: [Select]
_man = _this select 0
_act = _this select 2

_man setcaptive false
_man removeaction _act
_man addaction ["Holster weapon","hols.sqs"]
_man addweapon weap

exit

now another script

hols.sqs

Code: [Select]
_man = _this select 0
_act = _this select 2

_man setcaptive true
_man removeaction _act
_man addaction ["Draw weapon","draw.sqs"]
_man removeWeapon weap

exit

LCD OUT
« Last Edit: 31 May 2007, 23:09:23 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Need help with script
« Reply #2 on: 31 May 2007, 01:42:24 »
AFAIK, there is no way to detect whether a unit has a weapon in hand, or what weapon they are holding, so LCD's solution might be the only way.
urp!

Offline Bebbe

  • Members
  • *
Re: Need help with script
« Reply #3 on: 31 May 2007, 01:44:36 »
I like the script but there is one problem tho... when i holster the weapon again and then draw it will refill with ammo again... is there possible to make the script remember how much ammo there was when i holstered?

hope i made myself clear :)

Offline Bebbe

  • Members
  • *
Re: Need help with script
« Reply #4 on: 31 May 2007, 01:53:59 »
Another thing too.... i am trying to mmake my Civi to change side to East.
Code: [Select]
class Item2
{
side="EAST";
class Vehicles
{
items=1;
class Item0
{
position[]={9810.956055,26.730000,4008.541992};
azimut=180.000000;
id=63;
side="EAST";
vehicle="Civilian";
player="PLAYER COMMANDER";
leader=1;
skill=0.600000;
text="Man";
But still West wont kill me anything wrong?

Offline Blanco

  • Former Staff
  • ****
Re: Need help with script
« Reply #5 on: 31 May 2007, 02:35:17 »
Quote
I like the script but there is one problem tho... when i holster the weapon again and then draw it will refill with ammo again... is there possible to make the script remember how much ammo there was when i holstered?

Should be solvable. There are commands to return the magazines and weapons. All you have to do is store and update this array of magazines in a ( global) variable and use it again when you add the weapons and ammo in the draw script. That's the theory... Things are getting harder when you want to make such a script generic. What happens when the player decides to take another weapon from a crate, enemy or fallen teammate?
Anyway, I don't know I can write it, but I'm sure the big boys can :)

I'm thinking about these commands:
Magazines
Ammo
Weapons
PrimaryWeapon
SecondaryWeapon

PS :There was a good OFPscript back in the ol' days, but I can't find it back.
« Last Edit: 31 May 2007, 02:46:35 by Blanco »
Search or search or search before you ask.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Need help with script
« Reply #6 on: 31 May 2007, 10:15:34 »
i cant add a mag w/ less dan full ammo... but if player empties clip i can remove it...

i updated da scripts in ma post above

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Need help with script
« Reply #7 on: 31 May 2007, 17:51:42 »
To make your civi east, group him with an east unit of higher rank, and in the init for that unit put:
Code: [Select]
deleteVehicle this
Good for SP only.
urp!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Need help with script
« Reply #8 on: 31 May 2007, 23:06:57 »
updated script again :D now itll keep da amount of ammo.... check out ma 1st post :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: Need help with script
« Reply #9 on: 31 May 2007, 23:21:33 »
Bebbe, please try avoid thread titles like "Need help with script".    It's much better to use titles that describe the problem.   This helps people who might be able to answer your question; helps people in the future who are searching for answers to similar questions; and makes the forum easier to use and understand.   

Please use titles like "How to detect when gun is holstered?"   ;)

Many thanks.
Plenty of reviewed ArmA missions for you to play

Offline Bebbe

  • Members
  • *
Re: Need help with script: How to detect when gun is holstered
« Reply #10 on: 01 Jun 2007, 02:16:35 »
Yes you are probably right i will make the thread titles informative from now on

updated script again :D now itll keep da amount of ammo.... check out ma 1st post :D

LCD OUT
. Okay thanks i would have to test the script tommorow since i have a hell of alot to do right now. if i get any problems i let you guys know thanks alot for help :)
« Last Edit: 01 Jun 2007, 09:50:40 by h- »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Need help with script: How to detect when gun is holstered
« Reply #11 on: 01 Jun 2007, 09:49:58 »
Another pointer Bebbe; you don't have to quote the entire previous post you're replying to (infact we don't like it at all), so I've removed the quote which included the whole of macguba's post..

I'm pretty sure everyone understands to whom you were replying to even without the quote :)
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.