Home   Help Search Login Register  

Author Topic: not working  (Read 1476 times)

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
not working
« on: 14 Aug 2005, 11:41:22 »
ive made some small script that worked but not anymore for some reason
i did change it but i only added the sound in
i run it through an Event handler like this
Code: [Select]
alpha1 AddEventHandler ["{hit",{_this exec "hit.sqs"}]
the soldier is called alpha1

the hit.sqs script is like this

Code: [Select]
_hit = _this select 0
_amount = _this select 2

? getdammage _hit >= 0.95 : goto "dead"
? !not (alive _hit) : goto "notdead"
EXIT

#notdead

? _ammount >= 0.25 : goto "enough"
EXIT

#enough
~1
? not (alive _hit) : goto "dead"
if (100 > random 100) then {goto "shout"}
EXIT
#shout
if (50 > random 100) then {_hit groupradio "hit1"} else {_hit groupradio "hit2"}
~0.75
if (30 > random 100) then {_hit say "eng32"} else {_hit say "eng34"}

#dead
EXIT

it should when the unit is hit make a chance that he will sout down the radio one of the sounds i chanfed the probability's around to test it

i get no error messages at all no sound errors i have all the sound in the right place and there all defined
but no noise there not dead there still alive so they can still talk ?

EDIT - By the way im also in the units group
« Last Edit: 14 Aug 2005, 11:51:04 by 456820 »

bored_onion

  • Guest
Re:not working
« Reply #1 on: 14 Aug 2005, 12:35:47 »
Code: [Select]
? !not (alive _hit) : goto "notdead"
try removing the "not" after exclamation mark and replacing all "not"s for "!"s.

does "if then else" work in scripts? i always thought that was for functions. try doing some like

Code: [Select]
?(condition=true): goto "next"
;whatever commands you want to happen "else" this condition is met
exit
#next
;whatever commands you want to happen "if" this condition is met
exit

if that doesn't work put in a hint after each line of the script. where your hint stops pinging is where your problem is.
« Last Edit: 14 Aug 2005, 12:40:49 by bored_onion »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:not working
« Reply #2 on: 14 Aug 2005, 12:45:57 »
! not means not not so instead of !not just put a space.  That made more sense when I wrote it that i does when I read it.

I would drop all the ! and use not instead as I find that easier to read - but each to his own.

if ... then {...} else {...}

does indeed work within scripts.

EDIT:

This is your problem:
Code: [Select]
? _ammount >= 0.25 : goto "enough"You have put an extra m in _amount so the conditional test will always fail and the script will exit without a sound.

EDIT2:
Also
Code: [Select]
if (100 > random 100) then {goto "shout"}Is the same as

Code: [Select]
goto "shout"Though that is something I will often do if I think I might wish to change the probabilities later.
« Last Edit: 14 Aug 2005, 12:57:28 by THobson »

Offline 456820

  • Contributing Member
  • **
Re:not working
« Reply #3 on: 14 Aug 2005, 12:57:44 »
thanks alot guys ill edit it and have a go then

Quote
EDIT2:
Also
Code:if (100 > random 100) then {goto "shout"}
Is the same as

Code:goto "shout"

yeas that was just to make it work without having to shoot aloadof guys so it works first time when it works i was going to change that back to 50
thanks

bored_onion

  • Guest
Re:not working
« Reply #4 on: 14 Aug 2005, 13:24:50 »
w0w "if then else" works in scripts. you learn something new everyday.

Offline 456820

  • Contributing Member
  • **
Re:not working
« Reply #5 on: 14 Aug 2005, 13:42:06 »
okay i editedit and tried again and didnt work so i put in some hints then tried no hints came u what so ever so the script isnt actually running whats wrong with how i added the even handlers ?

bored_onion

  • Guest
Re:not working
« Reply #6 on: 14 Aug 2005, 14:39:06 »
try taking out the EXIT below the first two condition lines. it might be reading that for some strange reason.
« Last Edit: 14 Aug 2005, 14:39:23 by bored_onion »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:not working
« Reply #7 on: 14 Aug 2005, 14:41:19 »
possibly you can be dead without having .95+ dammage?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:not working
« Reply #8 on: 14 Aug 2005, 14:53:41 »
When you said you editied it, did you change
_ammount >= 0.25
to
_amount >= 0.25
?

By the way:

Code: [Select]
? _amount >= 0.25 : goto "enough"
EXIT

#enough

can be replaced by:
Code: [Select]
if (_amount < 0.25) then {exit}
It will do the same, neater and with out a slow goto.
« Last Edit: 14 Aug 2005, 15:01:13 by THobson »

Offline 456820

  • Contributing Member
  • **
Re:not working
« Reply #9 on: 14 Aug 2005, 15:53:44 »
i dont think thats the problem but ill try it the problem now is that its not running when i shoot a soldier i placed
alpha1 AddEventHandler ["hit",{_this exec "hit.sqs"}]
that in the init.sqs file
and when i shoot the soldier i should get a hint saying "SCript started" but i dont get anything so the script isnt getting activated for some reason ?

KIND OF EDIT - I justnoticed that i had a { in the add event handler so thats why it wasnt working ill give it a go now

oh and ill edit the script due to everyones suggestions to make it a bit easier to read

thanks alot

Offline 456820

  • Contributing Member
  • **
Re:not working
« Reply #10 on: 14 Aug 2005, 16:02:38 »
right ive got it working but for some reason it plays the sound twice for example i get
'Im hit' then a bout a second later i get 'MEDIC'
how can i stop that happening likeif one soldier is hit it sets a variable to true and will stop it playing th sound again for that soldier but with other soldiers it will play until there variable is set to true ?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:not working
« Reply #11 on: 14 Aug 2005, 17:01:05 »
Quote
dont think thats the problem
You seem not to have noticed despite me telling you twice, that you have an undeclared variable:

Code: [Select]
_amount = _this select 2
.
.
.
? _ammount >= 0.25 : goto "enough"

Count the m s in each of those two amounts

Offline 456820

  • Contributing Member
  • **
Re:not working
« Reply #12 on: 14 Aug 2005, 17:08:30 »
ive fixed the variable but didnt re post the edited version up
but i also had a problem in the init.sqs i had an extra { in some " " like "{Hit" so it wasnt working because of that but thats working now but ive still got a problem when i shoot a soldier they shout at right but say it twice for some reason anyone know how to fix it ?

also i was talking about bored_onion's suggestion i should of said so sorry

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:not working
« Reply #13 on: 14 Aug 2005, 19:53:37 »
Quote
w0w "if then else" works in scripts. you learn something new everyday.
If ... then {...} else {...}
works in scripts, in trigger activation fields, in unit init fields.  It works everywhere as far as I can tell.
« Last Edit: 15 Aug 2005, 08:02:16 by THobson »

bored_onion

  • Guest
Re:not working
« Reply #14 on: 14 Aug 2005, 21:07:31 »
kind of embarrassing that ive been scripting for a year and didnt know that...