comp_uter15776 1 Posted July 23, 2013 Hey all, Me again! This time, I'm having difficulties with the new Sector Modules. Got them set up fine, works really well - but it's making a system to check various things to do with the sectors. For example, I'm looking to be able to set some tickets (say, 100 each, WestTickets and EastTickets), which will deplete eventually until one hits 0, in which case, the team with 0 loses. Simple, right? Well, I set my ticket variables up: WestTickets = 100; EastTickets = 100; Then I arrived at my first problem. I wanted for every capture point to check per 60 seconds which side it was on, and deduct a point from the other team. I created this: while {count playableUnits >= 1} do { if (_ST == West) then {WestTickets - 1} else {EastTickets - 1}; sleep 60; }; _ST was the name of my Sector as unfortunately I haven't found a way to retain a name which has a space in it yet can be used like the above. The problem is that there is no information on whether a sector "becomes" west or east, or if it just shows up as that, so how can I compare which side the sector is on? A line down I had this further: //while {count WestTickets < 1} do { //["end1",false,2] call BIS_fnc_endMission; //}; Noticing the comments, this was because of some error complaining that I was missing a semi-colon in the top line of that (I mean... how. It doesn't mean I actually am missing a semi-colon, just I screwed up elsewhere, right?), so that bit isn't used, but would be what I try when making the mission end if the WestTickets dropped below 1 (for testing purposes only, I'd add EastTickets in later). Regards, Harry Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 I think I noticed some info about the sector, owner previous owner. I placed hint str _this in one of the boxes where code can be run and got some info returned. Not at A3 pc now so can't check. also wouldn't _st == west be side _st == west but it depends if you can check the side of sector that way. Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 (edited) Hey F2k, I'll have a look at that hint stuff and relay what it outputs. You are correct for your last observation, although like you, I am unsure if I can even check the side like that. EDIT: output - [L Alpha 1-1:2,UNKNOWN,ENEMY] DBL EDIT: Additionally, I have arrived at the conclusion that side does not work. How would one be able to determine if a sector has been captured, though? Edited July 23, 2013 by Comp_uter15776 Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 As an update, I've moved over to this code instead: execVM "ticketcheck.sqf"; //Start ticket monitoring while {side ST == east} do { //Check side of sector hint "east"; if (side ST == east) then {WestTickets = (WestTickets - 1); //If East, deplete 1 east ticket sleep 60; //Wait 1 minute }; }; However it's still not observing the side, as no "east" hint appears. I am fairly certain the output that F2k mentioned can be manipulated in somehow? Share this post Link to post Share on other sites
dr_strangepete 6 Posted July 23, 2013 i noticed in the editor, the sector module has a line "expression", hint says: "code executed when sector ownership changes. Passed arguments are: [<module>,<ownerSide>,<previousOwnerSide>]" could use that to run a script or simply set a variable... and the line below, "Ownership Limit" sets owner based on side 'dominance', could be useful to use also Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 I did notice that, but I'm not entirely sure how I could use that, to be totally honest. Would you be able to give me an example, please? Regards, Harry Share this post Link to post Share on other sites
dr_strangepete 6 Posted July 23, 2013 I did notice that, but I'm not entirely sure how I could use that, to be totally honest. Would you be able to give me an example, please?Regards, Harry Also being honest, i've never used the module, nor have any experience with modules - i could give you theory how it can help you, but thats about it. the <module>,<ownerSide>,etc are passed in an array, accessible by the script through _this so <module> would be _this select 0 <ownerSide> - _this select 1 <previousOwnerSide> - _this select 2 option 1: set variables - set a global variable for whatever side now owns it: "my_global_sector_side_variable = _this select 1;" option 2: call script that does more: "_nil = [_this] spawn "sectorchangehandler.sqf"; where your file 'sectorchangehandler.sqf' could do the same as above, or spawn timers or whatever else you need. in essence you really just need it to change a single variable that can control your external loops Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 (edited) It should be something like this sector expression player setvariable ["sector",_this,true] trigger cond (player getvariable "sector" select 1 ) == opfor script if ((player getvariable "sector" select 1 ) == opfor) then {Hint "OPFOR"}; returned different info by changing the selection number modulename select 0 current owner select 1 previous owner select 2 Beaten to it. It may be better to change the player to a gamelogic name. Edited July 27, 2013 by F2k Sel Share this post Link to post Share on other sites
dr_strangepete 6 Posted July 23, 2013 Beaten to it. but yours is way cleaner and clearer :D Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 (edited) Wow, thanks guys! I was starting to think this was a question ranking amongst "what is the meaning of life" :D Both your posts are insightful and I gathered a lot of ideas from it. I assume though, the at least in F2k's, I simple dupe and modify the opfor bits to blufor, to make it work for the other side too? Regards, Harry EDIT: Also, is that trigger an additional one to the area linked, or same but replaces the "this"? Edited July 23, 2013 by Comp_uter15776 Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 yes just change to match the side you after or what you want it to do when it matches the conditions given. Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 Ah, thanks for clearing that up. Not sure if you saw my edit in previous page about triggers? I mean, I've changed my code a bit now so there's less waffle and so has stuff mixed around now haha Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 it was just an additional , away to test the result is all. Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 I see. So, at the moment my code now looks like this: execVM "ticketcheck.sqf"; //Start ticket monitoring while {true} do { //Check side of sector hint "east"; (if ((player getvariable "sector" select 1 ) == opfor) then {Hint "OPFOR"; WestTickets = (WestTickets - 1); //If West, deplete 1 ticket for East every minute }; sleep 60; //Wait 1 minute }; However upon capture of sector there is no text, just the box that should appear in its background... no icon or text! Am I doing something wrong? Pictures to follow. http://prntscr.com/1h2dg8 http://prntscr.com/1h2dph Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 Not sure but you seem to have an extra ( here (if ((p Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 Silly me :o Rectified that, but the problem is still there :/ Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 This is how I'm testing and it seems to work. I start the script from the players init null=[] execVM "ticketcheck.sqf" save as "ticketcheck.sqf" WestTickets = 50; //execVM "ticketcheck.sqf"; //Start ticket monitoring while {true} do { //Check side of sector hint "east"; if ((player getvariable "sector" select 1 ) == opfor) then { Hint "OPFOR"; WestTickets = (WestTickets - 1); //If West, deplete 1 ticket for East every minute }; sleep 2;//debug hint str WestTickets;//debug sleep 6; //Wait 1 minute }; Opfor take the sector and after eight seconds the ticket reduces I use 8 just for testing. It also shows the ticket number. I know file names are probably wrong but it was only for testing. Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 Ah, I see how you're running it now. Yea, ticketcheck is in fact for displaying how many tickets remaining, however I can easily enough just replace ticketcheck with ticket or something :) I'll post my results back shortly, thanks again! ---------- Post added at 17:30 ---------- Previous post was at 16:40 ---------- Excellent, thank you everyone for helping me! (I still have that missing text/icon for objective thing but I'm sure I can debug that; or pester you later :P) I do have a derivative question though; is there any way to customize the position of a hint in order to be able to show both teams' tickets at once? Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 I see what your your talking about, I miss read the question before and thought you were talking about the text in the script. Yes the box is blank right now I assume it's a bug that's crept in as it's still WIP. Can't really help with the hint as that would be MP, A dialog would probably be the best option but I don't know enough about that either. Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 Ok then, cheers for that :) Would setting each team to see a different hint be a possibility or is that also awkward? (I was then thinking perhaps being able to hit a command and it'd spew out the readings in chat or something) Share this post Link to post Share on other sites
f2k sel 164 Posted July 23, 2013 Mp stuff isn't my cup of tea so you may be better asking a fresh question in the forum. I'd be surprised if there isn't a way to do it. Share this post Link to post Share on other sites
comp_uter15776 1 Posted July 23, 2013 Right you are :) I'll have a little attempt myself at first, or I won't learn anything at all. Cheers once more, Harry Share this post Link to post Share on other sites
mikey74 179 Posted July 28, 2013 (edited) It works fairly well with 1 sector, but how would I implement this into 2 sectors? edited: GOT IT!!!!!! I named my 2 sectors ambo and Ambb, and changed my expressions to Ambb setvariable ["sectora",_this,true] and ambo setvariable ["sectorb",_this,true] I didnt need either of my triggers. I change the conditions to fit with what I am trying to do. Which is when one side has both sectors under control for a certain amount of time that side wins. while {true} do { //Check side of sector Sleep 2; if ((Ambb getvariable "sectora" select 1 ) == opfor && (ambo getvariable "sectorb" select 1 ) == opfor) then { Opwin = true; hint "Red controls all";} else { if ((Ambb getvariable "sectora" select 1 ) == blufor && (ambo getvariable "sectorb" select 1 ) == blufor) then { Blwin = true; hint "Blue controls all";}}; if ((Ambb getvariable "sectora" select 1 ) == blufor && (ambo getvariable "sectorb" select 1 ) == opfor) then { Opwin = false; Blwin = false; hint "No one controls all";} else { if ((Ambb getvariable "sectora" select 1 ) == opfor && (ambo getvariable "sectorb" select 1 ) == blufor) then { Blwin = false; Opwin = false; hint "No one controls all";}}; Sleep 6;}; I created 2 trigger with Blwin in ones condition and the other with Opwin, and whalla!!! I have what I was looking for. Thanks guys for the help! :) Edited July 28, 2013 by Mikey74 Share this post Link to post Share on other sites
Larrow 2821 Posted July 28, 2013 (edited) Rather than using the Expression box in the editor to set variables on objects you can get the state straight from the module objects them selves. INFO:- //number of modules on map _sectorsModules = count (entities "ModuleSector_F"); //return an array of sector module object names (as in name in editor) _sectors = missionnamespace getvariable ["BIS_fnc_moduleSector_sectors",[]]; //sector setting variables (not able to update from script) _name = _logic getvariable ["Name",""]; _logic getvariable ["Designation",""]; _logic getvariable ["OwnerLimit","0"]; _logic getvariable ["OnOwnerChange","true"]; _logic getvariable ["CaptureCoef","0.05"]; _logic getvariable ["CostInfantry","1"]; _logic getvariable ["CostWheeled","1"]; _logic getvariable ["CostTracked","1"]; _logic getvariable ["CostWater","1"]; _logic getvariable ["CostAir","1"]; _logic getvariable ["CostPlayers","1"]; _logic getvariable ["DefaultOwner","-1"]; _logic getvariable ["TaskOwner",0]; _logic getvariable ["TaskTitle","%1"]; _logic getvariable ["TaskDescription","%1%2%3"]; //game duration variables _logic getvariable ["areas",_areas,true]; _logic getvariable ["sides",_sides,true]; _logic getvariable ["flags",_flags,true]; _logic getvariable ["tasks",_tasks,true]; _logic getvariable ["designation",_designation,true]; _logic getvariable ["sideScore",_sideScore,true]; _logic getvariable ["contested",_contested,true]; _logic getvariable ["owner",_owner,true]; _logic getvariable ["ownerTexture",_iconTexture,true] _logic getvariable ["ownerColor",_iconColor,true]; _logic getvariable ["contested",false,true]; Where _logic is a reference to your sector module or use the name you gave it in the editor. Quick example using something along the lines of what Comp_uter15776 is trying to accomplish. init.sqf if (!isDedicated) then { hintTicketSide = false; fnc_HintTickets = { _HStringWest = format ["West = %1",_this select 0]; _HStringEast = format ["East = %1",_this select 1]; if (hintTicketSide) then { if (side player == west) then { hintSilent _HStringWest; }else{ hintSilent _HStringEast; }; }else{ hintSilent format["%1\n%2",_HStringWest,_HStringEast] }; }; }; if (isServer) then { westTickets = 10; eastTickets = 10; _handle = [] spawn { //while true just for editor testing while {true} do { //count playableUnits >= 1 or {isPlayer _x}count playableUnits for players only //sc1 is the name given to the module in the editor if ((sc1 getVariable "owner") == east) then { WestTickets = westTickets - 1; } else { EastTickets = eastTickets - 1 }; [[westTickets, eastTickets],"fnc_HintTickets",true,false] call BIS_fnc_MP; sleep 60; }; }; }; TestMission inc. MP PBO Shame the module script does not take note of setting variables during operation then you could have scenarios where if a side owns other sectors nearby you can up the cost of things so areas get taken quicker if you own more nearby (a litte bit like planetSide for example). Maybe it does if you disable it change the settings and re-enable, have not tested, only other way is to delete it and spawn a new one i suppose. Anyway hope the above helps you all out. Edited July 28, 2013 by Larrow Share this post Link to post Share on other sites
mikey74 179 Posted July 28, 2013 Rather than using the Expression box in the editor to set variables on objects you can get the state straight from the module objects them selves.INFO:- //number of modules on map _sectorsModules = count (entities "ModuleSector_F"); //return an array of sector module object names (as in name in editor) _sectors = missionnamespace getvariable ["BIS_fnc_moduleSector_sectors",[]]; //sector setting variables (not able to update from script) _name = _logic getvariable ["Name",""]; _logic getvariable ["Designation",""]; _logic getvariable ["OwnerLimit","0"]; _logic getvariable ["OnOwnerChange","true"]; _logic getvariable ["CaptureCoef","0.05"]; _logic getvariable ["CostInfantry","1"]; _logic getvariable ["CostWheeled","1"]; _logic getvariable ["CostTracked","1"]; _logic getvariable ["CostWater","1"]; _logic getvariable ["CostAir","1"]; _logic getvariable ["CostPlayers","1"]; _logic getvariable ["DefaultOwner","-1"]; _logic getvariable ["TaskOwner",0]; _logic getvariable ["TaskTitle","%1"]; _logic getvariable ["TaskDescription","%1%2%3"]; //game duration variables _logic getvariable ["areas",_areas,true]; _logic getvariable ["sides",_sides,true]; _logic getvariable ["flags",_flags,true]; _logic getvariable ["tasks",_tasks,true]; _logic getvariable ["designation",_designation,true]; _logic getvariable ["sideScore",_sideScore,true]; _logic getvariable ["contested",_contested,true]; _logic getvariable ["owner",_owner,true]; _logic getvariable ["ownerTexture",_iconTexture,true] _logic getvariable ["ownerColor",_iconColor,true]; _logic getvariable ["contested",false,true]; Where _logic is a reference to your sector module or use the name you gave it in the editor. Quick example using something along the lines of what Comp_uter15776 is trying to accomplish. init.sqf if (!isDedicated) then { hintTicketSide = false; fnc_HintTickets = { _HStringWest = format ["West = %1",_this select 0]; _HStringEast = format ["East = %1",_this select 1]; if (hintTicketSide) then { if (side player == west) then { hintSilent _HStringWest; }else{ hintSilent _HStringEast; }; }else{ hintSilent format["%1\n%2",_HStringWest,_HStringEast] }; }; }; if (isServer) then { westTickets = 10; eastTickets = 10; _handle = [] spawn { //while true just for editor testing while {true} do { //count playableUnits >= 1 or {isPlayer _x}count playableUnits for players only //sc1 is the name given to the module in the editor if ((sc1 getVariable "owner") == east) then { WestTickets = westTickets - 1; } else { EastTickets = eastTickets - 1 }; [[westTickets, eastTickets],"fnc_HintTickets",true,false] call BIS_fnc_MP; sleep 60; }; }; }; TestMission inc. MP PBO Shame the module script does not take note of setting variables during operation then you could have scenarios where if a side owns other sectors nearby you can up the cost of things so areas get taken quicker if you own more nearby (a litte bit like planetSide for example). Maybe it does if you disable it change the settings and re-enable, have not tested, only other way is to delete it and spawn a new one i suppose. Anyway hope the above helps you all out. I've tried the 1st part of your 1st script.... lol BUT I haven't got a clue apparently. lol What if you have multiple sectors? You see what Ive got up there. I'd like to make it much easier for people with less scripting knowledge than me. Where they can just insert the name's of sectors and insert the script I am working on and go. I know there is a simpler way than I'm doing it, but I keep hitting walls. lol I'm not an expert by far. Share this post Link to post Share on other sites