Jump to content

dreadedentity

Member
  • Content Count

    1224
  • Joined

  • Last visited

  • Medals

Everything posted by dreadedentity

  1. 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
  2. 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).
  3. 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.
  4. ^Keep this in mind when I give you this code. I think the best way to do this would be using a Public Variable Event Handler since both setRain and setOvercast are local commands. rainBool = false; "rainBool" addPublicVariableEventHandler { [] spawn { //spawn a new thread to make sure sleep commands are executed even if a non-scheduled evironment _rainBool = _this select 1; if (_rainBool == true) then { 10 setOvercast 1; //it can only rain if overcast is 0.7 or higher sleep 11; //make 1 second longer to make sure the cloud coverage is enough to allow rain 10 setRain 1; } else //since rainBool is type Boolean, only other option is false { 10 setRain 0; sleep 11; //turns off rain first. I did this to prevent unknown happenings (like rain auto-turning off because no clouds) 10 setOvercast 0; }; }; }; Now, in case you've never used a publicVariableEventHandler before, you will need to publicVariable the variable, which broadcasts it over the network to all players, like this rainBool is currently false (some stuff happens, certain conditions are met, and youve written code that decided it should start raining now) rainBool = true; publicVariable "rainBool"; publicVariable goes to all computers (including server) and their "rainBool" event handler goes into action. Being that rainBool is true, clouds cover the sky and rain begins to fall. When I tried using publicVariable, it didn't work. But I think I explained how it works right.
  5. dreadedentity

    Create waypoint on Trigger

    Don't make it hard on yourself. If your extraction waypoint is going to be the very last one in the mission (you're not going to throw in any surprises like the boat/heli gets blown up and the players need to fight to a new extraction) you can use deleteWaypoint [GROUPNAME, all]; GROUPNAME addWaypoint [POSITION, 0, 1, "Extraction"]; //not sure if "Extraction" will have the effect I think it will, but throw it in there and let me know. deleteWaypoint (read notes too), addWaypoint Actually, you can use this code even if you want to throw in a surprise like the extraction vehicle get's blown up. >>>setWaypointPosition<<<
  6. Try using a global variable, or publicVariable. Kind of opens up security a little bit, though.
  7. 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
  8. I'm pretty bad with multiplayer scripting, but, why not just log in as admin and set your commands on the debug console?
  9. dreadedentity

    Trigger on Timer or event

    waitScript = [] spawn { sleep (60 * 15); //too lazy to open calculator. Note that this is possible. // sleep ^whatever that is equal to; //identical effects }; waitUntil {count alive units ENEMYGROUP == 0 || scriptDone waitScript}; terminate waitScript; Spawn a new thread and add a check to see if it's finished under your conditions ( || means or). Then make sure script is terminated.
  10. Are you saying you can't do sidechat because you don't know how? place a unit in the editor far, far away and give him a name Then use UNITNAME sideChat "YOURTEXTHERE"; Alternatively, you can use systemChat "YOURTEXTHERE" without needing a unit (message shows up in gray) EDIT: Double alternatively, in case you didn't know about the format command (click this) text1 = "Dreaded"; text2 = "Entity"; myText = format["My name is %1%2", text1, text2]; The variable "myText" will be equal to "My name is DreadedEntity" after this code is run.
  11. I'm making a small script that will allow you to spawn units, so I may have had a peek under the hood at Iceman77's vSys. I think I've isolated the lines that I need to understand to make this happen. _cfg = configFile >> "cfgVehicles"; _sidePlayer = getNumber (_cfg >> typeOf player >> "side"); What exactly do these lines do? Also, could someone please explain these commands and how to use them: config >> name, configClasses, configName, configFile, inheritsFrom
  12. dreadedentity

    Help understanding the config file

    I got it working Magirot, thanks for the help though. Now there's just a whole bunch of other obstacles in my way :icon_wink:
  13. dreadedentity

    Help understanding the config file

    One more question, Larrow. You said you can't edit the configFile without making an addon, but is there a .pbo that I can crack open and view like your missionConfigFile example?
  14. dreadedentity

    Help understanding the config file

    Wow, thanks a lot Larrow. Messing around with config files is extremely poorly documented on the BIKI, even dialogs have better documentation than that. I'm actually almost ready to release something, but I can't get a variable passed from one script to another (if that makes sense). Basically, you choose what you want to spawn from a combobox, then click on a button. The button launches a script, reads the selection of the combobox with lbCurSel, then using a passed array in combination with the index spawns something. I've been trying to find out how Iceman did it, but his coding is next-level. EDIT: @JShock, I always hope Larrow comments on my threads, he seems to know everything about everything. I haven't been able to stump him yet!
  15. maybe something like null=[this] execVM "replan.sqf"; in the vehicle init replan.sqf _obj = this select 0; while {true} do { _obj setDestination [yourdestination, "LeaderPlanned", true]; sleep 10; }; I'm not sure if this will stop the vehicle or not, though.
  16. dreadedentity

    Help understanding the config file

    Wow I didn't know about that. I might be able to do what I need now, thanks.
  17. dreadedentity

    Help understanding the config file

    Thanks, JShock. Do you know if there's a page like this for the Arma 3 CfgVehicles? I've looked all over, but can't find it.
  18. Hello all, I'm trying to create a mission kind of like a "Life" server. I want everything to be persistent, however, so database interactions are necessary. But the database will be stored on the server machine so I need a way to broadcast the variables across the network. Fortunately, a solution for this already exists in arma. Unfortunately, I don't understand how it works at all. Basically, when a player joins my game, the server should retrieve his stats, then the server will publicVariableClient to the client that just connected and sync his stats (if they exist). My problem is that I'm getting an undefined variable error in the little script I wrote. Here's what I've got so far: init.sqf "stats" addPublicVariableEventHandler { money = _this select 1; }; if (isDedicated) then { call compile preProcessFile "\inidbi\init.sqf"; //using @iniDB for read/write ["connect", "onPlayerConnected", { missionNamespace setVariable ["stats", ["PLAYERINFO", _uid, "MONEY", "STRING"] call iniDB_read]; _id publicVariableClient "stats"; }] call BIS_fnc_addStackedEventHandler; }; if (!isServer) then { sleep 2; hintSilent format["%1", money]; }; Like I said above, the error I'm getting is "Undefined variable in expression: money". So I guess I'm having trouble getting the variable saved on the client machine. Can anybody help me shed some light on this?
  19. dreadedentity

    Generic error, syntax problem?

    Remember: "A called function may only use suspension (sleep, uiSleep, waitUntil) if it originates in a scheduled environment. If the called function originates in a non-scheduled environment it will return a generic error." Apparently, as long as the higher scope is in a scheduled enviornment, you can "call" a sleep statement and it will work out okay (Using the chart MattAka Horner made for reference). Maybe try: [] spawn { waituntil {!isnull (finddisplay 46)}; (findDisplay 46) displayAddEventHandler ["KeyDown", {_this select 1 call MY_KEYDOWN_FNC;false;}]; }; @JShock displayAddEventHandler can take code for it's second argument. I prefer to use squigglies ( { } not sure the real name) rather than quotes "". EDIT: I forgot to mention, I changed your hints to hintSilent because for some reason playing the sound in hint has a significant effect on performance.
  20. dreadedentity

    Generic error, syntax problem?

    Your formatting made me sad. shotcount = 0; MY_KEYDOWN_FNC = { switch (_this) do { case 22: { shotcount = shotcount + 1; hintSilent format ["%1",shotcount]; if (shotcount > 4) then { hintSilent "reloading"; sleep 5; shotcount = 0; hintSilent "ready"; } else { nul = [] execVM "mousebomb.sqf"; }; }; }; }; Anyway, since you have no syntax errors in this code, it seems your error comes from the way you're trying to access the function, using call MY_KEYDOWN_FNC "To execute a sleep function in the called code, execute it with spawn instead." Instead execute this function like, "[] spawn MY_KEYDOWN_FNC;" MattAka Horner explains in a note at the bottom of the "call" documentation: "A called function may only use suspension (sleep, uiSleep, waitUntil) if it originates in a scheduled environment. If the called function originates in a non-scheduled environment it will return a generic error. "
  21. Larrow I think iniDB updated and changed the @modname, confirming @inidbi in my computer. It was a long road with many problems, but I was somehow able to use my second pc to run the dedi from, that's my test enviornment. I came to a similar conclusion as you, and made the client ask the server for his info, so the server will get the client's session ID (there really needs to be a better way to do this btw). Rewrote my init.sqf to look like this "stats" addPublicVariableEventHandler { money = _this select 1; }; if (isDedicated) then { call compile preProcessFile "\inidbi\init.sqf"; "PV_ClientID" addPublicVariableEventHandler { stats = ["PLAYERINFO", _uid, "MONEY", "STRING"] call iniDB_read; (_this select 1) publicVariableClient "stats"; }; // ["connect", "onPlayerConnected", { // missionNamespace setVariable ["stats", ["PLAYERINFO", _uid, "MONEY", "STRING"] call iniDB_read]; // _id publicVariableClient "stats"; // }] call BIS_fnc_addStackedEventHandler; }; if (!isServer) then { PV_ClientID = owner player; publicVariableServer "PV_ClientID"; sleep 5; hintSilent format ["%1", money]; }; It's pretty messy and I'm still getting the "Undefined variable in expression: money" script error. I'll look over your code, but the secret to publicVariable is just eluding me for some reason.
  22. Well the database part is irrelevant, I'm just trying to understand how to pass a variable from server to client. That's not an array, it's just a variable. iniDB_read takes 4 parameters and returns one. I could replace that line with: stats = ["PLAYERINFO", _uid, "MONEY", "STRING"] call iniDB_read]; and it does the same thing. To explain a little more about how iniDB handles things, the first parameter is the filename. So if I opened up PLAYERINFO.ini, it would look like this: ["MYPLAYERID"] //second argument MONEY="3000" //third argument //fourth argument is variable type you want to return I have every reason to believe I've coded the database interaction correctly, I'm just not sure how to use publicVariable.
  23. Hello all, I'm trying to host a dedicated server on my other computer for script testing. I think I've got the server hosted successfully, I can see it when I remote and type my inside IP address. However, I cannot join it. When I try to join it, it just kicks me off with the message "You were kicked off the game." That kind of sucks since it's my server :p Also, in the server browser it just sits there with "CREATING". Any help getting me connected into my server would be greatly appreciated. Thanks
  24. For anyone interested, I figured out my problem. The problem was that I did not have Arma 3 installed on the computer that I wanted to run the dedi from, so it only had the server files and not the game files. When I copied over the game from my other computer, the server ran fine.
  25. dreadedentity

    Hunger/Thirst System (Done but with issues)

    I have a lot to say on this matter, but none of it is in intelligent language. Take a look inside this mission I just whipped up (Dropbox) Just unarchive that inside the same folder where your other missions are saved Run over to the other guy and he will give you food and drink for free (I did not implement a money system)
×