Home   Help Search Login Register  

Author Topic: Ammo script not working  (Read 540 times)

0 Members and 1 Guest are viewing this topic.

Dagon

  • Guest
Ammo script not working
« on: 23 Sep 2004, 10:00:30 »
I've got a multiplayer mission that involves getting weapons/ammo from a crate. However, since it's a large thing to put in the crate's INIT line, I made a miniture script to duplicate the effects of the init line.

The script goes like this:

this addweaponcargo ["m21", 2]
this addweaponcargo ["LAWLauncher", 2]
this addweaponcargo ["G36a", 2]
this addmagazinecargo ["m21", 8]
this addmagazinecargo ["LAWLauncher", 8]
this addmagazinecargo ["G36amag", 20]

exit

and the init line is:

this exec "ammo.sqs"

(ammo.sqs is the scriptname).

sometimes I get a message like...

"addmagazinecargo ["g36amag", ##]| typed string, expected object" or something. If I move the script around a little, it's always the last line that gives me the error. Why is this?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Ammo script not working
« Reply #1 on: 23 Sep 2004, 10:37:57 »
In the init line:

[this] exec "ammo.sqs"


In the script:

_this add....


The error is always the last line because in fact the error is being generated for every line.    Each error message overwrites the previous one so you only see the final one, which of course refers to the last line.    You can't see the multiple error messages flashing up because it happens several orders of magnitude faster that you can see.
« Last Edit: 23 Sep 2004, 10:39:29 by macguba »
Plenty of reviewed ArmA missions for you to play

Dagon

  • Guest
Re:Ammo script not working
« Reply #2 on: 23 Sep 2004, 14:02:45 »
hrm... still doesn't work. I've attached the mission, RAR'ed, if you could possibly disect the problem. There's a second script (crazyloadout) which has the same problem (this is the script for the easter egg area. Easter no more, I guess.)

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Ammo script not working
« Reply #3 on: 25 Sep 2004, 02:27:10 »
Well, take half of macguba's suggestion, and you've got it:

this exec "ammo.sqs"
   ammo.sqs:
_this addmagazinecargo.....

If you want to do it macguba's way, it needs to look like this:

[this] exec "ammo.sqs"
   ammo.sqs:
(_this select 0) addmagazinecargo......

Hmm.... I swear I'm going to write a "this" tutorial one of these days....
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Ammo script not working
« Reply #4 on: 25 Sep 2004, 10:42:44 »
Hmm.... I swear I'm going to write a "this" tutorial one of these days....
Ok, well I finally did. I hope it isn't too wordy, but I wanted to cover everything, and leave no question unanswered. Check out the tutorial here: http://www.ofpec.com/editors/resource_view.php?id=706
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!