Home   Help Search Login Register  

Author Topic: Assign weapons & gear via script, + script conflicts?  (Read 2834 times)

0 Members and 1 Guest are viewing this topic.

Offline Kyle_Kelahshehskee

  • Members
  • *
  • I'm a llama!
Hello All,

Well, I've spent another several hours of my life trying to figure out what's going wrong, to no avail.  I've also searched for examples for what I'm trying to do, with no luck whatsoever.  This has probably been answered, oh, a 1,000 times or more already, but I have to ask as I'm really frustrated right now...

I'm in the process of setting up weapons and gear loadouts/kits for the infantry units, so that when it comes time to edit the unit's init field it's not a cluttered and long listed mess.  So I figured, why not make the loadouts as scripts, and then simply enter the script name that's to be executed inside the init line of the unit that you want to have said script?  Sounds simple, right?

Each and every time I've loaded up the mission in the editor, my avatar (that I'm testing the script approach on) shows up weaponless.  I am getting an error message at the top, but I'll get to that in a minute.
Again, this unit is the player's unit, and in its init line I have the following entered:
Quote
init="this exec ""L_I_hk416car_ap.sqs""; ";

So, here's what the above mentioned script looks like (and "Yes," I made sure that I got the name of the script spelled correctly in my unit's init field):
Quote
init="RemoveAllWeapons this; this addmagazine ""SmokeShell""; this addmagazine ""SmokeShell""; this addmagazine ""HandGrenade""; this addmagazine ""SJB_TOS_M4_mag""; this addweapon ""SgtEv_c416_acog""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addweapon ""SJB_TOS_Colt1911""; this addweapon ""Binocular""; this addweapon ""NVGoggles""';
When I load up the mission, my equipment's not there, and I get an error message at the top of the screen.  It's so long I can't even read the whole thing as it goes off the right edge of the screen, it begins, "'init="RemoveAllWeapons this; this addmagazine ""SmokeShell""; this addmagazine ""SmokeShell"" and just keeps going, repeating the init code as I have it listed in the script.

What am I doing wrong?

================================

Another issue, that's somewhat related to the one above.  It should be noted that I was having this problem before I tried executing my unit's loadout through its own weapon's script.  The trouble I was having with this bug occurred when I had all of the gear listed inside the unit's init field.  I was trying to launch a script that I located here, on "doubleweapons," the default script that came with the download was entitled "gun.sqs".  I modified its contents to better suit the extra gear I wanted my unit to take, and whenever I tried loading the mission up with this script active, my unit would show up weaponless.  30 seconds later, however, the doubleweapons script would kick in, and I was able to grab all of its contents and use them fine, but that doesn't address the fundamental issue that the equipment that was desired in the init wasn't showing up.  If I removed the doubleweapons script, the equipment spelled out in detail within the field would appear.  Now, I'm wondering if the conflict here is that when the unit's init kicks in, it's supposed to remove all weapons, and since the doubleweapons script that I have written has an extra firearm and grenades in it, is it getting confused by "knowing" that extra weapons are in another script that's delayed in its execution by 30 seconds, or ...?  By default, the doubleweapons script must take 30 seconds to start, and as far as I've been able to tell, there's no workaround for that. 

The problem grew even worse when I tried running the equipment script along with the doubleweapons script through the unit's init field; after trying to load the mission for several minutes, it would crash to the desktop.  Here's what my unit's init line looked like when I was trying to execute both scripts through it:
Quote
init="this exec ""L_I_hk416car_ap.sqs""; "; this exec ""guns.sqs""; "
  The order of the scripts had no impact on avoiding a crash to desktop.  It crashed every time, no matter what I order I tried.   


So, in summation, this is want I'm hoping to make work: I want the player unit to get its weapon through a script, and I would also like to run this script with the doubleweapons script.  Further on down the line, I'm going to try and have certain units execute AI scripts, such as Blanco's cover and hold stuff, so if there's a particular format I'm missing in order to get all of the scripts to work at the same time, I'd love to know what it is.

Yours,

Kyle
Nov. 6, 2007

 ???



Offline schuler

  • Contributing Member
  • **
Re: Assign weapons & gear via script, + script conflicts?
« Reply #1 on: 06 Nov 2007, 07:32:42 »
one script one unit. first name the guy ap3 or something
soldier ten slots and sidearm, HandGrenade, nvg and binc's with 
name ap3 not a medic,
notice the mags are loaded first then the weapon , i think you had to many "'s in the command line
this is wrong,,,    init="this exec ""L_I_hk416car_ap.sqs""; "; sould be, this exec "L_I_hk416car_ap.sqs"
code in units unit
Quote
[ap3] exec "unit357.sqs"

