I made 2 arrays
One at top of the script as:-
Array1 <- [1,2,3];
2nd one at onScriptLoad as:-
Array2 <- array(1,2,3)
Now I executed them as:-
foreach(a in Array1)
{
print(a);
}
Output:-
3
2
1
2nd one as:-
foreach(a in Array2)
{
print(a);
}
Output:-
2
So what's the difference between a array and a global variable?
You dumb f... How many times have I told you to read the documentation. array(...) is just a helper function that takes a number and a value and then creates an array with the size of the specified number and fills it with the specified value. Equivalent of:
function array(size, fill = null)
{
local a = [];
a.resize(size, fill);
return a;
}
Therefore your second statement creates and array with 1 element and fills all elements (
meaning a single element) with the integer value `2`. The third argument is discarded/ignored.
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fs23.postimg.org%2F6ttsiazsr%2FUntitled.jpg&hash=e44a4c684dec12a68fa41293c406a0c715e0a9a4)
Thanks again!
Solved