Jump to content

Recommended Posts

hello boy's and girl's i am releasing my fog script to night at 3am uk time random fog works well lot of people asked for it

 

titleText ["picking random fog", "PLAIN DOWN", 3];
sleep 5;
_var = random 1.80; //generates a random value between 0 and 1.80
if (_var < 0.20) then {
execVM 'overwrites\click_actions\250.sqf';
} else {
if (_var < 0.40 and _var > 0.20) then {
execVM 'overwrites\click_actions\500.sqf';
} else {
if (_var > 0.40 and _var < 0.60) then {
execVM 'overwrites\click_actions\750.sqf';
} else {
if (_var > 0.60 and _var < .80) then {
execVM 'overwrites\click_actions\1000.sqf';
} else {
if (_var > 0.80 and _var < 1) then {
execVM 'overwrites\click_actions\1250.sqf';
} else {
if (_var > 1 and _var < 1.20) then {
execVM 'overwrites\click_actions\1500.sqf';
} else {
if (_var > 1.20 and _var < 1.40) then {
execVM 'overwrites\click_actions\1750.sqf';
} else {
if (_var > 1.40 and _var < 1.60) then {
execVM 'overwrites\click_actions\2000.sqf';
} else {
if (_var > 1.60 and _var < 1.80) then {
execVM 'overwrites\click_actions\2500.sqf';
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};

titleText ["fog is now set relog to unset the change", "PLAIN DOWN", 3];

http://www.filedropper.com/clickactions

Link to comment
Share on other sites

Just wanted to add this to a code block because it just looks so much nicer...
 

titleText ["picking random fog", "PLAIN DOWN", 3];
sleep 5;
_var = random 1.80; //generates a random value between 0 and 1.80
if (_var < 0.20) then {
execVM 'overwrites\click_actions\250.sqf';
} else {
if (_var < 0.40 and _var > 0.20) then {
execVM 'overwrites\click_actions\500.sqf';
} else {
if (_var > 0.40 and _var < 0.60) then {
execVM 'overwrites\click_actions\750.sqf';
} else {
if (_var > 0.60 and _var < .80) then {
execVM 'overwrites\click_actions\1000.sqf';
} else {
if (_var > 0.80 and _var < 1) then {
execVM 'overwrites\click_actions\1250.sqf';
} else {
if (_var > 1 and _var < 1.20) then {
execVM 'overwrites\click_actions\1500.sqf';
} else {
if (_var > 1.20 and _var < 1.40) then {
execVM 'overwrites\click_actions\1750.sqf';
} else {
if (_var > 1.40 and _var < 1.60) then {
execVM 'overwrites\click_actions\2000.sqf';
} else {
if (_var > 1.60 and _var < 1.80) then {
execVM 'overwrites\click_actions\2500.sqf';
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};

titleText ["fog is now set relog to unset the change", "PLAIN DOWN", 3];

 

Link to comment
Share on other sites

On 3/14/2016 at 6:26 PM, DangerRuss said:

Just wanted to add this to a code block because it just looks so much nicer...
 


titleText ["picking random fog", "PLAIN DOWN", 3];
sleep 5;
_var = random 1.80; //generates a random value between 0 and 1.80
if (_var < 0.20) then {
execVM 'overwrites\click_actions\250.sqf';
} else {
if (_var < 0.40 and _var > 0.20) then {
execVM 'overwrites\click_actions\500.sqf';
} else {
if (_var > 0.40 and _var < 0.60) then {
execVM 'overwrites\click_actions\750.sqf';
} else {
if (_var > 0.60 and _var < .80) then {
execVM 'overwrites\click_actions\1000.sqf';
} else {
if (_var > 0.80 and _var < 1) then {
execVM 'overwrites\click_actions\1250.sqf';
} else {
if (_var > 1 and _var < 1.20) then {
execVM 'overwrites\click_actions\1500.sqf';
} else {
if (_var > 1.20 and _var < 1.40) then {
execVM 'overwrites\click_actions\1750.sqf';
} else {
if (_var > 1.40 and _var < 1.60) then {
execVM 'overwrites\click_actions\2000.sqf';
} else {
if (_var > 1.60 and _var < 1.80) then {
execVM 'overwrites\click_actions\2500.sqf';
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};

titleText ["fog is now set relog to unset the change", "PLAIN DOWN", 3];

 

thanks dude try to keep my code neat im just lazy at it like to keep code short as i can :rolleyes:

Link to comment
Share on other sites

On 3/14/2016 at 3:40 PM, ViseVersa said:

 

Next Time put it in a Spoiler to, please :P Oh and the Title is wrong. This is ViewDistance, not Fog! And it`s not well optimized ^^

There was literally no reason to add a spoiler. I was simply updating the original post with a code box so it was easier to copy paste. 

Link to comment
Share on other sites

Hi KillerKiwi

I am glad to see people are still contributing some of their work around.
Here's a quick tips on scripting:
If you have to type it more than twice, put it in a function.
When dealing with too many IF statements, it will be faster on runtimes if you use switch instead. That way engine does not need to execute multiple statements, instead it will execute one and compare given values which is faster and tidier.

However in some examples like yours, to keep code small and tidy, duplicate code can be removed with a little bit of creativity :)

_file = [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500];
_rand = _file select floor random count _file;
execVM format ["overwrites\click_actions\%1.sqf",_rand];

Enjoy the scripting, it's fun!

Link to comment
Share on other sites

  • 2 months later...
On 20/03/2016 at 11:50 AM, raymix said:

 

Hi KillerKiwi

I am glad to see people are still contributing some of their work around.
Here's a quick tips on scripting:
If you have to type it more than twice, put it in a function.
When dealing with too many IF statements, it will be faster on runtimes if you use switch instead. That way engine does not need to execute multiple statements, instead it will execute one and compare given values which is faster and tidier.

However in some examples like yours, to keep code small and tidy, duplicate code can be removed with a little bit of creativity :)


_file = [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500];
_rand = _file select floor random count _file;
execVM format ["overwrites\click_actions\%1.sqf",_rand];

Enjoy the scripting, it's fun!

 

thanks dude keep that in mind working on a few scripts try my best to add thatin but like to make it look like i done more work with it :tongue: 

Link to comment
Share on other sites

On Sunday, May 29, 2016 at 0:15 PM, killerkiwi said:

thanks dude keep that in mind working on a few scripts try my best to add thatin but like to make it look like i done more work with it :tongue: 

What raymix means , it's more optimized like that so will be faster , cleaner and create less burden on the engine . Making code large and big does not let it look like you did more work . It's actually only creating more work for the server . But indeed good people are still sharing nice work .

Link to comment
Share on other sites

yeah cuz execVM requires to pass variable, even if empty. I just wrote that as an example how you can optimize code into "one liners", kinda missed that part, been a while I touched SQF

Simply add empty array or anything else in front of it like so:

[] execvm "stuff"

And just to be on safe side, to make sure that string is generated before it's called, simply wrap the format in () like so:

[] execVM (format ["overwrites\click_actions\%1.sqf",_rand]);

It should work without it, but it's not a bad habit to have.

sometimes people even create nil variable to store nothing in it since there's no response. I find this practice kinda lame, but to each its own.

_nil = 0 execVM "stuff";

 

Link to comment
Share on other sites

You are calling (execVM) the sqf before declaring _file, try:

private ["_file"]; 
_file = [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500]; 
0 = [] execVM format ["overwrites\click_actions\%1.sqf",selectRandom _file]; 

If you want to reduce it further:

0 = [] execVM format ["overwrites\click_actions\%1.sqf",selectRandom [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500]]; 

https://community.bistudio.com/wiki/selectRandom

Link to comment
Share on other sites

 

On ‎31‎/‎05‎/‎2016 at 2:44 AM, killerkiwi said:

;) lol i no try this did't work

On ‎20‎/‎03‎/‎2016 at 11:50 AM, raymix said:

_file = [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500]; _rand = _file select floor random count _file; execVM format ["overwrites\click_actions\%1.sqf",_rand];

 

That will work perfectly fine. execVM doesn't require anything passing to it, at least not in Arma 3.

I seem to remember using execVM and format in that way didn't used to work in A2, maybe that has been updated since ? Previously I would use a call compile to execVM dynamic scripts: 

call compile format["[] execVM ""overwrites\click_actions\%1.sqf""",selectRandom [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500]];

A method I still use, out of habit, until now :)

EDIT

I don't think selectRandom is available for A2, I haven't currently got an install to test, this will work just as well as a replacement:

call compile format["[] execVM ""overwrites\click_actions\%1.sqf""",[250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500] call BIS_fnc_selectRandom];

https://community.bistudio.com/wiki/BIS_fnc_selectRandom

Link to comment
Share on other sites

12 hours ago, axeman said:

 

That will work perfectly fine. execVM doesn't require anything passing to it, at least not in Arma 3.

Oh shiet, you're right, I thought execVM works the same as Spawn which requires args at all times ( except it's reading the script from a drive not function in memory). Well, my excuse is that  I've never really used execVM to be honest, always compiling my stuff in memory, heh.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...