djtonybe 10 Posted September 10, 2010 I honestly can not get my head around this language (and i learnt C++ completely in 2 weeks). It doesn't help that there is no proper guides to scripting in this language and the variables / calls etc etc seem to be all over the place. And having 1 liner examples really doesn't help to understand how some functions/ constructs work. Share this post Link to post Share on other sites
shuko 59 Posted September 10, 2010 What was the question? SQF is just simple scripting language. You have your simple, common, IF, WHILE etc and a list of commands. Since it's just scripting, only thing you need to worry about variables is their scope. Functions Share this post Link to post Share on other sites
Muzzleflash 111 Posted September 10, 2010 One of the reasons you see more calls and variables everywhere is probably due to two reason - Unlike C++, SQF is not (has not OO) object oriented - Script are called from various places, from initialization lines, triggers, other scripts, where-as in a typical C++ program your application has one entry point. Share this post Link to post Share on other sites
kylania 568 Posted September 10, 2010 Read this, and don't over think things. :) Share this post Link to post Share on other sites
djtonybe 10 Posted September 10, 2010 Thats probably where the problem starts. there is no one off entry point which you can define and run everything. Just even with a basic ammo refil script, the script runs but i can't get the specific boxes to fill with specific weapons, i.e. extract while {true} do { (format ["Filling Ammo Box."] call XfGlobalChat); // Clear box clearWeaponCargo _this; clearMagazineCargo _this; // Gets upto here okay // Fill box if ( this isKindOf "USBasicAmmunitionBox_EP1" ) then // have tried if ( this Name == "AmmoCrateUSA" ) then { hint "American Ammo Crate being filled"; // US Army Weapons & Ammo _this addWeaponCargo ["M14_EP1", _amountWeapon]; I just can't seem to determine either the type of crate or the name of crate which is cruical to this part of the script. In C++, its as simple as this.name == etc etc.. ---------- Post added at 02:36 PM ---------- Previous post was at 02:34 PM ---------- Read this, and don't over think things. :) Read it, no help. Share this post Link to post Share on other sites
CarlGustaffa 4 Posted September 10, 2010 (edited) Maybe interesting. Some oo related things. Code looks a lot like Domination. For someone with coding skills and background, it might be a good place to start as it shows some examples of efficiency. But still the basic syntax of the language (which may seem a bit "off", but makes it kinda easy to read for those with no coding background at all) is something everyone needs to get a grasp on. First of all, this command is not available in scripts in "that form" (check the link). Order is correct for isKindOf, but when you know you have the "master class" you could have used the typeOf command instead. The isKindOf command is more to check if an item belongs to a certain hierarchy, i.e. myHMMWV isKindOf "car". But then you go "this name == .....". If you check the syntax for name, you'll see that it is in fact "name this == .....", or rather "name _this" or "name (_this select 0)" (for arrays). Also, you would have found that name may not even work the way you expect. Maybe you were looking for vehicleVarName instead? List of all (well, some new ones are still missing) commands: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2 Sorted by functionality: http://community.bistudio.com/wiki/Scripting_Commands_by_Functionality Control Structures: http://community.bistudio.com/wiki/Control_Structures Already mentioned... This: http://community.bistudio.com/wiki/this Oh, shk had already covered some of these. I must stop reading threads backwards :D Edited September 10, 2010 by CarlGustaffa Share this post Link to post Share on other sites
kylania 568 Posted September 10, 2010 Why is the name of the crate in any way crucial? The type of the box shouldn't matter either. You know which crate it is already, just create a script that fills it with what you want and run it from the crate's init field. No if's or names or anything required. Or make it generic like all other crate fillers are, where the object being filled is passed when you call the script and captured in script by _this. // Called from an ammocrate's init field via: // nul = this execVM "ammo.sqf"; while {alive _this} do { // Remove the stock items from the crate clearMagazineCargo _this; clearWeaponCargo _this; // Mk16 SCAR GLs _this addWeaponCargo ["SCAR_L_CQC_EGLM_Holo", 10]; _this addWeaponCargo ["SCAR_L_STD_EGLM_RCO", 10]; _this addWeaponCargo ["SCAR_L_STD_EGLM_TWS", 10]; // Ammo and 203s _this addMagazineCargo ["30Rnd_556x45_Stanag", 100]; _this addMagazineCargo ["1Rnd_HE_M203", 100]; // Restock time. 1800 = 30 minutes. sleep 300; }; You're really really making this way too complicated by trying to code it as if it's C++, it's not. It's just a scripting language, keep it simple. Also, since you're using the XFGlobalChat function it's clear that you're trying to start your scripting career by modifying Domination. That's a really silly way to start, especially if you're getting confused by the basics of SQF. Forget Domination, start with simple scripts and simple syntax then move up to the more complex things like Domi. Share this post Link to post Share on other sites
st_dux 26 Posted September 10, 2010 @djtonybe: You just aren't following the correct syntax of the scripting commands. Be sure to use the Biki (community.bistudio.com/wiki) to reference commands and get syntax instructions; don't just try to guess has stuff works. As for the script snippet you provided... - "this" in the if statements should be "_this" - "(_this Name =='AmmoCrateUSA')" should simply be "(_this == AmmoCrateUSA)" with no quotation marks around "AmmoCraateUSA." Share this post Link to post Share on other sites
sbsmac 0 Posted September 10, 2010 You might find squint useful as well - it should at least stop you tearing your hair out over where the semi-colons go ;) Share this post Link to post Share on other sites
djtonybe 10 Posted September 10, 2010 yey.. thanks guys, working now finally. In answer to a couple of questions, if i just put it all in one ammo box like all others, i would just use the domination scripts. Ironically, the reason i am looking Domi commands because its a working script dispite all the little bugs in it. Just a few more thousand little problems to fix now.. Starting with vehicles and catching that darn GetIn eventhandler.. Share this post Link to post Share on other sites
Muzzleflash 111 Posted September 10, 2010 ... Starting with vehicles and catching that darn GetIn eventhandler.. Just noticed a bug in the example I posted in your other thread. Just tested and this example works assuming your vehicle is named "car" in the editor. init.sqf: waitUntil {!isNil "car"}; car addEventHandler ["GetIn", {(_this select 2) action ["getOut", car];}]; Share this post Link to post Share on other sites