Jump to content

Search the Community

Showing results for '"code snippet"' in content posted in ARMA 3 - MISSION EDITING & SCRIPTING and posted by dreadedentity.


Didn't find what you were looking for? Try searching for:


More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • BOHEMIA INTERACTIVE
    • BOHEMIA INTERACTIVE - NEWS
    • BOHEMIA INTERACTIVE - JOBS
    • BOHEMIA INTERACTIVE - GENERAL
  • FEATURED GAMES
    • Arma Reforger
    • Vigor
    • DAYZ
    • ARMA 3
    • ARMA 2
    • YLANDS
  • MOBILE GAMES
    • ARMA MOBILE OPS
    • MINIDAYZ
    • ARMA TACTICS
    • ARMA 2 FIRING RANGE
  • BI MILITARY GAMES FORUMS
  • BOHEMIA INCUBATOR
    • PROJECT LUCIE
  • OTHER BOHEMIA GAMES
    • ARGO
    • TAKE ON MARS
    • TAKE ON HELICOPTERS
    • CARRIER COMMAND: GAEA MISSION
    • ARMA: ARMED ASSAULT / COMBAT OPERATIONS
    • ARMA: COLD WAR ASSAULT / OPERATION FLASHPOINT
    • IRON FRONT: LIBERATION 1944
    • BACK CATALOGUE
  • OFFTOPIC
    • OFFTOPIC
  • Die Hard OFP Lovers' Club's Topics
  • ArmA Toolmakers's Releases
  • ArmA Toolmakers's General
  • Japan in Arma's Topics
  • Arma 3 Photography Club's Discussions
  • The Order Of the Wolfs- Unit's Topics
  • 4th Infantry Brigade's Recruitment
  • 11th Marine Expeditionary Unit OFFICIAL | 11th MEU(SOC)'s 11th MEU(SOC) Recruitment Status - OPEN
  • Legion latina semper fi's New Server Legion latina next wick
  • Legion latina semper fi's https://www.facebook.com/groups/legionlatinasemperfidelis/
  • Legion latina semper fi's Server VPN LEGION LATINA SEMPER FI
  • Team Nederland's Welkom bij ons club
  • Team Nederland's Facebook
  • [H.S.O.] Hellenic Special Operations's Infos
  • BI Forum Ravage Club's Forum Topics
  • Exilemod (Unofficial)'s General Discussion
  • Exilemod (Unofficial)'s Scripts
  • Exilemod (Unofficial)'s Addons
  • Exilemod (Unofficial)'s Problems & Bugs
  • Exilemod (Unofficial)'s Exilemod Tweaks
  • Exilemod (Unofficial)'s Promotion
  • Exilemod (Unofficial)'s Maps - Mission Files
  • TKO's Weferlingen
  • TKO's Green Sea
  • TKO's Rules
  • TKO's Changelog
  • TKO's Help
  • TKO's What we Need
  • TKO's Cam Lao Nam
  • MSOF A3 Wasteland's Server Game Play Features
  • MSOF A3 Wasteland's Problems & Bugs
  • MSOF A3 Wasteland's Maps in Rotation
  • SOS GAMING's Server
  • SOS GAMING's News on Server
  • SOS GAMING's Regeln / Rules
  • SOS GAMING's Ghost-Town-Team
  • SOS GAMING's Steuerung / Keys
  • SOS GAMING's Div. Infos
  • SOS GAMING's Small Talk
  • NAMC's Topics
  • NTC's New Members
  • NTC's Enlisted Members
  • The STATE's Topics
  • CREATEANDGENERATION's Intoduction
  • CREATEANDGENERATION's HAVEN EMPIRE (NEW CREATORS COMMUNITY)
  • HavenEmpire Gaming community's HavenEmpire Gaming community
  • Polska_Rodzina's Polska_Rodzina-ARGO
  • Carrier command tips and tricks's Tips and tricks
  • Carrier command tips and tricks's Talk about carrier command
  • ItzChaos's Community's Socials
  • Photography club of Arma 3's Epic photos
  • Photography club of Arma 3's Team pics
  • Photography club of Arma 3's Vehicle pics
  • Photography club of Arma 3's Other
  • Spartan Gamers DayZ's Baneados del Servidor
  • Warriors Waging War's Vigor
  • Tales of the Republic's Republic News
  • Operazioni Arma Italia's CHI SIAMO
  • [GER] HUSKY-GAMING.CC / Roleplay at its best!'s Starte deine Reise noch heute!
  • empire brotherhood occult +2349082603448's empire money +2349082603448
  • NET88's Twitter
  • Mercurious Brotherhood +2347063372861's +2347063372861>> I WANT TO JOIN OCCULT FOR MONEY RITUAL
  • 123betcasino01's Topics

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Yahoo


