splatsh 10 Posted May 28, 2010 Got this in my "description.ext" Its from revive script, then I want to add a random option. But I dont know how it works. This is what I have now. description.ext class Params { class DayTime { //paramsArray[0] title = "Time Of Day"; values[] = {-6, 0, 8, 13, 00}; texts[] = {"Morning", "Clear day", "Sundown", "Night", "Random"}; default = 0; }; }; init.sqf If (paramsArray select 0 == "00") then { skiptime(random 24); }; else { skiptime (paramsArray select 0); }; But that is not working when I pick random. Please help me, how to set this up. Share this post Link to post Share on other sites
mrcurry 508 Posted May 28, 2010 (edited) your problem lies here: paramsArray select 0 == "00" this test if the parameter is set to a string of two zero's i.e "00" but... in your description.ext you give "Random" the value of 00 (and I think this is a interpreted as the numeric value 0, might be better to use a unique value like 1337 or w/e) quickfix: //In your description.ext: values[] = {-6, 0, 8, 13, 1337}; //in your init.sqf: If (paramsArray select 0 == 1337) then { I'm not sure if values[] can take strings (i.e. values[] = {-6, 0, 8, 13, "random"}; ) but that might work too, assuming you check for (paramsArray select 0 == "random") Edited May 28, 2010 by mrCurry Share this post Link to post Share on other sites
TRexian 0 Posted May 28, 2010 I believe you've defined the values as numeric, but are testing the conditional for a string? Perhaps make the values -6, 0, 8, 13, 99, then the conditional would be something like: if (paramsArray select 0 == 99) then I've never tried to do what you're doing, though, so not sure if that would even work. In the init, you may want to add a hint or diag_log to return what paramsArray select 0 is. That will let you know if it isn't even receiving the proper value. Good luck! Edit: ninja'd by Curry.... :D Glad we have the same answer, though. ;) Share this post Link to post Share on other sites
mrcurry 508 Posted May 28, 2010 (edited) Hehe, I'm actually gonna test if the values[] can take a string right this moment. Edit: It did not like that one bit. Only resulted in "Error in expression <(paramsArray select 0) == "rawr">" Conclusion: values[] can contain anything (runs fine), but you can only check it against numeric values. Edited May 28, 2010 by mrCurry Share this post Link to post Share on other sites
shuko 59 Posted May 28, 2010 If it's for MP, will be fun to have all players play at different times of day. ;) Share this post Link to post Share on other sites
mrcurry 508 Posted May 28, 2010 (edited) Biki about skiptime Even though the immediate effect of skipTime is only local, the new time will propagate through the network after 30 seconds or so. Solution: If (paramsArray select 0 == 1337 and isServer) then { skiptime(random 24); }; about the strings, did a second test... if you enter a string into your values[] it will simply ignore it and default to the first element supplied. values[] = {0, 1, 2, "rawr"}; texts[] = {"Easy", "Medium", "Hard", "Rawr!"}; will give you a the possible values {0,1,2} and even though you can still select the 4th option "Rawr!" it will default to the first value. In this case(paramsArray select 0 == 0) would return true Edited May 28, 2010 by mrCurry Share this post Link to post Share on other sites
TRexian 0 Posted May 28, 2010 Hey Curry- Nice find. One observation - I've found the engine can choke sometimes without clear parentheticals... something like ((paramsArray select 0 == 1337) and (isServer)) But YMMV. :) Share this post Link to post Share on other sites
splatsh 10 Posted May 28, 2010 Thanks for all answers. I use this atm and it look like it work good. in my description.ext values[] = {-6, 0, 8, 13, 1337}; init.sqf If ((paramsArray select 0 == 1337) and (isServer)) then { skiptime(random 24); }; else { skiptime (paramsArray select 0); }; Thanks for help :) ---------- Post added at 03:15 PM ---------- Previous post was at 02:30 PM ---------- Update: Sorry, but it does not work ok. If I select random it will work, but when select something else it does not work... Then I will start at 12.00 all the time. (That time I have set in editor.) How come? Share this post Link to post Share on other sites
shuko 59 Posted May 28, 2010 Because you have semicolon in the } else {. Besides, if you are going to count on the server syncing the time correctly and in decent amount of time, then I'd use this: if (isServer) then { if (paramsArray select 0 == 1337) then { skiptime(random 24); } else { skiptime (paramsArray select 0); }; }; That way the client doesn't run skiptime ever. In your code (without the typo) clients would always run it, even with 1337 value. Btw, instead of figuring out the perfect times for sunrise etc for each mission, you could use this: skiptime (((paramsArray select 0) - daytime + 24) % 24); With that you can define the hour you want the clock to be directly in the desc.ext instead of putting there the amount of hours to move either way. Makes it more convenient to copy-paste for new missions. :) Example what the desc.ext could have: 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}; texts[] = {"0000","0100","0200","0300","0400","0500","0600","0700","0800","0900","1000","1100","1200","1300","1400","1500","1600","1700","1800","1900","2000","2100","2200","2300"}; Share this post Link to post Share on other sites
splatsh 10 Posted May 28, 2010 So this is what you mean: (Need to confirm that it is correct, I am not so good at this codes.) title = "Time Of Day"; values[] = {1337,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}; texts[] = {"Random","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","1800","19.00","20.00","21.00","22.00","23.00"}; default = 12; if (isServer) then { if (paramsArray select 0 == 1337) then { skiptime(random 24); } else { skiptime (((paramsArray select 0) - daytime + 24) % 24); }; }; Share this post Link to post Share on other sites
wiggum2 31 Posted July 5, 2010 Ok, if i understand that correctly, then this is a working method to have a option to choose time only in a MP Game or SP too ? When do you get the option of choose daytime, during briefing ? This goes into Description.ext ? title = "Time Of Day"; values[] = {1337,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}; texts[] = {"Random","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","1800","19.00","20.00","21.00","22.00","23.00"}; default = 12; This goes into init.sqf ? if (isServer) then { if (paramsArray select 0 == 1337) then { skiptime(random 24); } else { skiptime (((paramsArray select 0) - daytime + 24) % 24); }; }; So now if i want two daytimes to select from, lets say 05:00 (day) and 02:00 (Night) i would need something like: case "Night": {... case "Day": {... ...oh man, to complex for me at the moment, can someone help please ? Share this post Link to post Share on other sites
shuko 59 Posted July 5, 2010 title = "Time Of Day"; values[] = {5,2}; texts[] = {"Day","Night"}; default = 5; skiptime (((paramsArray select 0) - daytime + 24) % 24); No idea if you can select parameters in SP, but in MP they are available for the admin in the pool aka role/slot selection screen. Share this post Link to post Share on other sites
wiggum2 31 Posted July 5, 2010 title = "Time Of Day"; values[] = {5,2}; texts[] = {"Day","Night"}; default = 5; skiptime (((paramsArray select 0) - daytime + 24) % 24); No idea if you can select parameters in SP, but in MP they are available for the admin in the pool aka role/slot selection screen. Thanks, but i cant get it work... This is how my description.ext looks like: class CfgRadio { class nomin_extract_01 { name = "nomin_extract_01"; sound[] = {}; title = "[YOU]: WE ARE CLOSE TO THE OUTPOST, GET READY GUYS !"; }; }; onLoadMission = "Attack The Outpost !"; onLoadMissionTime = true; doneKeys[]={"norest"}; title = "Time Of Day"; values[] = {5,2}; texts[] = {"Day","Night"}; default = 2; And then i have put these at the beginning of my init.sqf: if (isServer) then { skiptime (((paramsArray select 0) - daytime + 24) % 24); }; But if i host a server now i nowhere have the option to change daytime. Share this post Link to post Share on other sites
shuko 59 Posted July 5, 2010 class Params { class TimeOfDay { title = "Time Of Day"; values[] = {5,2}; texts[] = {"Day","Night"}; default = 2; }; }; http://derfel.org/arma2/paramswindow.jpg Share this post Link to post Share on other sites
wiggum2 31 Posted July 5, 2010 (edited) @ shk Thanks again for your help ! Now it works. :) Edited July 5, 2010 by Wiggum Share this post Link to post Share on other sites