Sulon480 4 Posted November 29, 2020 Hi all! I'm a huge fan of this game, so I showed it to some of my friends and they actually bought it. They asked me if I could make some kind of Battle Royale "mission" and I said: Sure! I was like hm.. okay im just gonna place some vehicles and stuff, do some basic triggers and the drop-off plane...WAIT! The crates! So I opened up Chris' OFP Editor (a cool tool which I use to make briefings, scripts, custom crates and stuff) and made like 40 different crate variations with various weapons in it. So I have these crate scripts in my mission folder, they work but I have one problem. I want to sort of "randomize" them. By that, I mean that when I put down a crate in editor it's either "crate1", or "crate2", or "crate3"...and so on until "crate40" Is it possible? Im using - [this] exec "crate1.sqs" - at the weapon crate's init. line to "define" my crate script or however u say it, it's not my native language lol. Anyway, thx for anyone in advance! Peace! 😄 Share this post Link to post Share on other sites
Przemek_kondor 13 Posted November 30, 2020 You could move them to random position inside some area (https://community.bistudio.com/wiki/setPos) and/or randomize their setup e.g. (sorry I haven't coded in sqs for many years, hence pseudocode): nr = 1 + abs (random 40); [this] exec format["crate%1.sqs", nr] Share this post Link to post Share on other sites
Sulon480 4 Posted December 1, 2020 Quote nr = 1 + abs (random 40); [this] exec format["crate%1.sqs", nr] So I tried this one and it SHOULD do the trick so thanks for it but when I tried it in game for some reason the code is searching for non-existing crates. What I mean: So as I stated before I have "crate1.sqs" and so on until "crate40.sqs" and this code that u sent does exactly what I want, pick one of the crates randomly. however for some reason it searches for like "crate6.19043" and 18.5684 so basically it puts random (mybe random) digits after it and so the editor tells me that there is no such crate as crate18.5684. Do you know what causes this? I was really happy when I saw that ur answered but now I'm sad it doesn't work 😞 Thx in advance 😄 -Dima ps. Just i case I'll attach some pics :) (Hope it'll show correctly) (psps.:sry my pc's in Hungarian language:D) Share this post Link to post Share on other sites
Przemek_kondor 13 Posted December 1, 2020 ah, stupid me - it should be floor instead of abs (absolute just changes negative to positive) nr = 1 + floor (random 40); [this] exec format["crate%1.sqs", nr] Share this post Link to post Share on other sites
Sulon480 4 Posted December 1, 2020 Lol I just checked in! Thx, I'll try it now! Ya probably saved my ass... Thx bro, appreciated! Share this post Link to post Share on other sites
Sulon480 4 Posted December 1, 2020 It says unknown operator... 😱 Share this post Link to post Share on other sites
Przemek_kondor 13 Posted December 1, 2020 floor is available from Arma1https://community.bistudio.com/wiki/floor (round and ceil too), hmmm we need some way to get integer from float Share this post Link to post Share on other sites
Przemek_kondor 13 Posted December 1, 2020 (edited) based on https://community.bistudio.com/wiki/a_%_b: rand = 1 + (random 40); nr = rand - (rand % 1); [this] exec format["crate%1.sqs", nr] maybe this will work Edited December 1, 2020 by Przemek_kondor removed 'floor' Share this post Link to post Share on other sites
Sulon480 4 Posted December 1, 2020 It still says unknown operator... 😞 (Btw sorry for bothering you, but I really want this to work... 😄 ) Share this post Link to post Share on other sites
Przemek_kondor 13 Posted December 1, 2020 I've edited code above (I forgot to delete the problematic 'floor') 1 Share this post Link to post Share on other sites
Sulon480 4 Posted December 1, 2020 OMFG! Thx man, it works now! Share this post Link to post Share on other sites