Jabber (xmpp)


Skype


Biography


Twitter


Google+


Youtube


Vimeo


Xfire


Steam url id


Raptr


MySpace


Linkedin


Tumblr


Flickr


XBOX Live


PlayStation PSN


Origin


PlayFire


SoundCloud


Pinterest


Reddit


Twitch.Tv


Ustream.Tv


Duxter


Instagram


Location


Interests


Interests


Occupation

Found 17 results

  1. Hello, I'm DreadedEntity pushing out another code snippet for everyone. This time it's a super-simple countdown timer. This script will count down from the amount of seconds you give it, and it will also display it in an optional debug parameter. Actually, all of the parameters are optional. So here's the script: DE_countdown.sqf: /* Usage: [60, "myOutput", true] spawn DE_countDown; (if using execVM: [60, "myOutput", true] execVM DE_countDown;) Parameters: P1: NUMBER - The number of seconds from which to count down from. (Default: 300, 5 minutes) P2: STRING - The string name for the global variable which you want to output. (Default: "DE_countdown") P3: BOOLEAN - Debug. True to display a hint with the current time, false to not. (Default: true) Returns: Script Handle, allows you to check if the countdown has finished -Second parameter also allows the content creator to use the timer in any way he/she desires (ie. within a dialog). Format of the output is [hours, minutes, seconds] and can be accessed using: _countdown = missionNamespace getVariable "DE_countdown"; */ DE_timer = { _seconds = [_this, 0, 300, [0]] call BIS_fnc_param;; _secondsTemp = 0; _minutes = 0; _hours = 0; _globalVar = [_this, 1, "DE_countdown", [""]] call BIS_fnc_param; _hint = [_this, 2, true, [false]] call BIS_fnc_param; while {_seconds > 0} do { _timer = [] spawn {uiSleep 1;}; _seconds = _seconds - 1; _hours = floor (_seconds / 3600); _minutes = floor((_seconds - (_hours * 3600)) / 60); _secondsTemp = floor (_seconds - (_hours * 3600) - (_minutes * 60)); if (_hours < 10) then { _hours = "0" + (str _hours); }; if (_minutes < 10) then { _minutes = "0" + (str _minutes); }; if (_secondsTemp < 10) then { _secondsTemp = "0" + (str _secondsTemp); }; waitUntil {scriptDone _timer}; missionNamespace setVariable [_globalVar, [_hours, _minutes, _secondsTemp]]; if (_hint) then { hint format ["%1:%2:%3", _hours, _minutes, _secondsTemp]; }; }; }; Enjoy!
  2. Hello! I was watching videos of milsim clans playing the game, people were out of ammo, they were being overwhelmed by enemies. In the heat of battle, a guy dropped a magazine on the ground and his teammate had to look down at the ground to pick it up. This isn't realistic! (well in a real battle you probably wouldn't throw mags) "Never again", I said and I got to work. 2 or 3 hours later, here's what I made. Code:
  3. Hey guys, been a while since I did a code snippet, so here's a new one. There's a lot of room for improvement, to be honest, I couldn't find a lot of the answers that I've been looking for in the configs for the past few days. Anyway, here's a video and the code is below that: VERSION 2: this addAction ["Remove Dead (TESTING)", { _veh = _this select 0; _vehPos = getPos _veh; _posDriverExit = _veh selectionPosition ("pos driver"); _posCommanderExit = _veh selectionPosition ("pos codriver"); _posCargoExit = _veh selectionPosition ("pos driver"); _posDriver = (driver _veh) worldToModel _vehPos; _posCommander = (commander _veh) worldToModel _vehPos; _posCargo = ((crew _veh ) select 0) worldToModel _vehPos; _driverExitOffset = (_posDriverExit select 0) - (_posDriver select 0); { if !(alive _x) then { _deadPos = _x worldToModel _vehPos; if ((_deadPos select 0) > 0) then { _deadPos set [0, (_deadPos select 0) + (abs _driverExitOffset)]; }else { _deadPos set [0, (_deadPos select 0) + (_driverExitOffset)]; }; _deadExitPos = _x modelToWorld _deadPos; _deadExitPos set [1, (getPos _x) select 1]; _x setPos _deadExitPos; }; } forEach (crew _veh); }, nil, 6, true, true, "({!alive _x} count (crew _target) > 0)"]; The condition in the action is still not working as I intended but I am incapable of caring any less about that.
  4. Hello fellow content creators, As all of us know, BI gives us pretty much complete freedom in how we can mod their game. Now, everyone that's been doing this for a while knows that as you allow more freedom, things become overall more complicated. The reason why is pretty simple, as you give more freedom, you have to have to add more commands to the game and the wiki. Eventually commands will get lost in the deep web and become extremely obscure. So, I'm here again with another code snippet, and maybe a much longer post. The reason I've embarked on this quest was because a few days ago someone was asking about how to disable players from accessing the map. I came up with 2 solutions but both were ugly, and barely working. So I dug deep into the wiki, and I'm back now and going to do a full write-up. Okay now, first, I'm going to show off some code and then go through it (possibly line-by-line), then finish off with some closing notes. Prevent players from reloading if they have a full magazine: _doNotReload = (findDisplay 46) displayAddEventHandler ["KeyDown", { _handled = false; if ((_this select 1) in (actionKeys "ReloadMagazine")) then { _magazine = []; { if ((_x select 2) && ((_x select 4) == currentMuzzle player)) then { _magazine = _x; }; }forEach (magazinesAmmoFull player); if (getNumber (configfile >> "CfgMagazines" >> (_magazine select 0) >> "count") == (_magazine select 1)) then { _handled = true; hint "Your magazine is full, don't reload"; }; }; if (_handled) then { []spawn { sleep 1; hintSilent ""; }; }; _handled }]; Okay, first off: _doNotReload = (findDisplay 46) displayAddEventHandler ["KeyDown", This adds a display event handler with the ID stored in a variable called _doNotReload, which is necessary if you ever want to remove the event handler. findDisplay will return the actual "display" value when you give the command a display IDD, using this you can add your event handler, 46 is the default, main game display. Seriously, click on that link and read it for yourself, it's hard to explain. "KeyDown" is the event handler we'd like to add, click on that link for a full list. DO NOTE: In my code I have "KeyDown" instead of "onKeyDown". I have tested "onKeyDown", "onKeyUp", "onMouseButtonDown", and "onMouseButtonUp" and none of them work unless you drop 'on' in front of them, suggesting that all of them on that list will work if you don't put 'on' in the beginning (but I only tested those 4). Actually, explaining all this sucks. Read over the code and if you have questions feel free to leave a comment and I'll answer to the best of my ability. A few reference pages from the wiki. actionKeys, DIK KeyCodes, A2 CfgDefaultKeysMapping Now, that last page is pretty much for just Arma 2, but while writing this post I found out how to get to the Arma 3 default keys. Go to the configViewer (cog symbol at the top of the editor), scroll to CfgDefaultKeysPresets -> Arma 3 -> Mappings. From there you can look at all of the actions in the game. By the way, here is that completed code that disables a player's map (and the GPS if they are bound to the same key, like the default keys are set up). disableMap = (findDisplay 46) displayAddEventHandler ["KeyDown", { _handled = false; if ((_this select 1) in (actionKeys "ShowMap")) then { hint "You cannot open the map"; _handled = true; }; if (_handled) then { []spawn //this spawn clears the hint after 1 second, in case anyone was wondering and couldn't figure it out { sleep 1; hintSilent ""; }; }; _handled }]; Hope that helps guys, enjoy.
  5. Hello all, Earlier today someone was asking about building a base. Being the good guy that I am I started working on something that would make it easy to build bases. Rather than making ~30 edits to the code over the course of an hour like I usually do, I got it to a point where it works then posted it. Then I lazily beefed it up a little more over the course of the past few hours. This is the ultimate result. Working in the current release of Arma 3 at the time of this posting. Copy this and paste it into the Debug Console, then click "Local Exec" actionStatus = false; { removeAllActions _x; removeAllActions player; }forEach (allMissionObjects "ALL" - [player]); { _x addAction ["Pick Up", { if (!actionStatus) then { (_this select 0) attachTo [(_this select 1)]; (_this select 0) setUserActionText [(_this select 2), "Drop"]; heldObject = (_this select 0); heldObjectDir = (direction(_this select 0)); currentAction = _this select 2; rotateEvent = (findDisplay 46) displayAddEventHandler ["keyDown", " if (_this select 1 == 51) then { heldObjectDir = heldObjectDir - 1; heldObject setDir heldObjectDir; }; if (_this select 1 == 52) then { heldObjectDir = heldObjectDir + 1; heldObject setDir heldObjectDir; }; if (_this select 1 == 207) then { detach heldObject; actionStatus = false; heldObject setUserActionText [currentAction, ""Pick Up""]; player removeAllEventHandlers ""keyDown""; }; if (_this select 1 == 211) then { detach heldObject; deleteVehicle heldObject; actionStatus = false; }; if (_this select 1 == 210) then { createVehicle [typeOf heldObject, getPos heldObject, [], 0, ""CAN_COLLIDE""]; }; false;"]; }else { detach (_this select 0); (_this select 0) setUserActionText [(_this select 2), "Pick Up"]; player removeAllEventHandlers "keyDown"; }; actionStatus = !actionStatus; },[],6,true,true,"",""]; }forEach (allMissionObjects "ALL" - [player]); player addAction ["Save to clipboard", { clipboard = ""; { if (typeOf _x != "Logic" && {typeOf _x != "Snake_random_F"} && {typeOf _x != "FxWindPollen1"} && {typeOf _x != "FxWindGrass2"}) then { pos = getPos _x; pos set [2, round (pos select 2)]; clipboard = clipboard + format["_obj = createVehicle [""%1"", %2, [], 0, ""NONE""]:_obj setDir %3:", typeOf _x, pos, round direction _x]; }; }forEach (allMissionObjects "ALL" - [player]); copyToClipboard clipboard; }]; TO USE THIS: First you need to put some things down in the editor. Place more than you need. You can delete stuff you don't want by picking it up and pressing "delete". You can also rotate objects by picking them up and pressing either < or >. They are bound like you think they would be, < rotates counter-clockwise and > rotates clockwise (like arrows pointing). Note: For some reason infantry doesn't like to be rotated, they will turn back to where they started (from what I could tell, the output is unaffected by their stupid behavior). ADDED: 2 new buttons; "Insert" will create a duplicate of the currently held object but you need to go back to the Debug Console and click "Local Exec" again (or click it a few times, I've already sorted out the issues with this) or else there won't be options to pick up the duplicated objects. "End" is an emergency drop button, I realize that for some objects you will not be able to "drop" them because the option doesn't show up. Just press "End" and the object will be dropped right where it is (I have also already sorted out the issues with this). TO SAVE: Select the "Save to Clipboard" option, then open notepad and paste the result. Press "ctrl + h" and replace all colons ( : ) with semicolons ( ; ). After that point you can then copy it again and paste the code right into your script. Wham, bam, easy peasy. A NOTE ABOUT SAVING: There are many random objects that get picked up when you use "allMissionObjects" for some reason (like snakes), I did a quick test and made a filter for a few of these items. If you are using this piece of code and you notice some random classname in the output, comment back here and I'll add it to the filter. For other scripters: For some reason, if you put a unit down, you are still able to rotate it until you pick up another unit. This is a bug due to my lack of knowledge of removing a display event handler. There is a piece of code in there that needs to be replaced, but the code still runs and without problem so I left it in as a guide on what to replace. Enjoy
  6. Hello! It has been a long time since I have made a code snippet! I am going to start making a GUI tutorial soon (maybe a series) but I don't like several of the things I had to do when I started learning about GUI's in Arma. Like many, I read and followed Iceman77's guide (and even had the privilege of having him in my teamspeak server multiple times), and bangabob's video tutorial. However, these required you to download/copy some files that had been already created for you. For a long time while I was learning, I did not realize the freedom that was available to me. Of course, a fair amount of my misunderstanding was probably due to naivete with the engine. However, in my tutorial series I want to express how much freedom one has and teach people not to be scared of searching for information and trying new things, not just follow a guide. So to prevent having to provide some file(s) that won't teach the viewer anything, I wanted to write a function that will allow them to "export" a config straight from the game, using BIS's default values. Note: This function must be compiled using the functions library with the Tag "DREAD" and the name "copyConfigClass" to work properly. As it is a recursive function, if you want to compile it with a different name, you will have to edit the self-call within the function yourself. The easiest way to use this script is to compile it using the functions library, using the names I have listed previously. So without further delay, here's my script: fn_copyConfigClass.sqf /////////////////////////////////////// // Function file for Armed Assault 3 // // Created by: DreadedEntity // // // // MUST BE COMPILED WITH THE // // FUNCTIONS LIBRARY // //Tag = DREAD Name = copyConfigClass// /////////////////////////////////////// /* TO USE: _partialClass = [config] call DREAD_fnc_copyConfigClass; INPUT: config: TYPE - Config | Anything that is not a config class is rejected. OUTPUT: _partialClass: TYPE - STRING | USED BY THE FUNCTION TO CREATE OUTPUT, DO NOT OVERWRITE HOWEVER, it is possible to save the result outside of the function, to run it multiple times ex. _textBoxClass = [configFile >> "RscText"] call DREAD_fnc_copyConfigClass; _listBoxClass = [configFile >> "RscListBox"] call DREAD_fnc_copyConfigClass; _buttonClass = [configFile >> "RscButton"] call DREAD_fnc_copyConfigClass; TO CLIPBOARD: Outputs a full class definition, even returning subclasses and their attributes, and it's nicely formatted with tabs. I'm such a god. */ private ["_parents","_numTabs","_numParams","_param","_newConfig","_params"]; _MAKE_TABS = { _tabs = ""; for "_t" from 1 to _this do { _tabs = _tabs + (toString [9]); }; _tabs; }; if (!isClass (_this select 0)) exitWith {"Input Was Not A Class"}; _newLine = toString [13, 10]; _parents = [_this select 0] call BIS_fnc_returnParents; _numTabs = _this param [1, 0, [0]]; _output = _this param [2, "", [""]]; _output = _output + (_numTabs call _MAKE_TABS) + "class " + (configName (_this select 0)) + _newLine + (_numTabs call _MAKE_TABS) + "{" + _newline; _params = []; { _numParams = (count _x) - 1; for "_i" from 0 to _numParams do { _param = configName (_x select _i); _newConfig = (_this select 0) >> _param; if (isClass _newConfig) then { _output = [_newConfig, _numTabs + 1, _output] call DREAD_fnc_copyConfigClass; } else { _newParam = _param; _data = nil; switch (true) do { case (isNumber _newConfig): { _data = getNumber _newConfig; }; case (isText _newConfig): { _data = str(getText _newConfig); }; case (isArray _newConfig): { _newParam = _newParam + "[]"; _data = str(getArray _newConfig); _data = "{" + (_data select [1, (count _data) - 2]) + "}"; }; }; if (_params find _param == -1) then { _output = _output + ((_numTabs + 1) call _MAKE_TABS) + format["%1 = %2;%3", _newParam, _data, _newLine]; _params pushBack _param; }; }; }; } forEach _parents; _output = _output + (_numTabs call _MAKE_TABS) + "};" + _newline; copyToClipboard _output; _output; Lastly, I'd like to thank the person who wrote the code for the Splendid Config Viewer; whose code was so bloated and unreadable I experienced the greatest headache of my life from reading it, and probably got cancer.
  7. I have made several changes from the original post. You will always be able to get the latest updates from Github. The post below will still serve as a learning tool, but if you intend on using this system in your missions, you should get the updated version Hello! I am back again with something pretty fun today. First, the setup. I have been playing a lot of Arma lately and, naturally, with how involved I was in scripting and this forum years ago I eventually found my way back here. So I've been playing various scenarios that the community has made and, while generally really good, something that always bothers me is the lack of a revive system, or a bad one. So let's make one; and give it away to the community as a nice base to work with. The goal here is simple; provide an easy, low-code, feature-rich system that can be customized and/or expanded upon. Simply put, if the code wasn't required, it's not here(with some tolerance to fun stuff that I actually did add anyway). For those of you that like to "try before you buy" so to speak, I have recorded and uploaded a video to show you what you're about to be getting into: Stop. Here is your only warning: This ain't your grandaddy's forum post. It's definitely the longest I've ever posted here, possibly the longest forum post I've ever made, on top of that, I'd even expect some of the highly-knowledgeable among us to sit with this for some time and digest it. So go refill your drink, take those last bites of dinner, and buckle in Initially I was going to just do a code snippet, like I used to do way back when, with BIS_fnc_holdActionAdd, a command that I had not known about before and might not have known about were it not for my bad habit of trying to answer every question on this forum. It has a really nice effect in my opinion, and is featured heavily in the "Old Man" scenario. Anyway, I should begin To start, we have 2 options for the actual reviving part of the revive system, which I call a "holding" type or a "click-and-wait" type. I am a much bigger fan of the "holding" revive, so I will quickly go over the "click-and-wait" type so we can move on. This might be obvious, but this type uses a basic addAction for functionality: To use this, just pass the unit via call or spawn. For example, let's give all players in a particular mission the ability to revive each other: { _x call addPlayerClickRevive } forEach allPlayers; Don't worry about unitSetReviveState, because I'm going to go over that in just a bit. But look, our "click-and-wait" revive system is done! Letsmoveonplease Next up, the pièce de résistance, the "holding" type revive. I like this one much more because of the effect. Either way, we're starting the same, create a function that will just add a revive action to units: And look, there's that unitSetReviveState again. I guess I should post that before anyone gets their pitchforks out. It is just a wrapper for a few commands that give the effect of a unit being dead because I got tired of typing the same commands over and over: Now, those eagle-eyed among you probably noticed that none of this works unless the unit is in a particular lifeState. But how do you get into the "incapacitated" life state? Whenever I shoot something it just dies?? Well, ironically because this post gained some popularity recently, we are going to use the exact same thing, the "HandleDamage" event handler. By the way, I started working on this just days before that post got necro'd 😉. I'll let you read the documentation and the previously mentioned post on your own time, so for now just trust me that this does work: "Now wait just a minute, Dread, I don't have any friends to play Arma with and it's just me and my AI squad all the time" Well don't you worry because that is up next. This is a full-featured revive system after all. Here is a function that will order a supplied unit to revive a supplied body; the unit will run over to the dying unit, perform the same animations the player does, and the unit will rise again to continue being cannon fodder to Opfor (looking at you, player). The second code block is simply a wrapper for "addAction" syntax so I didn't need to mangle the first function due to weird arguments from addAction: So there you have it, I have now given you all the pieces you need for a revive system. How you script them together is up to you...Alright, look, since I am a really nice guy, I'll also give you some sample stuff that will just work right out of the box. This bit of code will add revive icons to all dying units, and even switch it to a healing icon when someone is reviving: Look I know I said: But I also said: And this is one of those things Next up, this piece of code will add a revive action for each nearby (50 meters by default) dying guy to all AI squadmates. If the unit goes further than 50 meters away, the action is also cleaned up (removed). This is a safeguard, because one of the biggest annoyances I've found so far with existing revive systems is that while it is possible to order AI squadmates to use actions (6 in the command menu), like reviving, it is actually kind of finnicky to get the option to show up, you basically have to order the unit to stand right next to/on top of whatever to use the action and by the time you get it working you might as well have just done it yourself. Bonus tip, there is a sleep 0.01 that is strictly there to allow the thread to suspend so any other scripts you have can run, because I'm a really nice guy, remember? So yeah here it is: Normally I hate nesting so many scopes, but in this case I'll allow it because it's so dang useful Lastly, here's some example stuff (in order). How to "kill" a unit without actually killing a unit (shoutout to the discord #scripting for giving me a simple solution). Make AI go from unit to unit reviving everybody (from the video)(hardcoded...figure it out yourself). How to actually add the revive system to a unit (literally just call addRevive and pass in the unit). And the coup de grace, a loop that will automatically order the squadmate to revive the player should he "die"(also hardcoded) : Well now, if you've made it this far then you must be really interested, here's the whole script (+ GitHub mirror) : Enjoy! I truly can't wait to see what you make with this, please send me a link or pm
  8. Hello everyone! It's been some time since I've done a code snippet, I've been busy with other projects and life stuff. But I'm here today and I have something really cool things to show off (in my opinion). This code snippet will be a little more intense than my other ones, which were mostly just fun little arma things or short tutorials. So without further delay, here I go: Well, you did read the title correctly. One of my favorite things to do with code is loops. They're a bitch, but I love them. Today I've got 2 really neat functions, one is for converting a decimal number to ANY base (binary (base2), ternary(base3), base 10 (decimal, not sure why you'd convert from decimal to decimal though), hexadecimal, octodecimal) and the other is to convert that data back into decimal. I don't personally have a use for them, I was just having a little fun with the engine (somehow I've turned this game into a glorified calculator). It all started with my other little script that I wanted to show off. I played the DayZ mod for a great long time (a really long time), I played it for about a year before I even noticed that there was still another entire game that I hadn't played. Anyway, Rocket had vehicles in there that you had to fix up, and actions were shown in different colors depending on how damaged they were. Well guess who was able to reproduce this? That's right, see my video just below this. Now, I do realize that this isn't quite the same setup Rocket had, but I think it's a really good starting point. For some reason, however, I had to code in some error handling because some hitpoints were not showing up properly, despite being ripped off directly from the configfile, how strange! You can see that when I look at the hatchback and the light blue "NOT FOUND", I had to do that because otherwise it messed up my structured text and was just all around not very pretty. Alright, so in both of these scripts there are a few problems. For the Vehicle Diagnostic Tool I already talked about that, something's wrong with scraping the config info. Now in the encode/decode script, I'm not sure how many people know about Arma's rounding issues, but it's pretty bad. I've complained enough about it for one lifetime, though, so I won't say anything more. While writing those 2 functions, I was trying to get around the rounding so there ended up being a lot of strings and things dealing with them, the problem is there's always a failure point though. To make a long story short I'll get to the point, there is a maximum amount of characters that can be input before BOTH the encoder and decoder become unreliable. To circumvent this, I recommend splitting up larger numbers and saving them separately, you can then decode them with no problem and just stick 'em back together, like reattaching a loaf of bread that's been cut in half. Well, I guess I'll be off now. Keep up the good work, and please, don't forget to have fun along the way. Download: Vehicle Diagnostic Tool | BaseAnyEncoderDecoder (both are dropbox links)
  9. Hello all, I didn't think I'd be writing another code snippet so soon! I just finished writing an extremely simple loot system for single player so I thought I'd show it off. Below is a video I just recorded, and below that will be the code. I will be privately improving this and re-writing some of the core code to be used in multiplayer missions. Enjoy! _distanceToSpawn = [_this, 0, 300, [0]] call BIS_fnc_param; _sleepTimer = [_this, 1, 10, [0]] call BIS_fnc_param; while {true} do { _positionArray = []; _buildingArray = nearestObjects [player, ["house"], _distanceToSpawn]; { _positionArray pushBack ([_x] call BIS_fnc_buildingPositions); }forEach _buildingArray; { _element = _forEachIndex; { if (({(typeOf _x) == "Sign_Arrow_Blue_F"} count (nearestObjects[player,["Sign_Arrow_Blue_F"], 1])) == 0) then { _newMarker = createMarker [format ["%1_%2", _element, _forEachIndex], _x]; _newMarker setMarkerShape "ICON"; _newMarker setMarkerType "mil_dot"; _loot = createVehicle ["Sign_Arrow_Blue_F", _x, [], 0, "CAN_COLLIDE"]; [_newMarker, _loot, _distanceToSpawn] spawn { waitUntil {player distance (_this select 1) > (_this select 2)}; deleteVehicle (_this select 1); deleteMarker (_this select 0); }; }; }forEach _x; }forEach _positionArray; sleep _sleepTimer; }; //Framework by DreadedEntity //I'll have to ask anybody that uses this code, or any parts of this code, to not delete these comments And, lastly, as always, I'll always do my best to answer any questions people might have.
  10. I know that title is rather cryptic, but bear with me. If this works like I think it will, it will be awesome. First go into the editor, pick any map, put a player down, and save it with any name. Now download this script (Dropbox) and place it in your mission folder. Rename it all you want and then execVM it from your player's init line. (or even just rename it to init and let the game run it for you) Enjoy! For fun screenshot the hint and post it! (you can blot out your name of course, oops spoilers!)
  11. Hello all, I got bored and decided that it would be fun to see if I can make a person jump. You can! my init.sqf player addAction ["Jump (for loop)", { for "_i" from 0 to 12 do { player setPos [getPos player select 0, getPos player select 1, (_i / 12)]; sleep 0.02; }; }]; player addAction ["Jump (setVelocity)", { _vel = velocity player; _dir = direction player; _speed = 1; player setVelocity [ (_vel select 0) + (sin _dir * _speed), (_vel select 1) + (cos _dir * _speed), (_vel select 2) + 5 ]; }]; [] spawn { while {true} do { _position = getPos player; if (_position select 2 < getPos player select 2) then { hintSilent format["%1", getPos player select 2]; }; }; }; I don't know how to bind code to keypresses so this is where I leave you. Have fun!
  12. Hello all, While working on another script I plan to release soon (debug is taking an extremely long time because of this issue), I have found out that accuracy is nearly impossible to achieve because of the way numbers are handled either in the game, in the engine, or within my operating system itself. Basically, the issue is that somewhere in the pipes, all numbers are rounded to 6 significant figures. I was in the middle of writing a huge essay explaining the situation but I deleted it because I realized a chart would be faster to understand/explain and you guys wouldn't want to commit suicide from boredom while reading it. Besides, most of you should know what significant figures are from school anyway. So here's the chart: 12983.5m 1928.93m 495.293m 93.0293m 5.20039m 0.102938m This basically sums up the issue in 6 numbers, versus the (almost) 3 paragraphs I had written up (and we are all about optimization here). So as you can see, larger numbers lose significant portions of their accuracy, because if you do getPos (or literally any of the other position-returning commands in the game at the moment) they all output the same way. And if you think this only applies to positions, you're wrong: myNumber = 57.293847 + 2.394807209; //Those numbers should equal 59.688654209, I did the math on paper and with a calculator. hint str myNumber; //Game shows myNumber equals 59.6887. Try it! I have made an issue in the feedback tracker regarding this, extra information is also available, if you think this is important CLICK HERE AND VOTE UP. Why is this important? It's probably not to most people, but it's pretty important to me so I wrote this little function that's able to keep all that "extraneous" information. DREAD_fnc_getAccuratePos = { /* USAGE: _output = [P1] call DREAD_fnc_getAccuratePos; P1: OBJECT - The object you want a more accurate position for. RETURNS: POSITION ARRAY (3 ELEMENTS) - [[X position rounded to nearest whole integer, variation], [Y position rounded to nearest whole integer, variation], [Z position rounded to nearest whole integer, variation]] EXAMPLE: _accuratePosition = [player] call DREAD_fnc_getAccuratePos; RETURNS: [[14630,0.833008],[16172,0.761719],[0,0.00143814]] ADD EACH SUB-ARRAY TOGETHER: [14630.833008, 16172.761719, 0.00143814] */ private ["_object","_output","_objPos1","_objPos2"]; _object = (_this select 0); _object enableSimulation false; _output = []; _objPos1 = getPos _object; _object setPos [(_objPos1 select 0)-(floor(getPos _object select 0)), (_objPos1 select 1)-(floor(getPos _object select 1)), (_objPos1 select 2)-(floor(getPos _object select 2))]; _objPos2 = getPos _object; { _output pushBack [floor (_objPos1 select _forEachIndex), _objPos2 select _forEachIndex]; }forEach [0, 1, 2]; _object setPos [((_output select 0) select 0) + ((_output select 0) select 1), ((_output select 1) select 0) + ((_output select 1) select 1), ((_output select 2) select 0) + ((_output select 2) select 1)]; _object enableSimulation true; _output }; Using this function can return numbers (with a little work) that have up to a maximum of 11 significant figures! Currently set up only for object positions, but could probably be easily modified to input/return pure numbers using the same theory. This theory is using the "significant figures rounding effect" (as I have dubbed it) against itself, by saving an object's position, rounding down the X, Y, and Z positions to the nearest whole number and subtracting the object's current X, Y, and Z positions by the rounded numbers. Thus you have numbers like 0.0023938 and 0.392829 which since they are at 0, which allows them to utilize the maximum number of significant figures available. You then simply save both the rounded-down number, and the "variation". I hope this helps...somebody. It helped me EDIT: Added some colors to the chart in case anybody doesn't get it.
  13. Hello all, I got bored again tonight and decided to mess around with Event Handlers. Turns out making a gun that shoots strider's is easy! I wish my video didn't come out at 360p for some reason and is blurry as hell. add to your init.sqf player addEventHandler ["Fired", { _bullet = _this select 6; _dir = _this select 0; _velocity = velocity _bullet; [_bullet, _velocity, _dir] spawn { sleep 0.02; _newPos = getPos (_this select 0); deleteVehicle (_this select 0); _newBullet = createVehicle ["I_MRAP_03_F", _newPos, [], 0, "NONE"]; //_newBullet setDir (_this select 2); //breaks setVelocity for some reason. do not uncomment. _newBullet setVelocity (_this select 1); }; }];
  14. Hey Das I think that would make an excellent code snippet, just saying ;) (I WANT THAT CODE)
  15. dreadedentity

    Timer Script Question

    _seconds = 0; _secondsTemp = 0; _minutes = 0; _hours = 0; while {true} do { _timer = [] spawn { uiSleep 1; //uiSleep uses system time rather than in-game timekeeping (which is tied to framerate) and is therefore more accurate }; _seconds = _seconds + 1; _hours = floor (_seconds / 3600); _minutes = floor((_seconds - (_hours * 3600)) / 60); _secondsTemp = floor (_seconds - (_hours * 3600) - (_minutes * 60)); if (_hours < 10) then { _hours = "0" + (str _hours); }; if (_minutes < 10) then { _minutes = "0" + (str _minutes); }; if (_secondsTemp < 10) then { _secondsTemp = "0" + (str _secondsTemp); }; waitUntil {scriptDone _timer}; //all math should be done before before the script has finished, //this prevents the CPU from simply sitting idle and then wasting time number crunching when it should be displaying information hint format ["%1:%2:%3", _hours, _minutes, _secondsTemp]; //after script is finished then the proper amount of time has passed, display the info }; That's as efficient in every aspect as I can make this in my current state of inebriation (script size, script speed, cpu time wasted). Also, the total amount of seconds that has passed is preserved so that it can be used elsewhere as an event trigger. With 2 small changes you can modify this from counting up to counting down and make some other cool things. Actually, I think this is so cool that I will post this as a code snippet
  16. dreadedentity

    A3 Cruise Control Script

    JShock and I were talking about this, glad to see it finished. I may post my version in a code snippet later.
  17. dreadedentity

    Spawn empty vehicles using a trigger

    You're right, I was thinking of another function. Just did a quick test in the editor and can confirm createVehicle array works as intended. Somewhere along the way, units are being added to your vehicle. If I'm remembering correctly, if you spawn a vehicle, and then spawn some units in the same position the units will end up inside the vehicle somehow. Maybe I dreamt that, but it's something to watch out for. Also, you can stick this little code snippet somewhere to make sure there are no units in your spawned vehicles. { _vehicle deleteVehicleCrew _x; } forEach _vehicle crew;
×