Jump to content

Search the Community

Showing results for 'code snippet' in topics posted by dreadedentity.

  • 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

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 250 results

  1. dreadedentity

    Help with an action

    Thanks, Iceman. I remember Larrow giving this code to me in a previous topic. I was trying to find a way to add it to the objects themselves without breaking the toggle-ability of them. I just wrote up this small init.sqf, it should be a good starting point for something like this. boxes = []; _playerPos = position player; for "_i" from 0 to 2 do { _position = [((_playerPos select 0) - 5) + (_i * 5), (_playerPos select 1) + 10, 0]; _obj = createVehicle ["Box_NATO_Wps_F", _position, [], 0, "None"]; boxes pushBack [_obj, str _obj]; }; hintSilent format["%1", boxes]; It simply spawns 3 boxes, 10 meters in front of the player, 5 meters apart from each other. Use any map you want, save, then create an init.sqf and drop that code in it. It saves an array of arrays, the first value is the object itself, and the second value is a string of the object's handle (my thinking is that since all of these strings are unique, and addAction handles must be unique this would be a good naming scheme). Going to start messing with the actions now. ---------- Post added at 17:56 ---------- Previous post was at 17:34 ---------- Well, I got it finished, and it was actually a lot easier than I thought. Just put this in your init.sqf. init.sqf boxes = []; actionStatus = false; _playerPos = position player; for "_i" from 0 to 2 do { _position = [((_playerPos select 0) - 5) + (_i * 5), (_playerPos select 1) + 10, 0]; _obj = createVehicle ["Box_NATO_Wps_F", _position, [], 0, "None"]; boxes pushBack [_obj, str _obj]; //Unnecessary _obj addAction ["Pick Up", { if (!actionStatus) then { (_this select 0) attachTo [(_this select 1)]; (_this select 0) setUserActionText [(_this select 2), "Drop"]; }else { detach (_this select 0); (_this select 0) setUserActionText [(_this select 2), "Pick Up"]; }; actionStatus = !actionStatus; },[],1,true,true,"",""]; }; hintSilent format["%1", boxes]; Problem with this is that if you happen to move your mouse over another object, you'll get the option to pick it up, and if you use that action twice you actually will pick it up. But since this is going to be used privately and not in a script I will release, this is where I stop :p EDIT: 2 things I forgot to say. 1. I believe the easiest way by far to do this is to add your action when you create the object so you still have access to the local variable you should be using to refer to the object in your spawning function. An alternative way to do this is to add your created object to a global array with pushBack, then spawn a seperate thread with a while loop that simply waits for the size of the array to change, then adds the action to the last object in the array. 2. Any unit that you want to be able to use the actions needs to have actionStatus declared (not necessarily in init, but before they encounter any situation where the action is available to them). If you use the exact code from above, actionStatus needs to be declared as a boolean.
  2. dreadedentity

    Power outage

    @Kushluk Are those the classnames for the lights in that array? _objectArray = ["Lamps_Base_F", "PowerLines_base_F", "Land_PowerPoleWooden_F", "Land_LampHarbour_F", "Land_LampShabby_F", "Land_PowerPoleWooden_L_F", "Land_PowerPoleWooden_small_F", "Land_LampDecor_F", "Land_LampHalogen_F", "Land_LampSolar_F", "Land_LampStreet_small_F", "Land_LampStreet_F", "Land_LampAirport_F", "Land_PowerPoleWooden_L_F"]; _allLights = []; { _y = typeOf _x _z = _x { if (_x == configName(configFile >> "CfgVehicles" >> _y) then //maybe????? I couldn't find lamps in the config viewer. { //_allLights set [count _allLights, _z]; //derpy mistake. originally had set to _x instead of _y. double derpy mistake. created new variable so I could return the object. _allLights pushBack _z; //very very last edit exitWith{}; //end the loop early so you can't add object to array twice. not sure if any object can fall under 2 classnames. //if it's not possible then this is, and always was, for performance. }; }forEach _objectArray; }forEach (allMisionObjects ""); This code is supposed to return all lights in the mission. Not sure if it will work. Also I found a few interesting things while searching for the answer to this (make sure you read notes too) switchLight, setHit, and of course, you can always just setDamage if these commands don't work. EDIT: edited with code that might actually work. EDIT2: bunch of edits to the code, now it might really work. EDIT3: added pushBack command instead of "array set []", again performance-related
  3. dreadedentity

    Individual AI hold fire command

    Maybe a possible solution to this is _waypointArray = waypoints yourGroup; { _position = waypointPosition _x; yourGroup addWaypoint [_position, _forEachIndex + 1]; }forEach _waypointArray; Run that on each unit after you join them back to their group Thinking outside the box here: What if you teleported the unit to [0, 0, 99999] something insanely far away, maybe that would also wipe out the knowsAbout value? Here's a quick mission I whipped up to test that "outside the box thinking" (Dropbox) I tried sending the unit far underground (z: -999999), but he never came back. Used a hint to confirm code was running. It seems he was killed while underground, despite the time underground was only 1 line of code (next line was to teleport him back to his original position). I tried sending him to [0,0,0] but I guess that's in water, and when I teleported him back he had to take his gun off his shoulder giving the enemy an unfair advantage. Next I sent him to [4000,5000,0] which is on land, but you don't even notice him be teleported away. In fact, there isn't even a noticeable lapse in gunfire from either party. I added a 2 second delay before teleporting him back (which is what you'll see in that download), but it seems you need a longer interval or some other method to make him forget about his target. Perhaps deleting the other unit and spawning a new one with the same loadout/waypoints? I think the best way to do this would to be removing the unit from the group, adding him back, then using the code I posted above to add all the waypoints back to him (if any).
  4. dreadedentity

    Name Spawned Soldiers

    After your code runs, try something like this: { missionNamespace setVariable[format["mygroupstart%1", (_forEachIndex + 1)], _x]; }forEach (units _mygroup); using missionNamespace setVariable is a way to inject variables directly into the mission namespace (not sure how to explain this, pretty much everything that happens happens in the mission namespace) (probably) and to create dynamically named variables. It is a faster/better alternative to using call compile format which can achieve the same results. (definitely) what this code does is... (pseudocode) for each of the units in _mygroup, a new variable is created named "mygroupstart" + number the of the current index plus 1, because you place an object inside the variable becomes an object variable and you can run code using their handles. (probably) Here is a visualization (that hopefully comes out formatted correctly) variables = "mygroupstart1", "mygroupstart2","mygroupstart3","mygroupstart4" /|\ /|\ /|\ /|\ | | | | | | | | _mygroup = [man1, man2, man3, man4] (probably) hope that helps (hope it's right, too. I'm a little drunk.) EDIT: I got the names wrong when I read the post earlier! alphabet = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]; { missionNamespace setVariable[format["opf_team_1%1", (alphabet select _forEachIndex)], _x]; }forEach (units _mygroup); variables = "opf_team_1a", "opf_team_1b","opf_team_1c","opf_team_1d" /|\ /|\ /|\ /|\ | | | | | | | | ofp_team_1 = [man1, man2, man3, man4] Now this will have the effect you want.
  5. dreadedentity

    Hunger/Thirst System (Done but with issues)

    You can pretty much use the code Larrow posted to completely finish your hunger/thirst system (with his permission). I made a few tiny edits thirst = 100; hunger = 100; inv_food = 0; inv_drinks = 0; cash = 100; foodPrice = 5; drinkPrice = 5; player addAction ["Buy Food", { if (cash >= foodPrice) then { cash = cash - foodPrice; inv_food = inv_food + 1; systemChat "You bought some food"; }else { systemChat "You don't have enough money to buy food, you jerk!"; }; }, [], 1, false, true, "", "cash >= 20"]; player addAction ["Buy Drink", { if (cash >= drinkPrice) then { cash = cash - drinkPrice; inv_drinks = inv_drinks + 1; systemChat "You bought a drink"; }else { systemChat "You don't have enough money to buy a drink, you jerk!"; }; }, [], 1, false, true, "", "cash >= 10"]; player addAction ["Eat", { if (inv_food > 0) then { inv_food = inv_food - 1; hunger = hunger + 5; systemChat "You feel less hungry"; }else { systemChat "You don't have any food to eat, you noob!"; } }, [], 1, false, true, "", "inv_food > 0"]; player addAction ["Drink", { if (inv_drinks > 0) then { inv_drinks = inv_drinks - 1; thirst = thirst + 5; systemChat "You feel less thirsty"; }else { systemChat "You don't have anything to drink, you noob!"; }; }, [], 1, false, true, "", "inv_drinks > 0"]; //spawns a new thread to take care of hunger/thirst simulation _simThread = [] spawn { while {true} do { sleep 10; //every 10 seconds, lose 5 hunger and thirst thirst = thirst - 5; hunger = hunger - 5; //added code to make sure hunger/thirst can't fall below 0 if (thirst < 0) then { thirst = 0; }; if (hunger < 0) then { hunger = 0; }; if (thirst <= 10) then { systemChat "You need to drink something before you die of dehydration"; }; if (hunger <= 10) then { systemChat "You need to eat something before you die of starvation"; }; if (cash <= 0 && {isNil "outOfCash"}) then { systemChat "You have spent all your money"; outOfCash = true; }; /* if ( { _x <= 0 }count [hunger, thirst] > 0) then { [ "END1", false, 5] call BIS_fnc_endMission; }; */ //replaced Larrow's mission end system with a system that damages the player 5% health every cycle //(supposedly)(untested) It is now possible to starve to death in your mission. //players can still use a First Aid Kit to get (almost) full health to prolong the time until they die //You could do something with (health = damage player) to prevent this kind of cheating, but //I doubt it matters enough to try to fix that. if (hunger <= 0 || thirst <= 0) then { player setDamage ((damage player) - 0.05); }; }; }; _monitorStats = [] spawn { while {true} do { hintSilent format["Thirst\n%1\nHunger\n%2\n\nDrink\n%3\nFood\n%4\n\nCash\n%5", thirst, hunger, inv_drinks, inv_food, cash]; sleep 1; //there is a small break in this loop to reduce the cost of this thread on the CPU. Also, the player doesn't need 100% accuracy anyway. }; }; EDIT: After looking at the actions once again, I noticed the extra conditions at the end of each one. They invalidate my "if" statements because you won't even have the action anymore if you don't have enough money, or enough food/drink. Personally, I'd say go with the "if" statements so you don't have to explain to people why their actions aren't showing up anymore. EDIT2: Realized that hunger/thirst can drop infinitely, making recovery almost impossible in certain cases. Created a floor so hunger/thirst can't get lower than 0 (technically they can, but they get nearly instantly reset to 0). Already edited the code to reflect this change. EDIT3: Reformatted everything because Larrow uses spaces instead of tabs (shakes fist) :p
  6. dreadedentity

    trigger condition question

    try this instead: !(captive H1) && {!(captive H2)} && {!(captive H3)} && {!(captive H4)} You don't need to keep "this" in trigger conditions, and that code was trying to set the captive state for those objects to false so even if it did work it would just free all the units. It probably gave you an error because of the semicolon ( ; ), I don't think they can be used in conditions. forEach can return true, if it's in the code. However, setCaptive doesn't return a value so if that code ran you would get an error "Error: Expected Bool" Hope that helps
  7. I have a piece of code uses event handlers to check if a squad has been killed, for performance. However, it seems that I have no idea how to use them. I wrote up a small test script to try to understand more about them, but I'm just not getting it. Can somebody explain to me how to use these please? (btw, if you are going to test that code in a map those coordinates are just above and to the left of the 'a' in 'airfield' on stratis island. unitArray = createGroup west; missionNamespace setVariable ["1", group1 createUnit ["B_Soldier_F", [1690,5575,0], [], 0, "NONE"]] addEventHandler ["killed", hint "you killed the first unit."]; //originally, I had the addEventHandler's underneath the createUnit but they don't work. somehow I merged them with createUnit without getting a script error but they still don't work. //(unitArray select 1) addEventHandler ["killed", {[this] joinSilent grpNull;}]; missionNamespace setVariable ["2", group1 createUnit ["B_Soldier_F", [1690,5575,0], [], 0, "NONE"]] addEventHandler ["killed", {[this] joinSilent grpNull;}]; //(unitArray select 2) addEventHandler ["killed", {[this] joinSilent grpNull;}]; //commented this out because for some reason it throws //"Error zero divisor". When I researched the issue, I saw that the most relevant reason this error is thrown is if you try to access an //array index that doesn't exist. But this one does exist so I have no idea why an error gets thrown here. while {true} do { hintSilent format["%1", units group1]; [(units group1) select 1] joinSilent grpNull; //this works, the units get taken out of my squad correctly. }; The hint is shown as soon as I preview. I assume normal function of hint is supposed to go to all players, however, the unit was not killed so I don't understand why it's run. For the second unit, I assume that code is not run in the local scope of the unit, explaining why "this" doesn't work. I find that unnecessarily complicated and ridiculous.
  8. dreadedentity

    Spawning a group on a marker

    How are you trying to spawn these units? It looks like you want to spawn 2 units at 10 positions. _newGrp = createGroup west; _mkr1Pos = getMarkerPos "mkr1"; _loop = 1 while (_loop < 10) do { _unit = _newGrp createUnit ["B_Soldier_F", _mkr1Pos, ["mk1", "mkr2", "mkr3], 0, "NONE"]; _loop = _loop + 1; // ^ He forgot a quote here so that's why this didn't work. }; Use Baconator's code and modify it to do what you want. This is what I came up with. _newGrp = createGroup west; //create a new group of BLUFOR soldiers _markerArray = [getMarkerpos "spwnpos1", getMarkerpos "spwnpos2", getMarkerpos "spwnpos3", getMarkerpos "spwnpos4", getMarkerpos "spwnpos5", getMarkerpos "spwnpos6", getMarkerpos "spwnpos7", getMarkerpos "spwnpos8", getMarkerpos "spwnpos9", getMarkerpos "spwnpos10"]; //setting up an [url="https://community.bistudio.com/wiki/Array"]Array[/url] with the positions of all your spawners. { { _unit = _newGrp createUnit ["B_Soldier_F", _markerArray select _x, [], 0, "NONE"]; //nested loop makes a blufor soldier named _unit, part of _newGrp, and cycles through all 10 spawn locations } forEach [1, 2]; //made a trash array with no name, just to spawn 2 units } forEach _markerArray; //lastly, _x is a local variable that forEach uses for it's index, that's why we don't have to define it but can use it. The spawn code I posted earlier using _x was just bad practice, don't do that. This code will cycle through each spawn location, one by one, spawning 2 units. If you switch around "_markerArray" and "[1, 2]" it will create 1 unit at all the locations, but go through it twice. That could be useful if you're trying to get the units spread out quickly. Good Luck
  9. To be honest with you, I see a very distinct line between players, scripters, and modders. There is an overall "arma community", but I think the bond is very weak. Even between scripters and modders there is intermingling. I don't even play the game anymore, yet I have almost 3000 hours logged on steam. The point I'm trying to make is that I see the players as a completely separate entity than us, and I believe they view us the same. Every time I tried to join a server, all I hear is how badly the scripts are written/half of the mission doesn't work/"this mission sucks". Personally, I'm all about the scripting community, part of the reason I post code snippets and spend so much time on this forum anyway No! We are sincerely waiting for your releases! I want to see what you'll make. I come here to answer questions or fix people's problems, I like being able to occasionally see a release post and be able to say "Hey, I helped him with [obscure problem only hours of wiki-reading and code tests could solve]". You may not have done anything public yet, but I can't wait to see what you do
  10. I disagree with people saying this. There is such a thing as Clean Room Design There actually is a book (eBook), and here is the exact page you need to flip to to find this information. 90% of everything I know actually comes from that book, and if I really scrutinize I can bring that percentage as far down as 85%. Wiki edits are the (absolute) best way to share what you know. I have only opened someone else's script(s) with the purpose of finding out how they did something one time (BIS_fnc_camera). And I'm very proud of this too. The fun for me is writing all my own code and ending with the same or better result. You could almost say I live for it. Everything I have ever done has been clean room design. So where we stand right now in this thread is that me and Das are the only ones who actually answered the question (in the entire 5 page thread) and helped OP, while the rest of the community devolved 200 years and had a civil war over whether or not you should. Then we explored a bunch of worst-case scenarios (lots of fun). I will admit that I may have fanned the flames a little, though that was not my intention. But it's actually kind of ridiculous that in 5 pages of text, there are only 2 pieces of semi-relevant code. I don't even know why the mods are letting this forum ravaging happen. Are they sleeping? It should probably get locked now (or about 24 hours ago) while every has only a slightly bad taste in their mouths. Guys, I mean I can practically taste the salt in the air. Anyway, I guess I'm trying to say that information relevant to OP's vague question has ended hours ago, just like this thread probably should have. pls lock. pls
  11. I'm going to have to disagree with this statement Shock. Piracy is a huge problem in this entire industry, actually. People are arguing both sides here, but when you say it's okay to steal someone's content because arma is "just a game", does this make it not piracy? Where is the difference in people pirating a game or a script for arma? Both are code, yes? Somebody (or people) have put effort into it, right? Is it also okay to pirate full games? Maybe just pirate Arma itself (irony) then you can pirate usermade code? I'm failing to see the disparity here, and I don't believe there is any. Just imagine how you would feel after spending up to a week (or more) making an amazing sandwich, I mean it's the best sandwich that has ever been created or ever will be. You're so proud of it, so you go outside and start showing your sandwich off to passersby (use it in a mission). Then someone comes along and tells you, "wow, that is a reallllly cool sandwhich". Then they slap it out of your hand, watch it fall to the ground, and look you right in the eyes. Then they just walk away. Be smart, people. Piracy is wrong. You wouldn't download a car. this
  12. Hello everyone, I am in the last stages of development on a new system I'm working on (rewrite of ACS) and I am looking for some testers of the system in it's current state. Some changes: Dialog-based editor (ACSCE): First of all, the editor itself. This did not exist in ACS1 Save/load your conversations to/from profile namespace, allowing you to work on a conversation in one map, change maps, and continue Rearrange conversation topics at will Edit to your hearts content Able to import from clipboard in case you deleted the conversation from the editor, but still have it saved in a script. Able to export to clipboard for use in your missions ACS: A real, branching conversation system, unlike the ACS workaround Works with stringtables or regular strings Dialog modeled after TESV:Skyrim, ACS1 was modeled after TES4:Morro. May add support for both/more dialog styles. Sound-playing is currently identical to ACS1, working out some kinks in it Now have the ability to say some things to the NPC (optional), and then hear it's response Topics can have an optional "condition" that must be met before showing up to the player Topics can now redirect to another part of the conversation by setting an optional "path" Conversation initiator and reciever now move their lips while sounds are playing (random lip movement, prob won't match to sound, currently looking into a better option) Some (very) basic RPG commands, like forcing a unit to run to the player and initiate conversation (may be expanded) Player speech and NPC responses can be split into different "lines", every topic can contain an unlimited amount of lines All user scripts are now spawned, all code will always be in a scheduled environment I'm only looking for like 5 testers guys (enough to fill a group convo in the forum messaging system). Please respond to this post if you would like to be one of the first to use this system and help it's development by telling me about bugs and suggested features. Please PM me if you would like to participate on the low. I am not asking you to do any debugging or script-work, simply reporting issues. Although I guess you can look at the code it you want. Please express your interest within an hour of me posting this message so I can send you a download link and setup instructions quickly. If you do not see this message within an hour but still want to participate, don't be discouraged, I will send you that information in a few hours once I get back from work. If I think of anything else that I want to add, I will silently edit this post. Thank you all for your help!
  13. I wrote a little function for you, unfortunately I don't have a server to test it on at the moment. I have no idea if it will work but it's been a while since I've tried anything crazy. testVar = { /* Params: P1: Array of objects - Should only be player units To easily get an array of all players use: _allPlayers = []; { if (isPlayer _x) then { _allPlayers pushBack _x }; }forEach allUnits; P2: Namespace - The namespace that you want to retreive a variable from P3: String - The name of the variable you want to retreive Example Call: [[_array,_of,_players], missionNamespace, "test"] call testVar; */ [ [[(_this select 1),(_this select 2)],{ _varResult = (_this select 0) getVariable [(_this select 1), "NULL"]; [[[_namespace, _variable, _varResult],{hintSilent format ["Variable Retrieved!\nNamespace: %1\nVarible: %2\nResult: %3",(_this select 0),(_this select 1),(_this select 2)]}], "BIS_fnc_call", 0, true] call BIS_fnc_MP; }], "BIS_fnc_call", owner ((_this select 0) call BIS_fnc_selectRandom), true ] call BIS_fnc_MP; }; It's (supposed) to work by picking out a random player from a list of players you provide, use BIS_fnc_MP to drop a code bomb on that player, he checks the variable, and sends a BIS_fnc_MP packet back to the server with the result. By the way, if the variable doesn't exist, it will show "NULL" (provided that this code works at all). By the way, this is not a recommended way to use BIS_fnc_MP.
  14. dreadedentity

    Dialog - Returning Mouse Drag?

    I'm not sure if it's possible to rotate the character using setDirAndUp in your dialog but if you can, this is the code you'd want to use. Add this to your picture box control definition: onMouseDown = "isMouseDown == true"; onMouseUp = "isMouseDown == false"; onMouseMoving = "[myObject, _this select 1, _this select 2] call rotate"; rotate function: rotate = { if (isMouseDown) then { _objectDir = _objectDir - (_this select 1); (_this select 0) setDir _objectDir; _objectPitch = (_objectPitch - (_this select 2)) max -90 min +90; [ (_this select 0), _objectPitch, 0 ] call bis_fnc_setpitchbank; objectDirPitchBank = [ _objectDir, _objectPitch, _objectBank ]; }; }; Note that it is not possible to set bank with this function, I haven't figured out the code to make that work yet, nor do I see any use for it in what you need it for. Also, make sure you define 2 global variables, "isMouseDown" and "objectDirPitchBank", with default values of false and [0,0,0], respectively. "myObject" should also be a global variable and refers to the actual man object you are rotating around.
  15. dreadedentity

    kill death ratio calculator

    I rewrote your code so it's about 2x easier to read, but still contained in 16 lines: _get = call compile _get; _clientID = owner _unit; _get = (_get select 0) select 0; player_stats_add = [ parseNumber (_get select 0), //xp parseNumber (_get select 1), //kills parseNumber (_get select 2) //deaths ]; _clientID publicVariableClient "player_stats_add"; player_stats_got = 1; _clientID publicVariableClient "player_stats_got"; Anyway, I don't think this is the right place to add a kill/death calculation. It would be much better off making the receiving client do it, in which case you would add it to the Public Variable Event Handler "player_stats_add" addPublicVariableEventHandler { _variableName = /*_this select 1;*/ EDIT: _this select 0; _incomingData = _this select 1; //other code systemChat format ["Kills/Deaths ratio:\n%1",(_incomingData select 1)/(_incomingData select 2)]; }; Also, really?
  16. dreadedentity

    _x is undefined in a forEach loop?

    These functions work fine for me... [west, position player, 0] call AUSMD_spawn_group; [east, position player, 0] call AUSMD_spawn_group; //both working As MDCC said, the problem is with the _units array. Somewhere in your code you've probably put a string for the "side" parameter. Or you've misspelled something causing the interpreter to look for an undefined variable. Check your code for "weast" ;) I know I've typed that plenty of times by accident.
  17. Hello, That script is mega-nasty. I want to pour gasoline on my computer and watch it go up in flames after reading that. The allUnits command returned array can get huge if you have a mission with many, many ai. Trying to loop this onEachFrame is not an ideal solution by a longshot. A better name for this script would be "fps_massacre.sqf". I would just like to change 1 line from his original description: "This script will move ANY ai (ie: zeus-spawned, etc) to the headless client, while raping your frames-per-second" There are a few simple solutions, however. I don't know how you are spawning units, whether they be from a Zeus player or through scripts, but it's not an issue because there is a solution for both. For our Zeus units, we will be using 2 Curator-only event handlers, CuratorGroupPlaced and CuratorObjectPlaced. Copy this into the INIT box for the curator, or you can put this into a script and run it if you know how. this addEventHandler ["CuratorGroupPlaced", { _HC = owner "HC"; _check = (_this select 1) setGroupOwner _HC; if (_check) then { systemChat "Group was successfully transferred to Headless Client."; } else { systemChat "Group was not transferred to Headless Client."; }; }]; this addEventHandler ["CuratorObjectPlaced", { _HC = owner "HC"; _check = (group (_this select 1)) setGroupOwner _HC; if (_check) then { systemChat "Object was successfully transferred to Headless Client."; } else { systemChat "Object was not transferred to Headless Client."; }; }]; Now for units that are spawned through script, make sure you add this code to initServer.sqf: transfer_group_to_headless = { _HC = owner "HC"; _check = _this setGroupOwner _HC; if (_check) then { systemChat "Group was successfully transferred to Headless Client."; } else { systemChat "Group was not transferred to Headless Client."; }; }; And every time your script spawns units make sure you run this code right after the units are spawned: _myGroup call transfer_group_to_headless; So basically that should all work or something, I have no idea.
  18. Do note that the damage that is returned using (_this select 2) is the total damage of the unit after calculating damage from the hit. Using this code will result in an exponential damage increase, not a base damage increase. To do this properly, you must first isolate the damage that the hit caused, then multiply that, then set the damage to the unit. I may have been thinking of the "HandleDamage" event handler instead. this addEventHandler ["HandleDamage", { _unit = _this select 0; _totalDamage = _this select 2; _curHealth = damage _unit; _shotDamage = _totalDamage - _curHealth; //Isolate the damage that the shot caused (_curHealth + (_shotDamage * DAMAGE_MULTIPLIER)); //Return the modified damage to the engine because the engine will take care of adding the damage to the unit }]; In this code, I have set a global variable called DAMAGE_MULTIPLIER which you can set in init.sqf (or wherever you want). Alternatively, you can just replace that with a number. Also, this. lol. like...how can we help you if you don't give any details about it "not working".
  19. dreadedentity

    addAction for tent/sleeping bag

    Here's a little piece of code for something I was working on a few months ago, I never did finish it though. This code makes it so that if you sit down (I don't really remember which button does that), you will have an option to "Wait 2 hours". It's extremely simple, but this could probably help you get along faster: player addAction ["Wait 2 Hours", { _date = date; _date set [3, (_date select 3) + 2]; setDate _date; }, [], 0, false, true, "", "(animationState player) == 'amovpsitmstpsnonwnondnon_ground'"];
  20. Sure, basically your base will be a simple assignment: var = var + [newValue]; //it's slower, but you will NEVER overwrite an element using this or pushBack You'll just store your items like the game does, as strings. Here's an example for picking up an axe: this addAction ["Pick up hatchet", { playerInventory = playerInventory + ["hatchet"]; //To add an element to an array, you must add 2 or more ARRAYS so that's why you enclose your item in square brackets //You could also use: playerInventory pushBack "hatchet" but it's less clear what its function is. hint "You have picked up a hatchet"; //notify the player that something has happened - always helpful deleteVehicle (_this select 0); //remove hatchet from world space if (debug) then {hint str playerInventory}; //support for some kind of "debug" mode - also proof that the code worked }, [], 6, false, true]; Now you can use your virtual inventory in other code using: if ("myItem" in playerInventory) then { //do something }; Now, the biggest and most helpful advice for things like this is the same as simple coding - BE CONSISTENT. I mean, if you decide that all of your item names should start with a capital letter, than capitalize all the items. If you think that the entire word should be capitalized then do it for each one. Consistency can really cut down on debug time (wasted time) in a large or complex project.
  21. Thanks for your help Sw4l, I did see that memorypointgetincargo config entry, but the problem is that it's only a single entry and not an array. Here is a screenshot of the vehicle I'm testing: Here, I've placed little helper spheres to show me where each of the exit points are using this code: { _pos = car1 selectionPosition ("pos " + _x); _obj = createVehicle ["Sign_Sphere25cm_F", [0,0,0], [], 0, "CAN_COLLIDE"]; _obj attachTo [car1, _pos]; }forEach ["driver","codriver","cargo"]; I know that this will only spawn 3 spheres, but there is no error-handling in this code, if an array of position arrays were passed to it it would fail with an error. There should be 2 more exit points on the right side. If you choose "ride in back" and then you get out, you'll be properly dumped out on the right side, so I'm just wondering where that point is defined in the config and how I can access it. That's not even mentioning how "pos codriver" doesn't exist.
  22. Hello, display event handlers must be added to the currently active display. You can do this by setting the idd of your display within the config or description.ext. In this particular case, you would want to set your dialog's idd to 199. If there is no display open, the main game screen uses Display #46. displayAddEventHandler only waits until it's conditions are met, then the code you supply gets run. Think about a normal event handler, what does the "killed" event handler do? The game waits until the unit it is attached to dies, then the code runs. They are exactly the same, the only difference is the condition that must be met before they are fired. The "KeyDown" event handler simply waits until a key is pressed down, an element in it's return array will tell you which key it was, and then you can do fun stuff like preventing players from reloading Dialogs are the same as displays, I believe the only difference is that they cannot be interacted with by the user in any way (only through script). But I'm not too sure about that, I have made plenty of dialogs, but not a single display. These were good questions, I feel that the documentation regarding the background implementation of dialogs has a lot of holes, and in some places, is far too technical.
  23. dreadedentity

    Grid Refrence to World Position

    The problem with using this command is that you need to know the mystical "map control" the game uses' date=' which nobody that has found it has shared such information on the internet ---------- Post added at 14:53 ---------- Previous post was at 14:33 ---------- The problem with this is that I've found each map seems to have a different X/Y offset concerning their grid. Why this is, I have no idea. Copy this code and run it in the debug console on all 3 maps: [] spawn { _brushes = ["Solid","Horizontal","Vertical","Grid","FDiagonal","BDiagonal","DiagGrid"]; for "_i" from 0 to 81 do { for "_o" from 0 to 81 do { //if (!surfaceIsWater [(_o * 100) + 50, (_i * 100)]) then //{ _marker = createMarker [format["%1_%2",_o,_i], [(_o * 100), (_i * 100),0]]; _marker setMarkerText (format ["%1_%2 \ %3",_o,_i, getMarkerPos _marker]); _marker setMarkerShape "RECTANGLE"; //_marker setMarkerType "MIL_DOT"; _marker setMarkerSize [50,50]; _marker setMarkerBrush (_brushes select (floor random (count _brushes))); _marker setMarkerColor "ColorRed"; //}; }; }; }; This code puts a map marker on on some 100x100m squares. You should see that they do not align correctly with the grids. I've found 2 of the offsets (Altis & VR). Altis: x + 50, y + 50 VR: x + 0, y + 2 I haven't messed with Stratis. Again, I have no idea why they did this. If you ask me, the map should start at (0,0), along with the grids. I'm having trouble understanding what you mean, you do know that in Arma3 vanilla you can only have map coords of up to 6 figures, right? (XXXYYY)
  24. Advanced Conversation System By: DreadedEntity Release for Arma 3 Stable in: 1.34.128075 (and probably on) Version: 1.0 Hello everyone, ACS is finally ready, well, it's actually been ready since before Thanksgiving, but I wanted to make a demo mission to show off how to use it. ACS is a powerful, simple-to-use system that aims to provide full conversations with Arma's AI. It can run scripts and code, and even play sound. Features: Ability to talk to AI Branching conversation/tree system Ability to run code or scripts with data passed to them Create dynamic conversations with built-in add/remove topic functions Play sounds to go along with your conversations Virtually unlimited topics/conversations System keeps track of conversation topics that have already been talked about Conversations made entirely by you Implementation: To use the built-in functions #include ACS_userFunctions.sqf to a place clients will run it, such as init.sqf #include "ACS\ACS_userFunctions.sqf" To use the dialog system (this is required), #include the files from the ACS\resources folder to your description.ext #include "ACS\resources\definitions.hpp" #include "ACS\resources\ACS_dialog.hpp" That's it! Here's a video of the system in-action: (Download the example mission here, contains ACS (obviously)) Download (dropbox) <---ACS only I'm going to write up a short .pdf tutorial highlighting specific use of this system. It will cover everything, and include tricks that I have found during development. When completed, I will replace these sentences with a dropbox link This system is being released under the Arma Public License Share Alike (APL-SA). Please observe and follow this license. In addition to APL-SA the author reserves the right to have his work, or any derivatives of, removed from any works in which he does not want to be associated with.
  25. Code blocks are a separate environment, so if you rely on variables, they absolutely must be passed to it. Try this: Also, using BIS_fnc_param should be able to help condense your code, I have provided an example.
×