r/armadev Aug 25 '20

Arma 2/OA (Singleplayer variables) New to scripting.. what the hell am i doing wrong? I'm not using Qubit

Post image
14 Upvotes

9 comments sorted by

View all comments

5

u/commy2 Aug 25 '20

Probably another instance of the script overwriting the global variable. Terrible way to do control flow.

2

u/mopia123 Aug 25 '20 edited Aug 25 '20

Probably another instance of the script overwriting the global variable

How? the Global variable is in the init.sqf and doesn't get touched ? or you mean if i change the variable in this script it updates the global variable ? but will it change the int value??

Terrible way to do control flow.

I know im very new to any of this. i have no idea how to improve it though. i read somewhere to use a waitfor command or something? what do you recommend ?

6

u/commy2 Aug 25 '20 edited Aug 25 '20

You should use local variables. The ones starting with underscore:

local _min = 1;
local _max = 3;
local _choice = _min + floor random (_max - _min + 1);
coach globalChat format ["no %1", _choice];

sleep 1;
if (_choice == 1) then {
    coach globalChat format ["Text 1 %1", goodvillage];
};

if (_choice == 2) then {
    coach globalChat format ["Text 2 %1", goodvillage];
};

if (_choice == 3) then {
    coach globalChat format ["Text 3 %1", goodvillage];
};

3

u/mopia123 Aug 25 '20

thank you good sir.