script in mission folder called. unit357.sqs
Quote
; Get the unit parameter given
_unit = _this Select 0

; Strip the units current gear
RemoveAllWeapons _unit

; Add the new gear to the unit
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddWeapon "AK47"
_unit SelectWeapon "AK47"
_unit AddMagazine "GlockMag"
_unit AddMagazine "GlockMag"
_unit AddMagazine "GlockMag"
_unit AddMagazine "GlockMag"
_unit AddWeapon "Glock"
_unit AddMagazine "HandGrenade"
_unit AddMagazine "HandGrenade"
_unit AddMagazine "HandGrenade"
_unit AddMagazine "HandGrenade"
_unit AddWeapon "Binocular"
_unit AddWeapon "NVGoggles"

Exit
;) hope that solves you problems, let me know!
cheers schuler

« Last Edit: 06 Nov 2007, 07:34:52 by schuler »
Semper Fi

Offline Kyle_Kelahshehskee

  • Members
  • *
  • I'm a llama!
Re: Assign weapons & gear via script, + script conflicts?
« Reply #2 on: 06 Nov 2007, 12:11:52 »
If circumstances permit, I'll give this a try some time tonight.

Considering the number of "s I've used as being "too many" is strange to me, as I've been using the incorrect number of "s for months now, and each and every time the units spawn with and use the newly specified equipment without any errors.  I seem to recall using a reduced number of "s in the past, and the equipment changes didn't show up on the unit, but, like so many things in life, my recollection may be wrong on that point.  I'll alter my equipment changes per your expert recommendations.

But before I go, I just want to be clear on this, it's only possible to execute one script through the unit's init field?  Does that mean other scripts can be assigned to a unit, but only through a trigger (or a series of triggers)? 

If that's the case, then maybe I am better off individually assigning new loadouts in the unit's init field, and then inputting just the most desirable script at the end of equipment changes, or should I consider any change in a unit's gear to be a "script"?

I'm just trying to figure out the subtleties of this stuff, as headache inducing as it is right now.   :D

In any event, thank you for your very prompt, and nicely detailed feedback Schuler.   :good:

Yours!
Kyle
Nov. 6, 2007
 :)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Assign weapons & gear via script, + script conflicts?
« Reply #3 on: 06 Nov 2007, 13:16:43 »
If you are putting a script directly in the init field, then the correct way would be:
Code: [Select]
this exec "frog.sqs"

However, if you need to place quotes inside a string, then use double-quotes:
Code: [Select]
hint "A voice from above says, ""Hello!"""

The confusion, I think, is because you have found some sort of alternative way to set the init field by directly changing the init:

init="this exec ""frog.sqs"""

While this might have an equivalent effect to the original code example in this post, it is needlessly complex and just means you have to type more which will tend to lead to more mistakes. Setting init this way is entirely non-standard and no-one needs to use it since it is simply adding needless complexity. So, you are not using "too many" quotes, but you are using a method of setting init which requires you to use more than you need using simpler techniques.


However, when in a script, the only effect of:
Code: [Select]
init = "...do stuff..."

Would be to set a global variable called init to a string value and nothing else (the external script you are running is not tied to an object, unlike the code within the init field) This would have no effect at all, since none of the "code" within the string will be run (let alone compiled), so Schuler shows you the correct way to format an actual script.

Quote from: Kyle_Kelahshehskee
Code: [Select]
init="this exec ""L_I_hk416car_ap.sqs""; "; this exec ""guns.sqs""; "

Should be:
Code: [Select]
this exec "L_I_hk416car_ap.sqs"; this exec "guns.sqs";
« Last Edit: 11 Nov 2007, 22:42:55 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Kyle_Kelahshehskee

  • Members
  • *
  • I'm a llama!
Re: Assign weapons & gear via script, + script conflicts?
« Reply #4 on: 10 Nov 2007, 04:30:35 »
Alright, I'm really at my wits end on this thing.  I would've posted earlier, but I didn't want to seem like I was "over requesting" help without first exhausting the options that I feel confident enough to try on my own.  After several nights of more futile efforts, I'm back, begging for help once again.   :weeping:

Spooner, I tried listing the two scripts in my unit's init field exactly as you posted above, but in the end my unit spawned without any equipment, and the gun.sqs script didn't run properly.

