Home   Help Search Login Register  

Author Topic: Need help with a little script  (Read 493 times)

0 Members and 3 Guests are viewing this topic.

Offline Nemesis6

  • Members
  • *
Need help with a little script
« on: 19 Jun 2004, 20:14:41 »
Here's the thing, it's a drop command script that's intended to be added by a hit EventHandler. So when a unit is hit with a 30MM cannon for example, the unit ejects small debris parts. The problem is, when I add it to the player and another unit and shoot the other unit, it is only myself who eject debris... I am curtain that it is the positional stuff that screws up. It works when I make more scripts with the unit's names... anyway, here's the example mission. Just add the eventhandler to the player, too.
I am actually flying into a star... this is incredible!

Offline Nemesis6

  • Members
  • *
Re:Need help with a little script
« Reply #1 on: 21 Jun 2004, 19:08:11 »
bumpz0r
I am actually flying into a star... this is incredible!

Unnamed

  • Guest
Re:Need help with a little script
« Reply #2 on: 22 Jun 2004, 01:09:06 »
When you add your hit event I think it should be:

Code: [Select]
this addEventHandler ["hit",{_this exec "debris.sqs"}]
The "_This" between the {} is an array supplied by the event itself.

_this select 0 : who's hit (can be either a man or a vehicle) ;
_this select 1 : who did (h)it ;
_this select 2 : scalar damage value.

Take a look here for more on events:

http://www.ofpec.com/editors/resource_view.php?id=543

The same applies to your script:

Code: [Select]
? "Ch47D" counttype [this] == 1 || "Mi17" counttype [this] == 1|| "MI24" counttype [this] == 1|| "Kamov" counttype [this] == 1|| "SU25" counttype [this] == 1|| "Cobra" counttype [this] == 1|| "A10" counttype [this] == 1|| "A10LGB" counttype [this] == 1|| "AH64" counttype [this] == 1|| "UH60" counttype [this] == 1|| "UH60MG" counttype [this] == 1: _weight = 1.2

You cant use This from within a script, I think the value your after would be (_this select 1) e.g

Code: [Select]
? "Ch47D" counttype [(_this select 1)] == 1....e.t.c
Sorry I cant test more, but to be honest if I where you I would start from scratch again and do it one step at a time. Try and get the vehicle thats firing first, before worrying about the drop command. For example you could use:

Debris.sqs

Code: [Select]

_Target=_This Select 0
_Firing=_This Select 1

_Vehicle=Vehicle _Firing

If ((TypeOf _Vehicle) In ["Ch47D","Mi17","MI24","Kamov"]) Then {Hint Format ["You are being fired at by a %1",TypeOf Vehicle]}