Comrades in Arms Discussion Board

Full Version: Help with script syntax
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can someone help with this syntax:

Code:
;;Create Init Line String to be used in createUnit command
;;This will run the correct loadout and add the HDmag interchange event handler to the soldier
_InitLine = format ["[this] exec {%1};this addEventHandler [""killed"",{_this exec ""MagChangeOut.sqs"";""hit"",_this exec ""throwSmoke.sqs"";_this exec ""removeDeadAI.sqs""}]",_Loadout]

I want to get rid of the MagChangeOut.sqs upon being killed but can't quite get the syntax or the  [ or { right... >Sad
Are you trying to add multiple eventHandlers with only one addEventHandler command, or what does the ""hit"" in the curled braces mean?
Sorry, I should explain more...

The script as posted above works fine.

But I want to edit it and get rid of the MagChangeOut.sqs. I'm just not sure how to delete that part of it so the throwsmoke.sqs upon being hit, and the removeDeadAI.sqs upon being killed still work...

It's all part of an AI spawning script that has units with JAMHD weapons that I'm converting to WGL....

What the MagChangeOut.sqs does is replace the HD mags with "straight-shooting" ones when the unit is killed, so you can pick up non HD mags/weapons. I don't need this script and the reference to it as I'm concverting to WGL...
Hey Marto;

Just a shot in the dark but try to change this:
Quote:;;Create Init Line String to be used in createUnit command
;;This will run the correct loadout and add the HDmag interchange event handler to the soldier
_InitLine = format ["[this] exec {%1};this addEventHandler [""killed"",{_this exec ""MagChangeOut.sqs"";""hit"",_this exec ""throwSmoke.sqs"";_this exec ""removeDeadAI.sqs""}]",_Loadout]

To this:
Quote:;;Create Init Line String to be used in createUnit command
;;This will run the correct loadout and add the HDmag interchange event handler to the soldier
_InitLine = format ["[this] exec {%1};this addEventHandler [""killed"",{_this exec ""throwSmoke.sqs"";_this exec ""removeDeadAI.sqs""}]",_Loadout]

Like Zwobot questioned the "Hit"....it looks out of place there(???) Event handlers can get tricky. You can look to the BIS forums, I got an event handler problem fixed by someone there some time ago.
http://forums.bistudio.com/forumdisplay.php?f=26
I changed it to this:

Code:
_InitLine = format ["[this] exec {%1};this addEventHandler [""killed"",{_this exec ""removeDeadAI.sqs""; ""hit"",_this exec ""throwSmoke.sqs""}]",_Loadout]

And no error messages come up now. But as you guys say the "hit" bit doesn't work because I never see them throwing smoke... ???
And here is throwsmoke.sqs

Maybe there is an error here (I've added the smk gren to the units)

Code:
;;Have AI throw smoke if hit
;_this select 0 : who's hit
;_this select 1 : who shot
;_this select 2 : scalar damage value

_unit = _this select 0
_shooter = _this select 1

_chance = .8
_rand = random 1

? _chance >= _rand : goto "throw"
exit

#throw
_unit doTarget _shooter
_unit fire ["throw", "WGL_SmokegrenadeYellow"]
Marto;

This is the format EH's need to take:
Quote:Example:
player addEventHandler ["killed",{_this exec "playerKilled.sqs"}]


I think this would be more correct:
Quote:_InitLine = format "[this] exec {%1};_this addEventHandler [""killed"",{_this exec ""removeDeadAI.sqs""; ""hit"",{_this exec ""throwSmoke.sqs""}]",_Loadout]
<<_Loadout at end looks funny also...may not do anything there.


One thing I noted in my references is "Note: EHs are not compatible with multiplayer games."

(07-03-2009, 05:48 AM)Zulu1 link Wrote: [ -> ]http://forums.bistudio.com/forumdisplay.php?f=26

Thanks Zulu, Ill try that. I forgot to mention your link only went to a main OFP : MISSION EDITING & SCRIPTING  forum not to a specific post so I couldnt check it out. I think some of the link text is missing??

Regarding eventhandlers in multiplayer, that's strange because with the above scripts I posted, the removedeadAI works fine in MP on dedicated server...