Here's how I normally have my loadout setup within the Mission file.  I haven't had any problems with this working, till I try adding scripts.  Maybe I have too many "" instead of " ? 

Quote
side="WEST";
         class Vehicles
         {
            items=12;
            class Item0
            {
               position[]={15304.397461,20.339998,478.497192};
               azimut=479.799988;
               id=46;
               side="WEST";
               vehicle="OfficerW";
               player="PLAYER COMMANDER";
               leader=1;
               rank="LIEUTNANT";
               skill=1.000000;
               text="Player1";
               init="RemoveAllWeapons this; this addmagazine ""SmokeShell""; this addmagazine ""SmokeShell""; this addmagazine ""HandGrenade""; this addmagazine ""SJB_TOS_M4_mag""; this addweapon ""SgtEv_c416_acog""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addweapon ""SJB_TOS_Colt1911""; this addweapon ""Binocular""; this addweapon ""NVGoggles""";

Again, when I try running the mission with the all of the units' equipment setup as you see above, everything works fine, with no problems.

As soon as I try adding a script, that's when things starting behaving badly. 


So, here's how I have my gun.sqs setup:
Quote
;-----------------Made by BLIP modified by Kyle_K_ski-----------------------
;HK416 carabine Aimpoint x4 mags & various Grenades--Squad LEADER--
;This loadout is intended for switching AIMING AIDES, from HK416 carabine ACOG to Aimpoint.
;Only play with the Edit section unless you know
;what you are doing.
;example: _holder addmagazinecargo ["magazinename",# of mags]
;    _holder addweaponcargo ["weaponname",# of weapons]
;-------------------------------------------------------

_guy = _this select 0
_pos = getpos _guy select 2
~1
_holder = "weaponholder" createvehicle getpos _guy
~1
;------------Edit Weapon Here-----------------
_holder addmagazinecargo ["SJB_TOS_M4_mag",4]
_holder addweaponcargo ["SgtEv_c416_rd",1]
_holder addmagazinecargo ["HandGrenade",2]
_holder addmagazinecargo ["SmokeShellRed",2]
_holder addmagazinecargo ["SmokeShellGreen",1]
;-------------------------------------------------

#loop
?vehicle _guy !=_guy: goto "loop2"
_holder setpos [(getpos _guy select 0),(getpos _guy select 1),(getpos _guy select 2)-0.5]
~0.1
goto "loop"

#loop2
?vehicle _guy ==_guy: goto "loop"
_holder setpos [(getpos _guy select 0),(getpos _guy select 1),(getpos _guy select 2)+500]
~0.1
goto "loop2"
exit

And here's how I've got my unit loadout script (named L_I_hk416car_ACOG.sqs) setup:
Quote
; Get the unit parameter given
_unit = _this Select 0

; Strip the units current gear
RemoveAllWeapons _unit

; Add the new gear to the unit
_unit AddMagazine "SmokeShell"
_unit AddMagazine "SmokeShell"
_unit AddMagazine "HandGrenade"
_unit AddMagazine "SJB_TOS_M4_mag"
_unit AddMagazine "SJB_TOS_M4_mag"
_unit AddMagazine "SJB_TOS_M4_mag"
_unit AddMagazine "SJB_TOS_M4_mag"
_unit AddMagazine "SJB_TOS_M4_mag"
_unit AddMagazine "SJB_TOS_M4_mag"
_unit AddWeapon "SgtEv_c416_acog"
_unit SelectWeapon "SgtEv_c416_acog"
_unit AddMagazine "SJB_TOS_Colt1911_mag"
_unit AddMagazine "SJB_TOS_Colt1911_mag"
_unit AddMagazine "SJB_TOS_Colt1911_mag"
_unit AddMagazine "SJB_TOS_Colt1911_mag"
_unit AddWeapon "SJB_TOS_Colt1911"
_unit AddWeapon "Binocular"
_unit AddWeapon "NVGoggles"

Exit

Now, whenever I've tried running the gun.sqs in the init field, listed after my specified equipment as below, the game freezes up, and I then have to crash my system to reboot:
Quote
      };
      class Item13
      {
         side="WEST";
         class Vehicles
         {
            items=12;
            class Item0
            {
               position[]={15304.397461,20.339998,478.497192};
               azimut=479.799988;
               id=46;
               side="WEST";
               vehicle="OfficerW";
               player="PLAYER COMMANDER";
               leader=1;
               rank="LIEUTNANT";
               skill=1.000000;
               text="Player1";
               init="RemoveAllWeapons this; this addmagazine ""SmokeShell""; this addmagazine ""SmokeShell""; this addmagazine ""HandGrenade""; this addmagazine ""SJB_TOS_M4_mag""; this addweapon ""SgtEv_c416_acog""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this addweapon ""SJB_TOS_Colt1911""; this addweapon ""Binocular""; this addweapon ""NVGoggles""; this exec ""gun.sqs""; ";

If I simply try to run both scripts through the Player's unit's init field, when I try loading the mission the game crashes to the desktop,
The unit's init field for running just the two scripts looked like this:
Quote
init=this exec "L_I_hk416car_ap.sqs"; this exec "guns.sqs";

After the game crashes the following message is waiting for me on my desktop:
Quote
Operation Flashpoint [X]
'Users\KYLE\missions\Clear El Qlabsha.ARABIA_TadcoFarm_Bronze\mission.sqm/Mission/Groups/Item13/Vehicles/Item0.this'
: 'e' encountered instead of '='
[OK]

What am I doing wrong?


Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Assign weapons & gear via script, + script conflicts?
« Reply #5 on: 10 Nov 2007, 09:33:45 »
Ah, I didn't realise that you were trying to directly edit the mission.sqm, rather than putting the init in with the OFP editor. If you are editing directly, then yes, you need to write:
Code: (mission.sqm) [Select]
init="this exec ""L_I_hk416car_ap.sqs""; this exec ""guns.sqs"";";

But in the object initialization field (often just called init), you just write:
Code: (Object Initialization) [Select]
this exec "L_I_hk416car_ap.sqs"; this exec "guns.sqs";

The big advantage of using the editor means that it won't allow you to enter code if there is a syntax error, rather that causing OFP to CTD, if you get down and dirty by editing mission.sqm by hand. If you need to put the same init code in a lot of units, then you can still use copy-and-paste (with control-C and control-V), so there really is no reason to touch mission.sqm at all.
 
I'm assuming you didn't realise you could do this, because you can make even complex missions without ever touching mission.sqm in the way that you are. The only thing is that the default editor behaviour doesn't give you this option. You just need to toggle from "Easy" to "Advanced" editing mode, which is at the top-right of the editor screen, then double-click on the unit and enter the text into the Initialization field of the dialog window that appears.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Kyle_Kelahshehskee

  • Members
  • *
  • I'm a llama!
Re: Assign weapons & gear via script, + script conflicts?
« Reply #6 on: 11 Nov 2007, 07:29:39 »
Spooner,

A big thank you for your patient assistance in my hour(s) of need!   :good:

I tried entering the data for the unit's init field in the Mission file exactly as you described.  I received a strange result: the game gave me the default unit's equipment instead (I'm using the MCM-SLX mod, so my avatar was spawned with a M4 with a removable Aimpoint instead of the HK416 carbine ACOG that was specified in the script).  Said mod is available here: http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=78ab57d84c6570fae9fc6440838fac55;act=ST;f=4;t=69473;st=0  .  The HK416 Aimpoint + extra grenade script supplied via the doublegun script never launched, which is better than a CTD I guess.

So I then removed the script specifying my unit's initial HK416 ACOG loadout, and instead manually entered the specifics in its init field.  At the tail end of the data, I left the doublegun HK416 Aimpoint script.  This time the mission launched, I had the proper HK416 ACOG, but the HK416 Aimpoint script never launched.  I received an error message at the top of the game's screen which stated:
Quote
'_guy = _this select 0l#l': Error select: Type Object, expected Array

Other than this error message, the rest of the mission was perfectly playable.

The gun.sqs looks like this...
Quote
};
      class Item13
      {
         side="WEST";
         class Vehicles
         {
            items=12;
            class Item0
            {
               

position[]={15304.397461,20.339998,478.497192};
               azimut=479.799988;
               id=46;
               side="WEST";
               vehicle="OfficerW";
               player="PLAYER COMMANDER";
               leader=1;
               rank="LIEUTNANT";
               skill=1.000000;
               text="Player1";
               init="RemoveAllWeapons this; this

addmagazine ""SmokeShell""; this addmagazine ""SmokeShell""; this

addmagazine ""HandGrenade""; this addmagazine ""SJB_TOS_M4_mag""; this

addweapon ""SgtEv_c416_acog""; this addmagazine ""SJB_TOS_M4_mag""; this

addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this

addmagazine ""SJB_TOS_M4_mag""; this addmagazine ""SJB_TOS_M4_mag""; this

addmagazine ""SJB_TOS_Colt1911_mag""; this addmagazine

""SJB_TOS_Colt1911_mag""; this addmagazine ""SJB_TOS_Colt1911_mag""; this

addmagazine ""SJB_TOS_Colt1911_mag""; this addweapon

""SJB_TOS_Colt1911""; this addweapon ""Binocular""; this addweapon

""NVGoggles""; this exec ""gun.sqs""";
            };


I hope that this sheds some more light on this stubborn conundrum. 

Good night!
Kyle
Nov. 10, 2007

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Assign weapons & gear via script, + script conflicts?
« Reply #7 on: 11 Nov 2007, 12:14:58 »
Based on seeing the mission.sqm file (you said it was gun.sqs, but no problem since you included gun.sqs in an earlier post and yes, I should have spotted this error earlier) and the error message, I can see where you are going wrong. Whenever you see "_var1 = _this select 0;" at the start of a script, this means that the script wants to receive a parameters array, rather than a single parameter.

e.g.
Code: (top of script file expecting a single parameter) [Select]
_var = _this;

means call with:
Code: [Select]
a exec "script.sqs"
(which will make _var = a)

but
Code: (top of script file expecting an array of parameters - two in this case) [Select]
_var1 = _this select 0;
_var2 = _this select 1;

means run with:
Code: [Select]
[a, b] exec "script.sqs"
(which will make _var1 = a and _var2 = b)

Thus, in your case, you should call the script with:
Code: [Select]
[this] exec "guns.sqs"

The bigger issue, which you really have to sort out, continues to be: DO NOT EVER EDIT MISSION.SQM DIRECTLY! USE THE OFP EDITOR IN ADVANCED MODE TO PUT THE CODE DIRECTLY INTO THE INITIALIZATION FIELD:

Quote from: Spooner
I'm assuming you didn't realise you could do this, because you can make even complex missions without ever touching mission.sqm in the way that you are. The only thing is that the default editor behaviour doesn't give you this option. You just need to toggle from "Easy" to "Advanced" editing mode, which is at the top-right of the editor screen, then double-click on the unit and enter the text into the Initialization field of the dialog window that appears.

If you are now using the Initialization field, rather than going into mission.sqm, and were just showing me the file in order to show me the init field, then sorry! Nevertheless, if you are using the Initialization field properly, you can just select all the text, then use control-c, alt-tab then control-v to copy the contents of the Initialization field from the game into your web browser. This makes the text a lot easier to read than copying the contents of mission.sqm, because "s haven't been doubled.
« Last Edit: 11 Nov 2007, 12:37:43 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Kyle_Kelahshehskee

  • Members
  • *
  • I'm a llama!
Re: Assign weapons & gear via script, + script conflicts?
« Reply #8 on: 11 Nov 2007, 21:29:06 »
Spooner,

I didn't realize just how important it was to add scripts through the Mission Editor, rather than modify the Mission.sqm's contents with Notepad.  It's good to know that adjusting data through the Mission Editor does more than  just register the data that's being inputed by the person using the Editor, it also switches on/off other entries so that the newly modified data can work properly. 

Now, using only the Editor, I copied the names of the two scripts into the init field, saved the mission, and started it up.  I received the following error report at the very top of the screen:
Quote
'Save l#lthis script to a Mission file that's being EDITED, and in the Player's init field enter':Error Unknown operator this

When I spawned, I was equipped with the unit's default weapon loadout.  So, what can be done to address this snag?

I hope, man DO I hope that we're getting closer to a solution on this thing....

Yours,

Kyle
Nov. 11, 2007

Offline schuler

  • Contributing Member
  • **
Re: Assign weapons & gear via script, + script conflicts?
« Reply #9 on: 11 Nov 2007, 23:04:04 »
hi Kyle, just checking are you aware that medics and civs only have 4 slots for their main weapon? something like that would make an unknown error. i think when you solve this your going to go OOHHH WOW!
Semper Fi

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Assign weapons & gear via script, + script conflicts?
« Reply #10 on: 11 Nov 2007, 23:06:10 »
Kyle,

The most important thing about editing the mission.sqm in my opinion is that ANY mistake at all will crash the editor. At least if you input the code into the editor, it will not accept it if it has this kind of syntax error in it and you can keep trying to get it right! Nevertheless, the issues you pointed out are absolutely true as well :D

Well, based on that error you reported, you have the uncommented text, "Save this script to a Mission file that's being EDITED, and in the Player's init field enter...", in the script you are trying to run. At a guess, I'd say you removed the ; (SQS script) or // (SQF script) from the start of the line when you were editing it, which would normally tell the language interpreter to treat the line as a comment and not try to run it as though it was program code, which, predictably, causes an error.

@Schuler
I'm sure that isn't the issue here. Kyle is struggling with using scripts, not the contents of them. At least in ArmA, you can overload people in scripts as much as you like and the items are still added and can be used, but aren't seen in the inventory. addMagazine doesn't seem to take any notice of the carrying capacity of a person...
« Last Edit: 11 Nov 2007, 23:11:21 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Kyle_Kelahshehskee

  • Members
  • *
  • I'm a llama!
Re: Assign weapons & gear via script, + script conflicts?
« Reply #11 on: 12 Nov 2007, 02:00:11 »
Spooner,

I made a haphazard guest in regards to there being something wrong with one or (god forbid) both of the scripts I'm trying to run.  Neither script has any text that matches the text that was quoted in the error message.

I removed both scripts, reentered the loadout that I wanted through the Mission Editor's GUI, and the mission fired up fine.  Man, I want that extra weapon and ammo capacity, so that the loadout is more realistic.  The "extra" weapon's intended to be as if the player has the capacity to remove the ACOG and attach an Aimpoint. 

I'll play around with those danged scripts again soon.  It's like a scab, I have to keep picking at it!   :D

If you have any other ideas let me know.  I'll post here again if anything changes.


Offline Kyle_Kelahshehskee

  • Members
  • *
  • I'm a llama!
Re: Assign weapons & gear via script, + script conflicts?
« Reply #12 on: 12 Nov 2007, 04:16:55 »
Some strangeness that finally led to some results that actually worked.   :yes:

Alright, I modified a couple of "Bullet Time" Matrix-inspired scripts, and in spite of all of the recent failures with getting scripts to work, I decided to go through the trouble of trying them out.  They worked nicely.

So, thinking I was on a roll, I decided to try (again) the gun.sqs, and while the mission loaded up fine it froze up when I was killed, and I had to hard crash my system to get out of it. 

Now here's the strange part: I've been using the MCM-SLX mod while running these scripts, and there's been a number of times where I've been killed by a certain weapon and I had to reboot my system because it locked up.  Now, sometimes when this weapon kills me I'm able to Retry the mission just fine, other times it leads to the system freeze up.  I assumed it was due to a poorly coded relationship between MCM-SLX and the custom weapon, but now I'm wondering if this total locking up of my system is specifically due to the gun.sqs script.  Are some scripts more prone to failure than others?  The only time I've been able to get the gun.sqs to work is when it's the only data entered in the unit's init line, which kind of defeats the purpose of having it. 

Does the order that one lists multiple scripts have a significant impact on how effectively the scripts work/don't work in a mission?  If so, what would you recommend me to try now?  Is there a limit to the number of scripts that can be added?  The reason why I ask is that I tried having three Bullet Time scripts work, but thus far, I've only been able to have two be listed at a time in the Action Menu (and the gun.sqs puts an entry into the Action Menu for every item type listed therein). 

I'm just happy that I got a copy of scripts modified by me to finally work with this baby.  Now, if I can only get me a script that allows me to add another weapon plus grant me six or so ammo slots, I'll be really pleased with the results.

Yours,
Kyle
Nov. 11, 2007

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Assign weapons & gear via script, + script conflicts?
« Reply #13 on: 14 Nov 2007, 12:11:56 »
Well, there is no problem with starting 100 scripts from the init line if you want. The issue is with what types of scripts you are starting. Some scripts are linear and end quickly (such as your L_I_hk416car_ACOG.sqs) so they should be run with exec (which waits until the script has finished before moving on to the next command). Other scripts take a long time (containing @ or ~ commands) or never end because they have endless loops (e.g. your gun.sqs). If you use exec with these, then the next command will be delayed or never happen. In these cases, you should use execVM instead of exec, since that starts the script running and immediately moves to the next command (regardless of when the script completes).

For SQF scripts, use execVM to start it in a separate process (returns immediately) or if you want to run it in the same process (like exec does for SQS scripts):
Code: [Select]
[] call compile preprocessFileLineNumbers "script.sqf";

.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)