r/armadev • • 5d ago

Question Learning SQF Scripting and need help

I hope this is the right place for this!! I am in an Arma 3 starsim unit, I have experience with Eden and Zeusing but not much with scripting itself, so please forgive if I've made some super obvious error I just missed because I don't know anything.

I have a script (see below) that is intended to evaluate whether some shields have been disabled (deleted). If the jammer shields are still up, it is meant to display an addAction-type message hinting to the players that they need to disable those shields first. If the jammer shields are down, it is meant to be interactable to disable a second set of shields (the blue house shields). I suspect the issue is with the first message portion and that I don't have an action assigned to that part, or maybe the ordering of the sections, but the error it's giving me is that I'm missing a bracket haha. Any and all help appreciated as I am new to this :)

if (!isNull jammer_1) then {this addAction ["Disable Transmission Center Shields", [deleteVehicle blue_house_1; deleteVehicle blue_house_2;]]} else {this addAction ["Cannot Access Transmission Dish While Jammer Is Active"]};

3 Upvotes

9 comments sorted by

2

u/commandercasserole 5d ago

I can't tell you the right way to do this, or the best way to do this, I can only tell you what I would do, and I am no sqf expert. Someone may have better understanding and will comment on how to do what you are attempting, but sometimes posts here just get crickets.

Firstly, I assume you are placing this code in the init box in eden of an object? I'm guessing that from your use of "this" but I suppose I'm asking: where are you running this code? In Eden from an object init, from an external script file? From an Eden trigger? Does it matter where you want it to execute or do you just need to get the job done?

1

u/Historical_Raise326 5d ago

Yes, in a terminal object’s Init box.

I was also thinking there might be a way to do this where it wouldn’t have to be constantly checking for the jammer shield and maybe upon deletion a shield could change a variable’s value or send a behind the scenes message that would trigger the change in the terminal? thanks for your time aha

1

u/commandercasserole 5d ago

This was pasted on mobile app so. I have made it a bit more complicated because I edited the first addaction I found in my library.

The initial part has structured text, that's what all the align, shadow, size is about. It makes the option on screen appear bigger for players. You can remove all of that and just have text between the quotation marks like so "Activate thingy".

Inside the {} of the first addaction, it lists some parameters _target, _caller etc. This is only in there as a short bit of code to remove the action once it has been used. That doesn't have to happen, but otherwise someone could use it again. Again, no big deal as the objects will have already been deleted so they can't be deleted again, it won't give an error (I think). The Hint will display again though I believe, but that's no big deal. That first bit is not necessary, it's all about deleting the action.

Then in the brackets the 2 objects deleted and a hint displayed on screen to give whatever feedback you want. The hint part can be deleted if you don't want any.

Then there's a bunch of extra parameters for the addaction. These are on the BI wiki explaining what they do. I didn't need most of them but if I need one towards the end of the list I need to put all the prior ones in so it knows the order and can refer to the correct thing. In this case "!alive jammer" is the key. The action will only appear once jammer is not alive. That's better than isNull, I think. That's how I would do it.

After the jammer check, there is a 3, which is the distance from the object that the action appears. Increase it for players to interact from further away.

The second addaction is identical for the most part but the code in {} is just a hint saying something is wrong, you need to do something first. Then the condition to show when the action appears is "alive jammer". Once the jammer is dead, this action can't appear any more.

2

u/Historical_Raise326 4d ago

Oh my goodness thank you so much for the time you put into this and the help!! I will need to try it out, not at my computer right now, but I appreciate it so much holy cow

2

u/Historical_Raise326 4d ago

This worked beautifully and I really appreciate your explanation of all the parts -- I didn't know I could even edit the text like that or delete the action so it wouldn't try to run it again if used! Thank you again for your patience and time!

1

u/commandercasserole 5d ago

I'm out of work at the moment so I'm gonna fire up the laptop and make sure I get this right...

1

u/commandercasserole 5d ago

I would have two add action codes on the same object, one checking if the target thing is alive, and one for if it's dead. Apologies for any formatting that might be about to happen when I paste this code. I will reply in separate message for just the code, the explanation will be after

1

u/commandercasserole 5d ago

this addAction [ "<t align = 'center' shadow = '2' color='#FFFFFF' size='1.5' font='PuristaMedium' >Disable Shields</t>", { params ["_target", "_caller", "_actionId", "_arguments"]; _target removeaction _actionId; deleteVehicle bluehouse; deleteVehicle bluehouse2; hint "SHIELDS DISABLED, WELL DONE!"

}, nil, 6, true, true, "", "!alive jammer", 3, false, "", "" ];

this addAction [ "<t align = 'center' shadow = '2' color='#FFFFFF' size='1.5' font='PuristaMedium' >Disable Shields</t>", { hint "NOTHING HAPPENS. YOU MUST DO THE OTHER THING FIRST"

}, nil, 6, true, true, "", "alive jammer", 3, false, "", "" ];

0

u/HateAndCaffeine 3d ago

I think you’re looking for “hint” and not “addAction”