Jump to content

JacobJ

Member
  • Content Count

    308
  • Joined

  • Last visited

  • Medals

Community Reputation

10 Good

About JacobJ

  • Rank
    Staff Sergeant
  1. I have now removed those while loops and now it is working, but I am not happy with this. I need it to check if the next waypoint is closer than a certain distance or else it must generate a new one. But maybe my logic is wrong? It has to generate that position anyways, wouldnt it be easier on the server if it just satisfied with that position and used that instead of generating a new one? But this isnt looking very good, if they drew longer it would be nicer to look at. How can I put in a condition that would run the _pos code again to get a position further away and lets say 200 meters? Simpler script, but not what I am looking for: ---------- Post added at 04:18 PM ---------- Previous post was at 03:27 PM ---------- Okay I admit that I am not the sharpest knife in the drawer, when it comes to programming arma 2 stuff, but this is just silly.. I put in the _MinDistanceToNextPos into the _range parameter that is send to the SHK_pos script. By doing that I dont need loops like that to check the distance, because the distance to the next pos will be atleast the _MinDistanceToNextPos variable. Here is the code and I have added a distance hint to show how far away car1 is from W1.
  2. Okay cool. I surely don't understand all of scripting and thats why I posted this. Didnt know that it could be done so easily. I will try this out and see how it works. Thank you for your help so far.
  3. Hey all I have some scripts in my init.sqf that runs when the game is startet. Those scripts are started like this: [10, _markers] execVM "cars.sqf"; Lets say I want to be able to change that first variable, from 10 to lets say 20 in the lobby parameters (don't know what it is called correctly, but you know when you start up a multiplayer game and then select what time you want the mission to run at). How can I do that? It would make the mission a lot more user friendly, because they could change the number of cars, enemies and stuff like that. In my init.sqf I already have these parameters: //LOBBY PARAMETERS waitUntil {!(isNil "Paramsarray")}; //Til tiden skiptime (((paramsarray select 0) - daytime + 24) % 24); //Til vejret switch (paramsarray select 2) do { case 1: { 0 setOvercast 0; 0 setRain 0; 0 setFog 0 }; case 2: { 0 setOvercast 1; 0 setRain 1; 0 setFog 0.2 }; case 3: { 0 setOvercast 0.7; 0 setRain 0; 0 setFog 0 }; case 4: { 0 setOvercast 0.7; 0 setRain 1; 0 setFog 0.7 }; }; //Til PMC captive switch (paramsarray select 3) do { case 1: {[] execVM "PMCcaptive.sqf"}; case 2: {}; }; And acordingly in my description.ext: class Params { class TimeOfDay { title = "Time of day:"; values[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}; default = 12; texts[] = {"00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"}; }; class Revive { // paramsArray[1] title = "Number of Revives:"; values[] = {2000,1000,20,10,7,5}; texts[] = {"No Revive","Infinite - Cadet","20 - Easy ","10 - Normal","7 - Hard","5 - Extreme"}; default = 10; }; class Weather { title = "Weather"; values[] = {1,2,3,4}; default = 1; texts[] = {"Clear", "Stormy", "Cloudy", "Foggy"}; }; class Captive { title = "Captive inside PMC"; values[] = {1,2}; default = 1; texts[] = {"Yes", "No"}; }; }; /Jacob
  4. It isnt so that I only can use the variable _pos once? It can't be that the _pos isnt defined, because the above line _civ uses the _pos variable and that works fine. Just can't see what I have done wrong. Is there something wrong with the _mrk1 variable? Maybe it isnt something with the _pos, but with the _mrk1, that is wrong... ---------- Post added at 01:22 PM ---------- Previous post was at 12:16 PM ---------- Okay, after playing around with this, ive found a solution. Don't know if it is how it should be done, but atm. it is working. I just moved the creation of the marker a bit further down the code.
  5. Bump my problem: Post #869. Still get the same error: "Error Undefined variable in expression: _unconscious_invincibility"
  6. Hey again. Ive patched together this script from this threads posted codes. But I would like the second marker _mrk1 to be placed where the car is going to go, but it doesnt move. The _civ move _pos; works fine, but the _mrk1 setMarkerPos _pos; doesnt work. What have I done wrong?? hunhund = if (count _this >= 1) then {_this select 0} else {false}; if isserver then { SHK_cars = []; createCenter CIVILIAN; //Script can be improved by using the _pos of the car to generate the new position. To prevent the car from leaving the city, a _car distance marker can be put in to prevent that. //It is essential, that the _spawnrange and _spawnroads is set to as low numbers as possible. That makes the cars being generated a lot quicker and after that, the cars can use the larger //number, which can be defined in the _range and _DisToRoads parameters. private ["_cartypes","_count","_distance","_areacenter","_pos","_cartype","_car","_trg","_cnd","_act","_mrk","_side","_knowsAbout","_range","_onroads","_DisToRoads","_MindistanceToNextPos","_spawnrange","_spawnroads","_DisToRoadsCenter","_rangeCenter"]; _cartypes = ["car_hatchback","car_sedan","datsun1_civil_1_open","datsun1_civil_2_covered","datsun1_civil_3_open","hilux1_civil_1_open","hilux1_civil_2_covered","hilux1_civil_3_open","Ikarus","Lada1","Lada2","LadaLM","MMT_Civ","Skoda","SkodaBlue","SkodaGreen","SkodaRed","Tractor","TT650_Civ","UralCivil","UralCivil2","V3S_Civ","VWGolf","hilux1_civil_3_open_EP1","Ikarus_TK_CIV_EP1","Lada1_TK_CIV_EP1","Lada2_TK_CIV_EP1","LandRover_TK_CIV_EP1","Old_bike_TK_CIV_EP1","Old_moto_TK_Civ_EP1","S1203_TK_CIV_EP1","SUV_TK_CIV_EP1","TT650_TK_CIV_EP1","UAZ_Unarmed_TK_CIV_EP1","Ural_TK_CIV_EP1","V3S_Open_TK_CIV_EP1","Volha_1_TK_CIV_EP1","Volha_2_TK_CIV_EP1","VolhaLimo_TK_CIV_EP1"]; _civtypes = ["TK_CIV_Takistani01_EP1", "TK_CIV_Takistani02_EP1", "TK_CIV_Takistani03_EP1", "TK_CIV_Takistani04_EP1", "TK_CIV_Takistani05_EP1", "TK_CIV_Takistani06_EP1"]; _count = 5; _distance = 50; _areacenter = getMarkerPos "CIVcarMarker"; _side = WEST; _knowsAbout = 0.5; _spawnrange = random 200; _spawnroads = 200; _range = random 200; _rangeCenter = random 100; _DisToRoadsCenter = 100; _DisToRoads = 200; _MindistanceToNextPos = 100; _onroads = 1; for "_i" from 0 to (_count - 1) do { _pos = [_areacenter, _spawnrange, random 359, false, [_onroads, _spawnroads]] call SHK_pos; _cartype = _cartypes select (floor(random(count _cartypes))); _car = (_cartypes select (floor(random(count _cartypes)))) createVehicle (_pos); _civtype = _civtypes select (floor(random(count _civtypes))); _civ = (creategroup CIVILIAN) createUnit [_civtype,_pos,[],0,"NONE"]; _civ moveInDriver _car; _civ setSpeedMode "NORMAL"; _civ setBehaviour "SAFE"; SHK_cars set [_i,_car]; /* _trg = createTrigger ["EmptyDetector",_pos]; _trg setTriggerArea [_distance,_distance,0,false]; _trg setTriggerActivation ["WEST","PRESENT",true]; _cnd = format ["this && alive (SHK_cars select %1)",_i]; _act = format ["%1 spawn SHK_fncCivBomb",_i]; _trg setTriggerStatements [_cnd,_act,""]; _trg attachTo [_car]; */ if (hunhund) then { _mrk = createMarker [format ["CIVcar_%1",_i],_pos]; _mrk setMarkerShape "Icon"; _mrk setMarkerType "dot"; _mrk setMarkerColor "ColorRed"; _mrk setMarkerText format ["CIVcar_%1", (_i + 1)]; _mrk1 = createMarker [format ["WhereToCar_%1",_i],_pos]; _mrk1 setMarkerShape "Icon"; _mrk1 setMarkerType "dot"; _mrk1 setMarkerColor "ColorBlue"; _mrk1 setMarkerText format ["WhereToCar %1", (_i + 1)]; }; [_car,_mrk,_areacenter,_side,_knowsAbout,_civ,_range,_onroads,_DisToRoads,_MindistanceToNextPos,_DisToRoadsCenter,_rangeCenter,_i,_mrk1] spawn { private ["_car","_mrk","_areacenter","_pos","_i","_trg","_side","_knowsAbout","_areaway","_carway","_mrk1"]; _car = _this select 0; _civ = _this select 5; _range = _this select 6; _onroads = _this select 7; _DisToRoads = _this select 8; _MindistanceToNextPos = _this select 9; _DisToRoadsCenter = _this select 10; _rangeCenter = _this select 11; _i = _this select 12; if (hunhund) then { _mrk = _this select 1; _mrk1 = _this select 13; }; _areacenter = _this select 2; _side = _this select 3; _knowsAbout = _this select 4; areaway = 0; while {alive _car AND alive _civ} do { if (hunhund) then { _mrk setMarkerPos getpos _car; }; // Drive around if (alive _car AND alive _civ) then { if (unitReady _civ) then { areaway = areaway + 1; hint str format ["Car%1 - Total %2", _i, areaway]; if (_car distance _areacenter > 3200) then { _pos = [_areacenter, _rangeCenter, random 360, false, [_onroads, _DisToRoadsCenter]] call SHK_pos; while {_car distance _pos < _MindistanceToNextPos} do { _pos = [_areacenter, _rangeCenter, random 360, false, [_onroads, _DisToRoadsCenter]] call SHK_pos; sleep 1; }; _civ move _pos; _mrk1 setMarkerPos _pos; } else { //Lav det om igen, så det kun er normal random der er herunder. _pos = [_civ, _range, random 360, false, [_onroads, _DisToRoads]] call SHK_pos; while {_car distance _pos < _MindistanceToNextPos} do { _pos = [_civ, _range, random 360, false, [_onroads, _DisToRoads]] call SHK_pos; sleep 1; }; _civ move _pos; _mrk1 setMarkerPos _pos; }; }; }; sleep 1; }; if (hunhund) then { deleteMarker _mrk; deleteMarker _mrk1; }; }; }; }; hint "CIVcarTraffic.sqf - DONE";
  7. Hey all I got this civilian traffic script which I have made from bits and pieces of code provided here on the forum. It all works, but sometimes it just doesnt. I have narrowed the error down to the coloured code bit. The problem is, that if I put in a to big number in the _MindistanceToNextPos the while-loop goes crazy and the cars doesnt move. It just hangs in that loop. If I put in another lower number, like 100, instead of 400 it runs fine. But why does it hang there? At the moment I see no other option, than removing the distance condition and the whole loop and just satisfy with a random distance to the next waypoint. The reason I would like this, is that it would make the cars drive a bit more realisticly, not stopping all the time and also very much because I think it would help in performance, because the script would be executed a lot fewer times. Here is the script:
  8. I have tried the two testmissions, but I have a problem. When I order fixed air support, then the plane arrives, drops the bomb and then fly away. All fine, but it doesnt return to base. It keeps comming back. Its just like the known issue with drapers air support, which I think is also a good script, but it has the same issue with the planes wanting to circle around instead of returning to base. If I would to suggest some additional features that would be nice to have, it would be the ability to cancel the request and to be able to limit what kinds of support a unit could use. Else I think its a very nice script, but its a bit annoying with those planes.
  9. Okay cool, looks like this is a much more cleaver solution, than the one I have thought of. Can you explain why the unit is _this select 2? What is _this select 0 and _this select 1? But thank you very much for your help, I will try this out when I get home.
  10. Hey all I have thought of making a feature for my mission where units inside a car is set to captive, so that they can drive through enemy territory wihtou getting shot at. If they then get out of the vehicle and the enemy knowsabout those units, then they can't just jump into the vehicle again and then they are captive again. Its a one-time opportunity, if they areant knownabout. But how its done I don't know.. I have thought of triggers and a while function that checks all the time if and who is inside the vehicle, but that seems a bit to overkill or what would you suggest? /Jacob
  11. Okay, thank you for that. I have also found a download which makes notepad ++ show the syntax's. Thats also very handy.
  12. Okay I see what you mean. Surely I didnt want the groupleader code to be run for each unit. This works just as it should. Thank you very much for your help. How do you get so fine colours in your scripts? What syntax highlighting plugin do you use?
  13. I have tried playing around with the script again. Basicly, create a group of soldiers and make one of them the leader. The rest then follow the leader. The problem is only, that the they don't follow. They stand still, but the _groupleader runs away like he should. How would I make the rest follow? If I would like to spawn more groups, would I then just have to run the script again or how would I do that? Maybe create so many I want, put in a parameter of lets say 10 and that would be the number of units for that group. Then another group was created from the next 10 spawning units and so on. Script.sqf call compile preprocessfile "SHK_pos\shk_pos_init.sqf"; SHK_patrol = []; createCenter EAST; private ["_mentypes","_count","_pos","_mantype","_groupleader","_mrk","_spawncenter","_grp"]; _mentypes = ["TK_INS_Soldier_EP1", "TK_INS_Soldier_2_EP1", "TK_INS_Soldier_3_EP1", "TK_INS_Soldier_4_EP1", "TK_INS_Soldier_AA_EP1", "TK_INS_Soldier_AT_EP1", "TK_INS_Soldier_Sniper_EP1", "TK_INS_Soldier_AR_EP1", "TK_INS_Soldier_MG_EP1"]; _count = 10; _spawncenter = getMarkerPos "groupleaders"; for "_i" from 0 to (_count - 1) do { _grp = createGroup EAST; _mantype = _mentypes select (floor(random(count _mentypes))); _man = _grp createUnit [_mantype,_spawncenter,[],0,"FORM"]; SHK_patrol set [_i,_man]; [_groupleader,_mrk,_spawncenter] spawn { private ["_groupleader","_mrk","_spawncenter","_i"]; _groupleader = _this select 0; _mrk = _this select 1; _spawncenter = _this select 2; _groupleader = SHK_patrol select 0; _grp selectLeader _groupleader; _mrk = createMarker ["Groupleader",_spawncenter]; _mrk setMarkerShape "Icon"; _mrk setMarkerType "dot"; _mrk setMarkerColor "ColorRed"; _mrk setMarkerText "Groupleader"; while {alive _groupleader} do { _mrk setMarkerPos getpos _groupleader; if (unitReady _groupleader) then { _pos = [getmarkerpos "groupleaders", random 200, random 359, false, [0, 0]] call SHK_pos; _groupleader move _pos; sleep 1; }; }; deleteMarker _mrk; }; };
  14. Shuko, any possibility to take out the buildings already used in your script? It seems they are stacking up at a few buildings only. I have 5 men which position themselfs on only two buildings. It would be nice to spread them out a bit. Maybe a limit parameter for each buildingpos would be nice. Just a suggestion if you plan on upgrading it.
  15. Working like a charme. Thank you very much for your help with all these scripts. Now I almost have all the scripting needed to get this mission finished. Do you think I should change the title of the thread to something like: "SHK suicide generator script" so others can find it easier to use it in their missions? For everyone else who has helped me, thank you very much! If I have any questions in relation to this and/or alterations to this script, I will post them in here.
×