29.10.2018, 07:28
For example I have 2 arrays.
array1 = {0, 5, 3};
and
array2 = {5, 0, 3};
How to check that those arrays are same?
array1 = {0, 5, 3};
and
array2 = {5, 0, 3};
How to check that those arrays are same?
new MyVAR[3] = {0, 5, 3};
new MyVAR2[3] = {5, 0, 3};
public OnFilterScriptInit()
{
if(MyVAR[2] == MyVAR2[2])
print("yes");
else print("no");
return 1;
}
for(new i; i < sizeof(MyVAR); i++)
{
for(i = 0; i < sizeof(MyVAR2); i++)
{
if(MyVAR[i] == MyVAR2[i])
printf("yes %d - %d", MyVAR[i], MyVAR2[i]);
else printf("no %d - %d", MyVAR[i], MyVAR2[i]);
}
}
new bool:are_same;
// If they are the same size
if (sizeof arr1 == sizeof arr2)
{
// Assume both arrays are the same
are_same = true;
// Iterate through both arrays
for (new i; i < sizeof arr1; i++)
{
// If both elements are not the same
if (arr1[i] != arr2[i])
{
// Both arrays are not the same
are_same = false;
// No need to check further elements
break;
}
}
}
// "are_same" is "true" if both arrays are the same, otherwise "false"